Sha256: 8ebfce9ab1fa1f8b7f23caab73a2a524f91d9f50bf7ffc2891ac43041ff15e07

Contents?: true

Size: 1.66 KB

Versions: 23

Compression:

Stored size: 1.66 KB

Contents

module Fog
  module Vsphere
    class Compute
      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
          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

23 entries across 23 versions & 1 rubygems

Version Path
fog-vsphere-3.7.0 lib/fog/vsphere/requests/compute/list_server_types.rb
fog-vsphere-3.6.8 lib/fog/vsphere/requests/compute/list_server_types.rb
fog-vsphere-3.6.7 lib/fog/vsphere/requests/compute/list_server_types.rb
fog-vsphere-3.6.6 lib/fog/vsphere/requests/compute/list_server_types.rb
fog-vsphere-3.6.5 lib/fog/vsphere/requests/compute/list_server_types.rb
fog-vsphere-3.6.4 lib/fog/vsphere/requests/compute/list_server_types.rb
fog-vsphere-3.6.3 lib/fog/vsphere/requests/compute/list_server_types.rb
fog-vsphere-3.6.2 lib/fog/vsphere/requests/compute/list_server_types.rb
fog-vsphere-3.5.3 lib/fog/vsphere/requests/compute/list_server_types.rb
fog-vsphere-3.6.0 lib/fog/vsphere/requests/compute/list_server_types.rb
fog-vsphere-3.5.2 lib/fog/vsphere/requests/compute/list_server_types.rb
fog-vsphere-3.5.1 lib/fog/vsphere/requests/compute/list_server_types.rb
fog-vsphere-3.5.0 lib/fog/vsphere/requests/compute/list_server_types.rb
fog-vsphere-3.4.0 lib/fog/vsphere/requests/compute/list_server_types.rb
fog-vsphere-3.3.1 lib/fog/vsphere/requests/compute/list_server_types.rb
fog-vsphere-3.3.0 lib/fog/vsphere/requests/compute/list_server_types.rb
fog-vsphere-3.2.5 lib/fog/vsphere/requests/compute/list_server_types.rb
fog-vsphere-3.2.2 lib/fog/vsphere/requests/compute/list_server_types.rb
fog-vsphere-3.2.1 lib/fog/vsphere/requests/compute/list_server_types.rb
fog-vsphere-3.2.0 lib/fog/vsphere/requests/compute/list_server_types.rb