Class: Fog::Compute::Hyperv::Cluster

Inherits:
Hyperv::Model show all
Defined in:
lib/fog/hyperv/models/compute/cluster.rb

Instance Method Summary collapse

Methods inherited from Hyperv::Model

#initialize

Methods included from Hyperv::ModelExtends

#lazy_attributes

Methods included from Hyperv::ModelIncludes

#cluster, #computer, #dirty?, #lazy_attributes, #parent, #vm

Constructor Details

This class inherits a constructor from Fog::Hyperv::Model

Instance Method Details

#hostsObject



22
23
24
# File 'lib/fog/hyperv/models/compute/cluster.rb', line 22

def hosts
  attributes[:hosts] ||= id.nil? ? [] : nodes.map { |n| service.hosts.get(n[:name]) }
end

#nodesObject

end



18
19
20
# File 'lib/fog/hyperv/models/compute/cluster.rb', line 18

def nodes
  attributes[:nodes] ||= id.nil? ? [] : [service.get_cluster_node(cluster: name, _return_fields: [:description, :name, :node_name])].flatten
end

#reloadObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# 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
  )

  attributes[:nodes] = nil
  attributes[:hosts] = nil

  merge_attributes(data.attributes)
  self
end