Class: Fog::Compute::Vsphere::Servers

Inherits:
Fog::Collection show all
Defined in:
lib/fog/vsphere/models/compute/servers.rb

Instance Attribute Summary collapse

Attributes inherited from Fog::Collection

#service

Instance Method Summary collapse

Methods inherited from Fog::Collection

#clear, #create, #destroy, #initialize, #inspect, #load, model, #model, #new, #reload, #table, #to_json

Methods included from Attributes::ClassMethods

#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes

Methods included from Fog::Core::DeprecatedConnectionAccessors

#connection, #connection=, #prepare_service_value

Methods included from Attributes::InstanceMethods

#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #persisted?, #requires, #requires_one

Constructor Details

This class inherits a constructor from Fog::Collection

Instance Attribute Details

#clusterObject

Returns the value of attribute cluster.



13
14
15
# File 'lib/fog/vsphere/models/compute/servers.rb', line 13

def cluster
  @cluster
end

#datacenterObject

Returns the value of attribute datacenter.



11
12
13
# File 'lib/fog/vsphere/models/compute/servers.rb', line 11

def datacenter
  @datacenter
end

#folderObject

Returns the value of attribute folder.



15
16
17
# File 'lib/fog/vsphere/models/compute/servers.rb', line 15

def folder
  @folder
end

#networkObject

Returns the value of attribute network.



12
13
14
# File 'lib/fog/vsphere/models/compute/servers.rb', line 12

def network
  @network
end

#resource_poolObject

Returns the value of attribute resource_pool.



14
15
16
# File 'lib/fog/vsphere/models/compute/servers.rb', line 14

def resource_pool
  @resource_pool
end

Instance Method Details

#all(filters = { }) ⇒ Object

‘folder’ => ‘/Datacenters/vm/Jeff/Templates’ will be MUCH faster. than simply listing everything.



19
20
21
22
23
24
25
26
27
# File 'lib/fog/vsphere/models/compute/servers.rb', line 19

def all(filters = { })
  load service.list_virtual_machines(filters.merge(
                                          :datacenter    => datacenter,
                                          :cluster       => cluster,
                                          :network       => network,
                                          :resource_pool => resource_pool,
                                          :folder        => folder
                                        ))
end

#get(id, datacenter = nil) ⇒ Object



29
30
31
32
33
# File 'lib/fog/vsphere/models/compute/servers.rb', line 29

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