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.



22
23
24
25
26
27
28
29
# File 'lib/megam/mixins/common_deployable.rb', line 22

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.



7
8
9
# File 'lib/megam/mixins/common_deployable.rb', line 7

def inputs
  @inputs
end

#statusObject (readonly)

Returns the value of attribute status.



7
8
9
# File 'lib/megam/mixins/common_deployable.rb', line 7

def status
  @status
end

#tosca_typeObject (readonly)

Returns the value of attribute tosca_type.



7
8
9
# File 'lib/megam/mixins/common_deployable.rb', line 7

def tosca_type
  @tosca_type
end

Instance Method Details

#attributesObject



18
19
20
# File 'lib/megam/mixins/common_deployable.rb', line 18

def attributes
  ATTRIBUTES
end

#bld_toscatype(params) ⇒ Object



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

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



31
32
33
34
35
36
37
# File 'lib/megam/mixins/common_deployable.rb', line 31

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