Sha256: cbca07da541bcb7748d37cd362314473726f8edc9745a9303af7e32beee74203

Contents?: true

Size: 1.29 KB

Versions: 11

Compression:

Stored size: 1.29 KB

Contents

module Fog
  module Compute
    class Vsphere
      class Real
        def list_storage_pods(filters = { })
          datacenter_name = filters[:datacenter]
          raw_storage_pods(datacenter_name).map do |storage_pod|
            storage_pod_attributes(storage_pod, datacenter_name)
          end.compact
        end

        private
        def raw_storage_pods(datacenter_name)
          dc = find_raw_datacenter(datacenter_name)

          connection.serviceContent.viewManager.CreateContainerView({
            :container  => dc,
            :type       => ["StoragePod"],
            :recursive  => true
          }).view
        end
        protected

        def storage_pod_attributes storage_pod, datacenter
          {
            :id          => managed_obj_id(storage_pod),
            :name        => storage_pod.name,
            :freespace   => storage_pod.summary.freeSpace,
            :capacity    => storage_pod.summary.capacity,
            :datacenter  => datacenter,
          }
        end
      end
      class Mock
        def list_storage_pods(filters = {})
          if filters.key?(:datacenter)
            self.data[:storage_pods].select{|h| h[:datacenter] == filters[:datacenter] }
          else
            self.data[:storage_pods]
          end
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

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