Sha256: 634d4261e5c6668d8763c8589ba18527cf89b583aee50d95bbd58e0810c976c1

Contents?: true

Size: 1.33 KB

Versions: 10

Compression:

Stored size: 1.33 KB

Contents

module Fog
  module Vsphere
    class Compute
      class Servers < Fog::Collection
        autoload :Server, File.expand_path('../server', __FILE__)

        model Fog::Vsphere::Compute::Server
        attr_accessor :datacenter
        attr_accessor :network
        attr_accessor :cluster
        attr_accessor :resource_pool
        attr_accessor :folder
        attr_accessor :recursive

        # 'folder' => '/Datacenters/vm/Jeff/Templates' will be MUCH faster.
        # than simply listing everything.
        def all(filters = {})
          f = {
            datacenter: datacenter,
            cluster: cluster,
            network: network,
            resource_pool: resource_pool,
            folder: folder,
            recursive: recursive
          }.merge(filters)

          load service.list_virtual_machines(f)
        end

        def get(id, datacenter = nil)
          new service.get_virtual_machine id, datacenter, folder, recursive
        rescue Fog::Vsphere::Compute::NotFound
          nil
        end

        # Pass attributes we know about down to any VM we're creating
        def new(attributes = {})
          super({
            datacenter: datacenter,
            path: folder,
            cluster: cluster,
            resource_pool: resource_pool
          }.merge(attributes))
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
fog-vsphere-3.4.0 lib/fog/vsphere/models/compute/servers.rb
fog-vsphere-3.3.1 lib/fog/vsphere/models/compute/servers.rb
fog-vsphere-3.3.0 lib/fog/vsphere/models/compute/servers.rb
fog-vsphere-3.2.5 lib/fog/vsphere/models/compute/servers.rb
fog-vsphere-3.2.2 lib/fog/vsphere/models/compute/servers.rb
fog-vsphere-3.2.1 lib/fog/vsphere/models/compute/servers.rb
fog-vsphere-3.2.0 lib/fog/vsphere/models/compute/servers.rb
fog-vsphere-3.1.1 lib/fog/vsphere/models/compute/servers.rb
fog-vsphere-3.1.0 lib/fog/vsphere/models/compute/servers.rb
fog-vsphere-3.0.0 lib/fog/vsphere/models/compute/servers.rb