Sha256: 6a7241468e9797a6583ed688f7b45966f67947217a122766685803ddd3bcc11f

Contents?: true

Size: 1.79 KB

Versions: 16

Compression:

Stored size: 1.79 KB

Contents

require 'fog/core/collection'
require 'fog/vcloud_director/models/compute/network'

module Fog
  module Compute
    class VcloudDirector
      class Networks < Collection

        include Fog::VcloudDirector::Query

        model Fog::Compute::VcloudDirector::Network

        attribute :organization

        def query_type
          "orgVdcNetwork"
        end

        private

        def get_by_id(item_id)
          raw_network = service.get_network_complete(item_id).body
          data = {}
          data[:type] = raw_network[:type]
          data[:href] = raw_network[:href]
          service.add_id_from_href!(data)
          data[:name] = raw_network[:name]
          data[:description] = raw_network[:Description]
          data[:is_shared] = raw_network[:IsShared]
          net_config = raw_network[:Configuration]
          data[:fence_mode] = net_config[:FenceMode]
          ip_scope = net_config[:IpScopes][:IpScope]
          data[:is_inherited] = ip_scope[:IsInherited]
          data[:gateway] = ip_scope[:Gateway]
          data[:netmask] = ip_scope[:Netmask]
          data[:dns1] = ip_scope[:Dns1]
          data[:dns2] = ip_scope[:Dns2]
          data[:dns_suffix] = ip_scope[:DnsSuffix]
          data[:ip_ranges] = []
          raw_ip_ranges = ip_scope[:IpRanges][:IpRange]
          data[:ip_ranges] = raw_ip_ranges.map do |ip_range|
            { :start_address => ip_range[:StartAddress],
              :end_address   => ip_range[:EndAddress] }
          end
          data
        end

        def item_list
          data = service.get_organization(organization.id).body
          items = data[:Link].select { |link| link[:type] == "application/vnd.vmware.vcloud.orgNetwork+xml" }
          items.each{|item| service.add_id_from_href!(item) }
          items
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 3 rubygems

Version Path
fog-1.36.0 lib/fog/vcloud_director/models/compute/networks.rb
fog-1.35.0 lib/fog/vcloud_director/models/compute/networks.rb
fog-2.0.0.pre.0 lib/fog/vcloud_director/models/compute/networks.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-1.32.0/lib/fog/vcloud_director/models/compute/networks.rb
fog-1.34.0 lib/fog/vcloud_director/models/compute/networks.rb
fog-1.33.0 lib/fog/vcloud_director/models/compute/networks.rb
fog-1.32.0 lib/fog/vcloud_director/models/compute/networks.rb
fog-1.31.0 lib/fog/vcloud_director/models/compute/networks.rb
fog-1.30.0 lib/fog/vcloud_director/models/compute/networks.rb
fog-1.29.0 lib/fog/vcloud_director/models/compute/networks.rb
fog-1.28.0 lib/fog/vcloud_director/models/compute/networks.rb
fog-1.27.0 lib/fog/vcloud_director/models/compute/networks.rb
fog-1.26.0 lib/fog/vcloud_director/models/compute/networks.rb
fog-1.25.0 lib/fog/vcloud_director/models/compute/networks.rb
nsidc-fog-1.24.1 lib/fog/vcloud_director/models/compute/networks.rb
fog-1.24.0 lib/fog/vcloud_director/models/compute/networks.rb