Class: InstanceProfile

Inherits:
BaseModel show all
Defined in:
lib/deltacloud/models/instance_profile.rb

Overview

Model to store the hardware profile applied to an instance together with any instance-specific overrides

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

attr_accessor, attributes, #attributes, #id, #to_entity

Constructor Details

#initialize(hwp_name, args = {}) ⇒ InstanceProfile

Returns a new instance of InstanceProfile.



26
27
28
29
30
31
32
33
# File 'lib/deltacloud/models/instance_profile.rb', line 26

def initialize(hwp_name, args = {})
  opts = args.inject({ :id => hwp_name.to_s }) do |m, e|
    k, v = e
    m[$1] = v if k.to_s =~ /^hwp_(.*)$/
    m
  end
  super(opts)
end

Instance Attribute Details

#architectureObject

Returns the value of attribute architecture.



23
24
25
# File 'lib/deltacloud/models/instance_profile.rb', line 23

def architecture
  @architecture
end

#cpuObject

Returns the value of attribute cpu.



24
25
26
# File 'lib/deltacloud/models/instance_profile.rb', line 24

def cpu
  @cpu
end

#memoryObject

Returns the value of attribute memory.



21
22
23
# File 'lib/deltacloud/models/instance_profile.rb', line 21

def memory
  @memory
end

#storageObject

Returns the value of attribute storage.



22
23
24
# File 'lib/deltacloud/models/instance_profile.rb', line 22

def storage
  @storage
end

Instance Method Details

#nameObject



35
36
37
# File 'lib/deltacloud/models/instance_profile.rb', line 35

def name
  id
end

#override?(property) ⇒ Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/deltacloud/models/instance_profile.rb', line 43

def override?(property)
  overrides.find { |p, v| p == property }
end

#overridesObject



47
48
49
50
51
52
53
54
# File 'lib/deltacloud/models/instance_profile.rb', line 47

def overrides
  [:memory, :storage, :architecture, :cpu].inject({}) do |h, p|
    if v = instance_variable_get("@#{p}")
      h[p] = v
    end
    h
  end
end

#to_sObject



39
40
41
# File 'lib/deltacloud/models/instance_profile.rb', line 39

def to_s
  name
end