Class: Megam::Mixins::CommonDeployable

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

Constant Summary collapse

DEFAULT_VERTICE_PREFIX =
'vertice'.freeze
DEFAULT_BITNAMI_PREFIX =
'bitnami'.freeze
DEFAULT_DOCKER_PREFIX =
'docker'.freeze
ATTRIBUTES =
[
    :tosca_type,
    :status,
    :state,
: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.



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

def initialize(params)
    @tosca_type = ''
    @status = 'initialized'
    @state = 'initialized'
    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

#stateObject (readonly)

Returns the value of attribute state.



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

def state
  @state
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



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

def attributes
    ATTRIBUTES
end

#bld_toscatype(params) ⇒ Object



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

def bld_toscatype(params)
    case params[:scm_name]
  when DEFAULT_BITNAMI_PREFIX
    @tosca_type = DEFAULT_BITNAMI_PREFIX + ".#{params[:cattype].downcase}.#{params[:mkp_name].downcase}" if params[:cattype] != nil  && params[:mkp_name] != nil
  when DEFAULT_DOCKER_PREFIX
    @tosca_type = DEFAULT_DOCKER_PREFIX + ".#{params[:cattype].downcase}.#{params[:mkp_name].downcase}" if params[:cattype] != nil  && params[:mkp_name] != nil
  else
    @tosca_type = DEFAULT_VERTICE_PREFIX + ".#{params[:cattype].downcase}.#{params[:mkp_name].downcase}" if params[:cattype] != nil  && params[:mkp_name] != nil
  end

end

#to_hashObject



33
34
35
36
37
38
39
40
# File 'lib/megam/mixins/common_deployable.rb', line 33

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