Sha256: 0060ad0e94c0fd55e2768553b7cc200c72f4ddb7e44709189781374068253b37

Contents?: true

Size: 1.5 KB

Versions: 30

Compression:

Stored size: 1.5 KB

Contents

module Fog
  module 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

30 entries across 30 versions & 2 rubygems

Version Path
fog-0.2.30 lib/fog/vcloud/requests/get_network.rb
fog-0.2.28 lib/fog/vcloud/requests/get_network.rb
fog-0.2.27 lib/fog/vcloud/requests/get_network.rb
fog-0.2.26 lib/fog/vcloud/requests/get_network.rb
fog-0.2.25 lib/fog/vcloud/requests/get_network.rb
fog-0.2.24 lib/fog/vcloud/requests/get_network.rb
tecnh-fog-0.2.23.vpc lib/fog/vcloud/requests/get_network.rb
fog-0.2.23 lib/fog/vcloud/requests/get_network.rb
fog-0.2.22 lib/fog/vcloud/requests/get_network.rb
fog-0.2.21 lib/fog/vcloud/requests/get_network.rb
fog-0.2.20 lib/fog/vcloud/requests/get_network.rb
fog-0.2.19 lib/fog/vcloud/requests/get_network.rb
fog-0.2.18 lib/fog/vcloud/requests/get_network.rb
fog-0.2.17 lib/fog/vcloud/requests/get_network.rb
fog-0.2.16 lib/fog/vcloud/requests/get_network.rb
fog-0.2.15 lib/fog/vcloud/requests/get_network.rb
fog-0.2.14 lib/fog/vcloud/requests/get_network.rb
fog-0.2.13 lib/fog/vcloud/requests/get_network.rb
fog-0.2.12 lib/fog/vcloud/requests/get_network.rb
fog-0.2.11 lib/fog/vcloud/requests/get_network.rb