Module: Fog::Hyperv::ModelIncludes

Included in:
Compute::Server, Model
Defined in:
lib/fog/hyperv/model.rb

Instance Method Summary collapse

Instance Method Details

#clusterFog::Hyperv::Compute::Cluster?

Get the Cluster this model is part of

Returns:



76
77
78
79
80
81
# File 'lib/fog/hyperv/model.rb', line 76

def cluster
  return @cluster if @cluster
  return unless respond_to?(:cluster_name) && cluster_name

  @cluster ||= service.clusters.get cluster_name
end

#computerFog::Hyperv::Compute::Host?

Get the Computer this model is attached to

Returns:



67
68
69
70
71
72
# File 'lib/fog/hyperv/model.rb', line 67

def computer
  return @computer if @computer
  return @computer ||= service.hosts.get(computer_name) if respond_to?(:computer_name) && computer_name

  @computer ||= vm&.computer
end

#dirtyArray<Symbol>

Get all dirty attributes

Returns:

  • (Array<Symbol>)

    all the attributes that have changed since the model was retrieved



49
50
51
52
53
54
# File 'lib/fog/hyperv/model.rb', line 49

def dirty
  potential = attributes.slice(*self.class.attributes)
  return potential unless old

  potential.reject { |k, v| old.attributes[k] == v }.keys
end

#dirty?Boolean

Has the model been modified

Returns:

  • (Boolean)

    have any attributes changed since the model was retrieved



43
44
45
# File 'lib/fog/hyperv/model.rb', line 43

def dirty?
  dirty.any?
end

#vmFog::Hyperv::Compute::Server?

Get the VM this model is attached to

Returns:



58
59
60
61
62
63
# File 'lib/fog/hyperv/model.rb', line 58

def vm
  return @vm if @vm
  return unless respond_to?(:vm_id) && vm_id

  @vm ||= service.servers.get vm_id
end