Sha256: e43c93066afbdfcd7ddbff9effab5da49d0ebdacdf590ef6cf2920ffcc81fb5b

Contents?: true

Size: 1.42 KB

Versions: 40

Compression:

Stored size: 1.42 KB

Contents

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

        model Fog::Compute::Vsphere::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::Compute::Vsphere::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

40 entries across 40 versions & 1 rubygems

Version Path
fog-vsphere-1.7.0.1 lib/fog/vsphere/models/compute/servers.rb
fog-vsphere-2.1.1 lib/fog/vsphere/models/compute/servers.rb
fog-vsphere-2.1.0 lib/fog/vsphere/models/compute/servers.rb
fog-vsphere-2.0.1 lib/fog/vsphere/models/compute/servers.rb
fog-vsphere-2.0.0 lib/fog/vsphere/models/compute/servers.rb
fog-vsphere-1.13.1 lib/fog/vsphere/models/compute/servers.rb
fog-vsphere-1.13.0 lib/fog/vsphere/models/compute/servers.rb
fog-vsphere-1.12.0 lib/fog/vsphere/models/compute/servers.rb
fog-vsphere-1.11.3 lib/fog/vsphere/models/compute/servers.rb
fog-vsphere-1.11.2 lib/fog/vsphere/models/compute/servers.rb
fog-vsphere-1.11.1 lib/fog/vsphere/models/compute/servers.rb
fog-vsphere-1.11.0 lib/fog/vsphere/models/compute/servers.rb
fog-vsphere-1.10.0 lib/fog/vsphere/models/compute/servers.rb
fog-vsphere-1.9.2 lib/fog/vsphere/models/compute/servers.rb
fog-vsphere-1.9.1 lib/fog/vsphere/models/compute/servers.rb
fog-vsphere-1.9.0 lib/fog/vsphere/models/compute/servers.rb
fog-vsphere-1.8.0 lib/fog/vsphere/models/compute/servers.rb
fog-vsphere-1.7.1 lib/fog/vsphere/models/compute/servers.rb
fog-vsphere-1.7.0 lib/fog/vsphere/models/compute/servers.rb
fog-vsphere-1.6.0 lib/fog/vsphere/models/compute/servers.rb