Class: Pec::Handler::Networks::IpAddress

Inherits:
OptionBase
  • Object
show all
Defined in:
lib/pec/handler/networks/ip_address.rb

Class Method Summary collapse

Class Method Details

.build(network) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/pec/handler/networks/ip_address.rb', line 6

def build(network)
  ip = IP.new(network[1]['ip_address'])
  subnet = Yao::Subnet.list.find {|s|s.cidr == ip.network.to_s}

  if ip.to_s != subnet.cidr
    {
      fixed_ips: [
        { subnet_id: subnet.id, ip_address: ip.to_addr}
      ]
    }
  end
end