Sha256: 4fc390d2e2dc7334988904e0ed5f0579cd24e55c1d4fd255e9d217c00461c612

Contents?: true

Size: 1.36 KB

Versions: 91

Compression:

Stored size: 1.36 KB

Contents

module Fog
  module Vcloud
    class Compute
      class Real

        def validate_network_data(network_data, configure=false)
          valid_opts = [:id, :href, :name, :address, :broadcast, :gateway]
          unless valid_opts.all? { |opt| network_data.has_key?(opt) }
            raise ArgumentError.new("Required data missing: #{(valid_opts - network_data.keys).map(&:inspect).join(", ")}")
          end
        end

        def configure_network(network_uri, network_data)
          validate_network_data(network_data)

          request(
            :body     => generate_configure_network_request(network_data),
            :expects  => 200,
            :headers  => {'Content-Type' => 'application/vnd.vmware.vcloud.networkService+xml'},
            :method   => 'PUT',
            :uri      => network_uri,
            :parse    => true
          )
        end

        private

        def generate_configure_network_request(network_data)
          builder = Builder::XmlMarkup.new
          builder.Network(xmlns) {
            builder.Id(network_data[:id])
            builder.Href(network_data[:href])
            builder.Name(network_data[:name])
            builder.Address(network_data[:address])
            builder.BroadcastAddress(network_data[:broadcast])
            builder.GatewayAddress(network_data[:gateway])
          }
        end

      end
    end
  end
end

Version data entries

91 entries across 91 versions & 16 rubygems

Version Path
fog-1.22.0 lib/fog/vcloud/requests/compute/configure_network.rb
fog-1.21.0 lib/fog/vcloud/requests/compute/configure_network.rb
fog-maestrodev-1.20.0.20140305101839 lib/fog/vcloud/requests/compute/configure_network.rb
fog-maestrodev-1.20.0.20140305101305 lib/fog/vcloud/requests/compute/configure_network.rb
fog-maestrodev-1.19.0.20140212012611 lib/fog/vcloud/requests/compute/configure_network.rb
fog-1.20.0 lib/fog/vcloud/requests/compute/configure_network.rb
fog-maestrodev-1.19.0.20140110004459 lib/fog/vcloud/requests/compute/configure_network.rb
fog-maestrodev-1.19.0.20140110003812 lib/fog/vcloud/requests/compute/configure_network.rb
fog-maestrodev-1.19.0.20140109202555 lib/fog/vcloud/requests/compute/configure_network.rb
fog-maestrodev-1.19.0.20140107192102 lib/fog/vcloud/requests/compute/configure_network.rb
fog-maestrodev-1.19.0.20140107142106 lib/fog/vcloud/requests/compute/configure_network.rb
fog-maestrodev-1.19.0.20131219203941 lib/fog/vcloud/requests/compute/configure_network.rb
fog-maestrodev-1.18.0.20131219193542 lib/fog/vcloud/requests/compute/configure_network.rb
fog-1.19.0 lib/fog/vcloud/requests/compute/configure_network.rb
fog-maestrodev-1.18.0.20131219033443 lib/fog/vcloud/requests/compute/configure_network.rb
fog-maestrodev-1.18.0.20131219032002 lib/fog/vcloud/requests/compute/configure_network.rb
fog-maestrodev-1.18.0.20131219030716 lib/fog/vcloud/requests/compute/configure_network.rb
fog-maestrodev-1.18.0.20131219022322 lib/fog/vcloud/requests/compute/configure_network.rb
fog-maestrodev-1.18.0.20131218202447 lib/fog/vcloud/requests/compute/configure_network.rb
fog-maestrodev-1.18.0.20131209091424 lib/fog/vcloud/requests/compute/configure_network.rb