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.



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

def cluster
  @cluster
end

#datacenterObject

Returns the value of attribute datacenter.



6
7
8
# File 'lib/fog/vsphere/models/compute/servers.rb', line 6

def datacenter
  @datacenter
end

#folderObject

Returns the value of attribute folder.



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

def folder
  @folder
end

#networkObject

Returns the value of attribute network.



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

def network
  @network
end

#recursiveObject

Returns the value of attribute recursive.



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

def recursive
  @recursive
end

#resource_poolObject

Returns the value of attribute resource_pool.



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

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.



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

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



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

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



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

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