Sha256: 1f807f3a5e9e23d2aeac77ad0342c256976fc86d644e364b2c1398aed3fdcfdc

Contents?: true

Size: 1.72 KB

Versions: 73

Compression:

Stored size: 1.72 KB

Contents

module Fog
  module Compute
    class Vsphere
      class Real
        def list_server_types(filters={})
          datacenter_name = filters[:datacenter]
          servertypes=raw_server_types(datacenter_name)
          if servertypes
            servertypes.map do | servertype |
               server_type_attributes(servertype, datacenter_name)
            end.compact
          else
            nil
          end
          #select{ | guestdesc | guestdesc.select{ | k, v | filter.has_key?(k) and filter[k] == v }==filter }
        end

        def raw_server_types(datacenter_name, filter={})
          datacenter=find_raw_datacenter(datacenter_name)
          environmentBrowser=datacenter.hostFolder.childEntity.grep(RbVmomi::VIM::ComputeResource).first.environmentBrowser
          if environmentBrowser
            environmentBrowser.QueryConfigOption[:guestOSDescriptor]
          end
        end

        protected

        def server_type_attributes(servertype, datacenter)
          {
            :id         => servertype.id,
            :name       => servertype.id,
            :family     => servertype.family,
            :fullname   => servertype.fullName,
            :datacenter => datacenter,
          }
        end
      end
      class Mock
        def list_server_types(datacenter_name)
          [{:id=>"rhel6Guest",
            :name=>"rhel6Guest",
            :family=>"linuxGuest",
            :fullname=>"Red Hat Enterprise Linux 6 (32-Bit)",
            :datacenter=>"Solutions"},
           {:id=>"rhel5_64Guest",
            :name=>"rhel5_64Guest",
            :family=>"linuxGuest",
            :fullname=>"Red Hat Enterprise Linux 5 (64-Bit)",
            :datacenter=>"Solutions"}]
        end
      end
    end
  end
end

Version data entries

73 entries across 73 versions & 5 rubygems

Version Path
fog-vsphere-1.5.2 lib/fog/vsphere/requests/compute/list_server_types.rb
fog-vsphere-1.5.1 lib/fog/vsphere/requests/compute/list_server_types.rb
fog-vsphere-1.5.0 lib/fog/vsphere/requests/compute/list_server_types.rb
fog-vsphere-1.4.0 lib/fog/vsphere/requests/compute/list_server_types.rb
fog-vsphere-1.3.0 lib/fog/vsphere/requests/compute/list_server_types.rb
fog-vsphere-1.2.2 lib/fog/vsphere/requests/compute/list_server_types.rb
fog-vsphere-1.2.1 lib/fog/vsphere/requests/compute/list_server_types.rb
fog-vsphere-1.2.0 lib/fog/vsphere/requests/compute/list_server_types.rb
fog-vsphere-1.1.0 lib/fog/vsphere/requests/compute/list_server_types.rb
fog-vsphere-1.0.1 lib/fog/vsphere/requests/compute/list_server_types.rb
fog-vsphere-1.0.0 lib/fog/vsphere/requests/compute/list_server_types.rb
fog-vsphere-0.8.1 lib/fog/vsphere/requests/compute/list_server_types.rb
fog-vsphere-0.8.0 lib/fog/vsphere/requests/compute/list_server_types.rb
fog-vsphere-0.7.0 lib/fog/vsphere/requests/compute/list_server_types.rb
fog-vsphere-0.6.4 lib/fog/vsphere/requests/compute/list_server_types.rb
fog-vsphere-0.6.3 lib/fog/vsphere/requests/compute/list_server_types.rb
fog-vsphere-0.6.2 lib/fog/vsphere/requests/compute/list_server_types.rb
fog-vsphere-0.6.1 lib/fog/vsphere/requests/compute/list_server_types.rb
fog-vsphere-0.6.0 lib/fog/vsphere/requests/compute/list_server_types.rb
fog-vsphere-0.5.0 lib/fog/vsphere/requests/compute/list_server_types.rb