Sha256: 863138356645d360f545297eaace5583b6e9914ea5ed0e22dc8555de6cef3aa1

Contents?: true

Size: 1.4 KB

Versions: 31

Compression:

Stored size: 1.4 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 = {}
          [ {:name => "Solutions", :status => "grey"}, {:name => "Solutions2", :status => "green" }]
        end
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 5 rubygems

Version Path
fog-1.36.0 lib/fog/vsphere/requests/compute/list_datacenters.rb
fog-vsphere-0.2.0 lib/fog/vsphere/requests/compute/list_datacenters.rb
fog-vsphere-0.1.1 lib/fog/vsphere/requests/compute/list_datacenters.rb
fog-vsphere-0.1.0 lib/fog/vsphere/requests/compute/list_datacenters.rb
fog-1.35.0 lib/fog/vsphere/requests/compute/list_datacenters.rb
fog-2.0.0.pre.0 lib/fog/vsphere/requests/compute/list_datacenters.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-1.32.0/lib/fog/vsphere/requests/compute/list_datacenters.rb
fog-1.34.0 lib/fog/vsphere/requests/compute/list_datacenters.rb
fog-1.33.0 lib/fog/vsphere/requests/compute/list_datacenters.rb
fog-1.32.0 lib/fog/vsphere/requests/compute/list_datacenters.rb
fog-1.31.0 lib/fog/vsphere/requests/compute/list_datacenters.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/fog-1.22.1/lib/fog/vsphere/requests/compute/list_datacenters.rb
fog-1.30.0 lib/fog/vsphere/requests/compute/list_datacenters.rb
fog-1.29.0 lib/fog/vsphere/requests/compute/list_datacenters.rb
fog-1.28.0 lib/fog/vsphere/requests/compute/list_datacenters.rb
fog-1.27.0 lib/fog/vsphere/requests/compute/list_datacenters.rb
fog-1.26.0 lib/fog/vsphere/requests/compute/list_datacenters.rb
fog-1.25.0 lib/fog/vsphere/requests/compute/list_datacenters.rb
nsidc-fog-1.24.1 lib/fog/vsphere/requests/compute/list_datacenters.rb
fog-1.24.0 lib/fog/vsphere/requests/compute/list_datacenters.rb