Sha256: 234fe7e35679130f5dc55a719c4e449c2956d56e7723f91d9b5b6a068beddca2

Contents?: true

Size: 1.34 KB

Versions: 14

Compression:

Stored size: 1.34 KB

Contents

module Fog
  module Compute
    class Vsphere
      class Real
        def list_datacenters filters = {}
          raw_datacenters.map do |dc|
            {
              :id => managed_obj_id(dc),
              :name => dc.name,
              :path => raw_getpathmo(dc),
              :status => dc.overallStatus
            }
          end
        end

        protected

        def raw_getpathmo mo
          if mo.parent == nil or mo.parent.name == connection.rootFolder.name then
            [ mo.name ]
          else
            [ raw_getpathmo(mo.parent), mo.name ].flatten
          end
        end

        def raw_datacenters folder=nil
          folder ||= connection.rootFolder
          @raw_datacenters ||= get_raw_datacenters_from_folder folder
        end

        def get_raw_datacenters_from_folder folder=nil
          folder.childEntity.map do | childE |
            if childE.is_a? RbVmomi::VIM::Datacenter
               childE
            elsif childE.is_a? RbVmomi::VIM::Folder
               get_raw_datacenters_from_folder childE
            end
          end.flatten
        end

        def find_datacenters name=nil
          name ? [find_raw_datacenter(name)] : raw_datacenters
        end
      end

      class Mock
        def list_datacenters filters = {}
          self.data[:datacenters].values
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
fog-vsphere-2.1.1 lib/fog/vsphere/requests/compute/list_datacenters.rb
fog-vsphere-2.1.0 lib/fog/vsphere/requests/compute/list_datacenters.rb
fog-vsphere-2.0.1 lib/fog/vsphere/requests/compute/list_datacenters.rb
fog-vsphere-2.0.0 lib/fog/vsphere/requests/compute/list_datacenters.rb
fog-vsphere-1.13.1 lib/fog/vsphere/requests/compute/list_datacenters.rb
fog-vsphere-1.13.0 lib/fog/vsphere/requests/compute/list_datacenters.rb
fog-vsphere-1.12.0 lib/fog/vsphere/requests/compute/list_datacenters.rb
fog-vsphere-1.11.3 lib/fog/vsphere/requests/compute/list_datacenters.rb
fog-vsphere-1.11.2 lib/fog/vsphere/requests/compute/list_datacenters.rb
fog-vsphere-1.11.1 lib/fog/vsphere/requests/compute/list_datacenters.rb
fog-vsphere-1.11.0 lib/fog/vsphere/requests/compute/list_datacenters.rb
fog-vsphere-1.10.0 lib/fog/vsphere/requests/compute/list_datacenters.rb
fog-vsphere-1.9.2 lib/fog/vsphere/requests/compute/list_datacenters.rb
fog-vsphere-1.9.1 lib/fog/vsphere/requests/compute/list_datacenters.rb