Module: ForemanNetbox::Concerns::PrimaryIps

Included in:
SyncHost::SyncDevice::Update, SyncHost::SyncVirtualMachine::Update
Defined in:
app/interactors/foreman_netbox/concerns/primary_ips.rb

Instance Method Summary collapse

Instance Method Details

#ip_addresses_mapObject



18
19
20
21
22
# File 'app/interactors/foreman_netbox/concerns/primary_ips.rb', line 18

def ip_addresses_map
  @ip_addresses_map ||= context.ip_addresses.each_with_object({}) do |ip, hash|
    hash[ip.address.to_i] = ip.id
  end
end

#primary_ip4Object



6
7
8
9
10
# File 'app/interactors/foreman_netbox/concerns/primary_ips.rb', line 6

def primary_ip4
  return if context.host.ip.blank?

  ip_addresses_map[IPAddr.new(context.host.ip).to_i]
end

#primary_ip6Object



12
13
14
15
16
# File 'app/interactors/foreman_netbox/concerns/primary_ips.rb', line 12

def primary_ip6
  return if context.host.ip6.blank?

  ip_addresses_map[IPAddr.new(context.host.ip6).to_i]
end