Class: Fog::Compute::Hyperv::Cluster
Class Method Summary
collapse
Instance Method Summary
collapse
#lazy_attributes
#cluster, #computer, #dirty?, #lazy_attributes, #parent, #vm
Constructor Details
#initialize(attrs = {}) ⇒ Cluster
Returns a new instance of Cluster.
11
12
13
14
15
16
|
# File 'lib/fog/hyperv/models/compute/cluster.rb', line 11
def initialize(attrs = {})
super
@collections = {}
self.class.ensure_collections!
end
|
Class Method Details
.ensure_collections! ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/fog/hyperv/models/compute/cluster.rb', line 40
def self.ensure_collections!
return if @collections
@collections = true
Fog::Compute::Hyperv.collections.each do |coll|
next if coll == :hosts
coll_name = coll.to_s.split('_').map(&:capitalize).join
klass = Fog::Compute::Hyperv.const_get(coll_name)
next if klass.requires?(:vm)
define_method coll do
@collections[coll] ||= service.send(coll, cluster: self)
end
end
end
|
Instance Method Details
#hosts ⇒ Object
22
23
24
|
# File 'lib/fog/hyperv/models/compute/cluster.rb', line 22
def hosts
@hosts ||= nodes.map { |n| service.hosts.get(n[:name]) }
end
|
#nodes ⇒ Object
18
19
20
|
# File 'lib/fog/hyperv/models/compute/cluster.rb', line 18
def nodes
@nodes ||= [service.get_cluster_node(cluster: name, _return_fields: [:description, :name, :node_name])].flatten
end
|
#reload ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/fog/hyperv/models/compute/cluster.rb', line 26
def reload
requires_one :domain, :name
data = service.get_cluster(
domain: domain,
name: name,
_return_fields: self.class.attributes,
_json_depth: 1
)
merge_attributes(data.attributes)
self
end
|