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
28
29
# File 'lib/fog/vsphere/models/compute/servers.rb', line 19

def all(filters = { })
  f = {
    :datacenter    => datacenter,
    :cluster       => cluster,
    :network       => network,
    :resource_pool => resource_pool,
    :folder        => folder
  }.merge(filters)

  load service.list_virtual_machines(f)
end

#get(id, datacenter = nil) ⇒ Object



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

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