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

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#clusterObject

Returns the value of attribute cluster.



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

def cluster
  @cluster
end

#datacenterObject

Returns the value of attribute datacenter.



8
9
10
# File 'lib/fog/vsphere/models/compute/servers.rb', line 8

def datacenter
  @datacenter
end

#folderObject

Returns the value of attribute folder.



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

def folder
  @folder
end

#networkObject

Returns the value of attribute network.



9
10
11
# File 'lib/fog/vsphere/models/compute/servers.rb', line 9

def network
  @network
end

#recursiveObject

Returns the value of attribute recursive.



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

def recursive
  @recursive
end

#resource_poolObject

Returns the value of attribute resource_pool.



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

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.



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

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

#get(id, datacenter = nil) ⇒ Object



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

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

#new(attributes = {}) ⇒ Object

Pass attributes we know about down to any VM we’re creating



37
38
39
40
41
42
43
44
# File 'lib/fog/vsphere/models/compute/servers.rb', line 37

def new(attributes = {})
  super({
    datacenter: datacenter,
    path: folder,
    cluster: cluster,
    resource_pool: resource_pool
  }.merge(attributes))
end