Project

General

Profile

« Previous | Next » 

Revision adf5a9e6

Added by alejandrocfg over 7 years ago

Fixes #16619 - Set EC2 VPC instance private IP from primary NIC

View differences:

app/models/compute_resource.rb
def host_interfaces_attrs(host)
host.interfaces.select(&:physical?).each.with_index.reduce({}) do |hash, (nic, index)|
hash.merge(index.to_s => nic.compute_attributes)
hash.merge(index.to_s => nic.compute_attributes.merge(ip: nic.ip, ip6: nic.ip6))
end
end
app/models/compute_resources/foreman/model/ec2.rb
args[:groups].reject!(&:empty?) if args.has_key?(:groups)
args[:security_group_ids].reject!(&:empty?) if args.has_key?(:security_group_ids)
args[:associate_public_ip] = subnet_implies_is_vpc?(args) && args[:managed_ip] == 'public'
args[:private_ip_address] = args[:interfaces_attributes][:"0"][:ip]
super(args)
rescue Fog::Errors::Error => e
Foreman::Logging.exception("Unhandled EC2 error", e)

Also available in: Unified diff