Sha256: 6539d970042f88cbf70874422ec50eec7f70dd8bbf02f53c7c44e3a13430d849

Contents?: true

Size: 1.11 KB

Versions: 4

Compression:

Stored size: 1.11 KB

Contents

module Fog
  module Compute
    class Vsphere
      class Real
        def list_networks(filters = { })
          datacenter_name = filters[:datacenter]
          # default to show all networks
          only_active = filters[:accessible] || false
          raw_networks(datacenter_name).map do |network|
            next if only_active and !network.summary.accessible
            network_attributes(network, datacenter_name)
          end.compact
        end

        def raw_networks(datacenter_name)
          find_raw_datacenter(datacenter_name).network
        end

        protected

        def network_attributes network, datacenter
          {
            :id            => managed_obj_id(network),
            :name          => network.name,
            :accessible    => network.summary.accessible,
            :datacenter    => datacenter,
            :virtualswitch => network.class.name == "DistributedVirtualPortgroup" ? network.config.distributedVirtualSwitch.name : nil
          }
        end
      end
      class Mock
        def list_networks(datacenter_name)
          []
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
fog-1.36.0 lib/fog/vsphere/requests/compute/list_networks.rb
fog-vsphere-0.2.0 lib/fog/vsphere/requests/compute/list_networks.rb
fog-vsphere-0.1.1 lib/fog/vsphere/requests/compute/list_networks.rb
fog-vsphere-0.1.0 lib/fog/vsphere/requests/compute/list_networks.rb