lib/vcloud-rest/vcloud/vapp_networking.rb
def merge_network_config(vapp_networks, new_network, config)
        net_configuration = new_network.css('Configuration').first

        fence_mode = new_network.css('FenceMode').first
        fence_mode.content = config[:fence_mode] || 'isolated'

        network_features = Nokogiri::XML::Node.new "Features", net_configuration
        firewall_service = Nokogiri::XML::Node.new "FirewallService", network_features
        firewall_enabled = Nokogiri::XML::Node.new "IsEnabled", firewall_service
        firewall_enabled.content = config[:firewall_enabled] || "false"

        firewall_service.add_child(firewall_enabled)
        network_features.add_child(firewall_service)
        net_configuration.add_child(network_features)

        if config[:parent_network]
          # At this stage, set itself as parent network
          parent_network = Nokogiri::XML::Node.new "ParentNetwork", net_configuration
          parent_network["href"] = "#{@api_url}/network/#{config[:parent_network][:id]}"
          parent_network["name"] = config[:parent_network][:name]
          parent_network["type"] = "application/vnd.vmware.vcloud.network+xml"
          new_network.css('IpScopes').first.add_next_sibling(parent_network)
        end

        vapp_networks.to_xml.gsub("<PLACEHOLDER/>", new_network.css('Configuration').to_xml)
      end
def merge_network_config(vapp_networks, new_network, config)
        net_configuration = new_network.css('Configuration').first

        fence_mode = new_network.css('FenceMode').first
        fence_mode.content = config[:fence_mode] || 'isolated'

        network_features = Nokogiri::XML::Node.new "Features", net_configuration
        firewall_service = Nokogiri::XML::Node.new "FirewallService", network_features
        firewall_enabled = Nokogiri::XML::Node.new "IsEnabled", firewall_service
        firewall_enabled.content = config[:firewall_enabled] || "false"

        firewall_service.add_child(firewall_enabled)
        network_features.add_child(firewall_service)
        net_configuration.add_child(network_features)

        if config[:parent_network]
          # At this stage, set itself as parent network
          parent_network = Nokogiri::XML::Node.new "ParentNetwork", net_configuration
          parent_network["href"] = "#{@api_url}/network/#{config[:parent_network][:id]}"
          parent_network["name"] = config[:parent_network][:name]
          parent_network["type"] = "application/vnd.vmware.vcloud.network+xml"
          new_network.css('IpScopes').first.add_next_sibling(parent_network)
        end

        vapp_networks.to_xml.gsub("<PLACEHOLDER/>", new_network.css('Configuration').to_xml)
      end
def merge_network_config ( vapp_networks , new_network , config ) net_configuration = new_network . css ( 'Configuration' ) . first fence_mode = new_network . css ( 'FenceMode' ) . first fence_mode . content = config [ :fence_mode ] || 'isolated' network_features = Nokogiri :: XML :: Node . new "Features" , net_configuration firewall_service = Nokogiri :: XML :: Node . new "FirewallService" , network_features firewall_enabled = Nokogiri :: XML :: Node . new "IsEnabled" , firewall_service firewall_enabled . content = config [ :firewall_enabled ] || "false" firewall_service . add_child ( firewall_enabled ) network_features . add_child ( firewall_service ) net_configuration . add_child ( network_features ) if config [ :parent_network ] # At this stage, set itself as parent network parent_network = Nokogiri :: XML :: Node . new "ParentNetwork" , net_configuration parent_network [ "href" ] = "#{@api_url}/network/#{config[:parent_network][:id]}" parent_network [ "name" ] = config [ :parent_network ] [ :name ] parent_network [ "type" ] = "application/vnd.vmware.vcloud.network+xml" new_network . css ( 'IpScopes' ) . first . add_next_sibling ( parent_network ) end vapp_networks . to_xml . gsub ( "<PLACEHOLDER/>" , new_network . css ( 'Configuration' ) . to_xml ) end
Merge the Configuration section of a new network and add specific configuration
Merge the Configuration section of a new network and add specific configuration