Class: Megam::Mixins::CommonDeployable

Inherits:
Object
  • Object
show all
Includes:
Nilavu::MegamAttributes
Defined in:
lib/megam/mixins/common_deployable.rb

Constant Summary collapse

DEFAULT_TOSCA_PREFIX =
'tosca'.freeze
DEFAULT_TOSCA_SUFFIX =

this is a mutable string, if nothing exists then we use ubuntu

'ubuntu'.freeze
ATTRIBUTES =
[
:tosca_type,
:status,
:inputs]

Constants included from Nilavu::MegamAttributes

Nilavu::MegamAttributes::KEY, Nilavu::MegamAttributes::VALUE

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Nilavu::MegamAttributes

#set_attributes

Constructor Details

#initialize(params) ⇒ CommonDeployable

Returns a new instance of CommonDeployable.



37
38
39
40
41
42
43
44
# File 'lib/megam/mixins/common_deployable.rb', line 37

def initialize(params)
  @tosca_type = ''
  @status = 'launching'
  bld_toscatype(params)
  set_attributes(params)
  @inputs = InputGroupData.new(params)

end

Instance Attribute Details

#inputsObject (readonly)

Returns the value of attribute inputs.



22
23
24
# File 'lib/megam/mixins/common_deployable.rb', line 22

def inputs
  @inputs
end

#statusObject (readonly)

Returns the value of attribute status.



22
23
24
# File 'lib/megam/mixins/common_deployable.rb', line 22

def status
  @status
end

#tosca_typeObject (readonly)

Returns the value of attribute tosca_type.



22
23
24
# File 'lib/megam/mixins/common_deployable.rb', line 22

def tosca_type
  @tosca_type
end

Instance Method Details

#attributesObject



33
34
35
# File 'lib/megam/mixins/common_deployable.rb', line 33

def attributes
  ATTRIBUTES
end

#bld_toscatype(params) ⇒ Object



54
55
56
57
58
# File 'lib/megam/mixins/common_deployable.rb', line 54

def bld_toscatype(params)
  tosca_suffix = DEFAULT_TOSCA_SUFFIX
  tosca_suffix = "#{params[:mkp_name]}" unless params[:cattype] != 'TORPEDO'.freeze
  @tosca_type = DEFAULT_TOSCA_PREFIX + ".#{params[:cattype].downcase}.#{params[:mkp_name].downcase}" if params[:cattype] != nil  && params[:mkp_name] != nil
end

#to_hashObject



46
47
48
49
50
51
52
# File 'lib/megam/mixins/common_deployable.rb', line 46

def to_hash
  h = {
    status: status,
    tosca_type: tosca_type,
    inputs: inputs.to_hash
  }
end