Chapter 09/circuit-oneops-1-master/components/cookbooks/azure/libraries/network_interface_card.rb
# define the NIC's IP Config
define the NIC's IP Config
define the NIC ' s IP Config
def define_nic_ip_config(ip_type, subnet)
      nic_ip_config_props =
        Azure::ARM::Network::Models::NetworkInterfaceIpConfigurationPropertiesFormat.new
      nic_ip_config_props.private_ipallocation_method =
        Azure::ARM::Network::Models::IpAllocationMethod::Dynamic
      nic_ip_config_props.subnet = subnet
      if ip_type == 'public'
        publicip = AzureNetwork::PublicIp.new(@creds, @subscription)
        publicip.location = @location
        public_ip_address = publicip.build_public_ip_object(@ci_id)
        public_ip_if =
          publicip.create_update(@rg_name,
                                 public_ip_address.name,
                                 public_ip_address)
        nic_ip_config_props.public_ipaddress = public_ip_if
      end
      nic_ip_config =
        Azure::ARM::Network::Models::NetworkInterfaceIpConfiguration.new
      nic_ip_config.name = Utils.get_component_name("privateip",@ci_id)
      nic_ip_config.properties = nic_ip_config_props
      OOLog.info("NIC IP name is: #{nic_ip_config.name}")
      nic_ip_config
    end
def define_nic_ip_config ( ip_type , subnet ) nic_ip_config_props = Azure :: ARM :: Network :: Models :: NetworkInterfaceIpConfigurationPropertiesFormat . new nic_ip_config_props . private_ipallocation_method = Azure :: ARM :: Network :: Models :: IpAllocationMethod :: Dynamic nic_ip_config_props . subnet = subnet if ip_type == 'public' publicip = AzureNetwork :: PublicIp . new ( @creds , @subscription ) publicip . location = @location public_ip_address = publicip . build_public_ip_object ( @ci_id ) public_ip_if = publicip . create_update ( @rg_name , public_ip_address . name , public_ip_address ) nic_ip_config_props . public_ipaddress = public_ip_if end nic_ip_config = Azure :: ARM :: Network :: Models :: NetworkInterfaceIpConfiguration . new nic_ip_config . name = Utils . get_component_name ( "privateip" , @ci_id ) nic_ip_config . properties = nic_ip_config_props OOLog . info ( "NIC IP name is: #{nic_ip_config.name}" ) nic_ip_config end
define the NIC's IP Config
define the NIC ' s IP Config
# get public ip object # create public ip # set the public ip on the nic ip config
ip_type
<not_specific>
subnet
<not_specific>