Sha256: c388591f8824bdc7c1d2d10fea2967924aabbb7c6d520e67c0f78353f08fa9d4

Contents?: true

Size: 1.47 KB

Versions: 29

Compression:

Stored size: 1.47 KB

Contents

module Fog
  class Vcloud

    class Real
      basic_request :get_network
    end

    class Mock

      def get_network(network_uri)
        #
        # Based off of:
        # vCloud API Guide v0.8 - Page 50
        #
        # Did not implement AssociatedNetwork, seems redundant, haven't seen it in use yet
        # Did not implement the following features: Dhcp, Nat & Firewall
        #
        network_uri = ensure_unparsed(network_uri)
        type = "application/vnd.vmware.vcloud.network+xml"
        response = Excon::Response.new
        if network = mock_data.organizations.map { |org| org.vdcs.map { |vdc| vdc.networks } }.flatten.detect { |network| network.href == network_uri.to_s }
          xml = Builder::XmlMarkup.new
          mock_it 200,
            xml.Network(xmlns.merge(:href => network.href, :name => network.name, :type => type)) {
              xml.Description(network.name)
              xml.Configuration {
                xml.Gateway(network.gateway)
                xml.Netmask(network.netmask)
                xml.Dns(network.dns)
              }
              if network.features
                xml.Features {
                  if feature = network.features.detect { |feature| feature[:type] == :FenceMode }
                    xml.FenceMode(feature[:value])
                  end
                }
              end
            },
            { 'Content-Type' => type }
        else
          mock_error 200, "401 Unauthorized"
        end
      end

    end
  end
end

Version data entries

29 entries across 29 versions & 3 rubygems

Version Path
fog-0.5.3 lib/fog/vcloud/requests/get_network.rb
fog-0.5.2 lib/fog/vcloud/requests/get_network.rb
fog-0.5.1 lib/fog/vcloud/requests/get_network.rb
fog-0.5.0 lib/fog/vcloud/requests/get_network.rb
phpfog-fog-0.4.1.3 lib/fog/vcloud/requests/get_network.rb
phpfog-fog-0.4.1.2 lib/fog/vcloud/requests/get_network.rb
phpfog-fog-0.4.1.1 lib/fog/vcloud/requests/get_network.rb
phpfog-fog-0.4.1 lib/fog/vcloud/requests/get_network.rb
fog-0.4.1 lib/fog/vcloud/requests/get_network.rb
fog-0.4.0 lib/fog/vcloud/requests/get_network.rb
fog-0.3.34 lib/fog/vcloud/requests/get_network.rb
fog-0.3.33 lib/fog/vcloud/requests/get_network.rb
fog-0.3.32 lib/fog/vcloud/requests/get_network.rb
fog-0.3.31 lib/fog/vcloud/requests/get_network.rb
fog-0.3.30 lib/fog/vcloud/requests/get_network.rb
fog-0.3.29 lib/fog/vcloud/requests/get_network.rb
fog-0.3.28 lib/fog/vcloud/requests/get_network.rb
fog-0.3.27 lib/fog/vcloud/requests/get_network.rb
fog-0.3.26 lib/fog/vcloud/requests/get_network.rb
fog-0.3.25 lib/fog/vcloud/requests/get_network.rb