Class: Deltacloud::DSL::InstanceProfile

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/instance_profile.rb

Instance Method Summary collapse

Constructor Details

#initialize(name, &block) ⇒ InstanceProfile

Returns a new instance of InstanceProfile.



12
13
14
15
# File 'lib/instance_profile.rb', line 12

def initialize(name, &block)
  super(:name => name)
  define &block
end

Instance Method Details

#define {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



17
18
19
# File 'lib/instance_profile.rb', line 17

def define(&block)
  yield self if block_given?
end

#to_instance_paramsObject

Convert InstanceProfile to DeltaCloud create_instance method parameters. Some property names varies from the names used in DeltaCloud. This method will deal with them.



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

def to_instance_params
  params = self.marshal_dump
  params[:hardware_profile] = params.delete(:name)
  params[:hwp_memory] = params.delete(:memory) unless params[:memory].nil?
  params[:hwp_cpu] = params.delete(:cpu) unless params[:cpu].nil?
  params[:hwp_storage] = params.delete(:storage) unless params[:storage].nil?
  params
end