lib/wire/commands/spec_command.rb
# given a network object, this generates spec
# for it.
# params:
# +zone_name+  name of zone (needed for erb context)
# +bridge_name+  name of network/bridge (needed for erb context)
# +network_data+  network details
# rubocop:disable Lint/UnusedMethodArgument
# rubocop:disable Lint/UselessAssignment
# :reek:UnusedParameters
given a network object, this generates spec
for it.
given a network object this generates spec for it .
def run_on_network_in_zone(zone_name, bridge_name, network_data)
      $log.debug("Creating specs for network #{bridge_name}")
      template = SpecTemplatesNetwork.build_template__bridge_exists
      erb = ERB.new(template, nil, '%')
      @spec_code << erb.result(binding)
      vlan = network_data[:vlan]
      if vlan
        vlanid = vlan[:id]
        on_trunk = vlan[:on_trunk]
        template = SpecTemplatesNetwork.build_template__bridge_vlan_id_and_trunk
        erb = ERB.new(template, nil, '%')
        @spec_code << erb.result(binding)
      end
      ip = network_data[:hostip]
      if ip
        template = SpecTemplatesNetwork.build_template__ip_is_up
        erb = ERB.new(template, nil, '%')
        @spec_code << erb.result(binding)
      end
      attach_intf = network_data[:attach]
      if attach_intf
        template = SpecTemplatesNetwork.build_template__port_exists
        erb = ERB.new(template, nil, '%')
        @spec_code << erb.result(binding)
      end
      dhcp_data = network_data[:dhcp]
      if dhcp_data
        ip_start = dhcp_data[:start]
        ip_end = dhcp_data[:end]
        hostip = ip
        template = SpecTemplatesNetwork.build_template__dhcp_is_valid
        erb = ERB.new(template, nil, '%')
        @spec_code << erb.result(binding)
      end
      $log.debug("Done for network #{bridge_name}")
    end
def run_on_network_in_zone ( zone_name , bridge_name , network_data ) $log . debug ( "Creating specs for network #{bridge_name}" ) template = SpecTemplatesNetwork . build_template__bridge_exists erb = ERB . new ( template , nil , '%' ) @spec_code << erb . result ( binding ) vlan = network_data [ :vlan ] if vlan vlanid = vlan [ :id ] on_trunk = vlan [ :on_trunk ] template = SpecTemplatesNetwork . build_template__bridge_vlan_id_and_trunk erb = ERB . new ( template , nil , '%' ) @spec_code << erb . result ( binding ) end ip = network_data [ :hostip ] if ip template = SpecTemplatesNetwork . build_template__ip_is_up erb = ERB . new ( template , nil , '%' ) @spec_code << erb . result ( binding ) end attach_intf = network_data [ :attach ] if attach_intf template = SpecTemplatesNetwork . build_template__port_exists erb = ERB . new ( template , nil , '%' ) @spec_code << erb . result ( binding ) end dhcp_data = network_data [ :dhcp ] if dhcp_data ip_start = dhcp_data [ :start ] ip_end = dhcp_data [ :end ] hostip = ip template = SpecTemplatesNetwork . build_template__dhcp_is_valid erb = ERB . new ( template , nil , '%' ) @spec_code << erb . result ( binding ) end $log . debug ( "Done for network #{bridge_name}" ) end
given a network object, this generates spec
for it.
given a network object this generates spec for it .
# render template for hostip (if any) # render template for network/port attachments (if any) # render dhcp spec (if any)
zone_name
<not_specific>
bridge_name
<not_specific>
network_data
<not_specific>