Chapter 09/circuit-oneops-1-master/components/cookbooks/azure/libraries/virtual_network.rb
# this method creates the vnet object that is later passed in to create
# the vnet
this method creates the vnet object that is later passed in to create
the vnet
this method creates the vnet object that is later passed in to create the vnet
def build_network_object
      OOLog.info("network_address: #{@address}")
      address_space = Azure::ARM::Network::Models::AddressSpace.new
      address_space.address_prefixes = [@address]
      ns_list = Array.new
      for i in 0..@dns_list.length-1
        OOLog.info('dns address[' + i.to_s + ']: ' + @dns_list[i].strip)
        ns_list.push(@dns_list[i].strip)
      end
      dhcp_options = Azure::ARM::Network::Models::DhcpOptions.new
      if ns_list != nil
        dhcp_options.dns_servers = ns_list
      end
      subnet = AzureNetwork::Subnet.new(@creds, @subscription)
      subnet.sub_address = @sub_address
      subnet.name = @name
      sub_nets = subnet.build_subnet_object
      virtual_network_properties =
        Azure::ARM::Network::Models::VirtualNetworkPropertiesFormat.new
      virtual_network_properties.address_space = address_space
      virtual_network_properties.dhcp_options = dhcp_options
      virtual_network_properties.subnets = sub_nets
      virtual_network = Azure::ARM::Network::Models::VirtualNetwork.new
      virtual_network.location = @location
      virtual_network.properties = virtual_network_properties
      virtual_network
    end
def build_network_object OOLog . info ( "network_address: #{@address}" ) address_space = Azure :: ARM :: Network :: Models :: AddressSpace . new address_space . address_prefixes = [ @address ] ns_list = Array . new for i in 0 .. @dns_list . length - 1 OOLog . info ( 'dns address[' + i . to_s + ']: ' + @dns_list [ i ] . strip ) ns_list . push ( @dns_list [ i ] . strip ) end dhcp_options = Azure :: ARM :: Network :: Models :: DhcpOptions . new if ns_list != nil dhcp_options . dns_servers = ns_list end subnet = AzureNetwork :: Subnet . new ( @creds , @subscription ) subnet . sub_address = @sub_address subnet . name = @name sub_nets = subnet . build_subnet_object virtual_network_properties = Azure :: ARM :: Network :: Models :: VirtualNetworkPropertiesFormat . new virtual_network_properties . address_space = address_space virtual_network_properties . dhcp_options = dhcp_options virtual_network_properties . subnets = sub_nets virtual_network = Azure :: ARM :: Network :: Models :: VirtualNetwork . new virtual_network . location = @location virtual_network . properties = virtual_network_properties virtual_network end
this method creates the vnet object that is later passed in to create
the vnet
this method creates the vnet object that is later passed in to create the vnet