Module: SparkleFormation::SparkleAttribute::Heat

Included in:
Rackspace, SparkleFormation::SparkleStruct::Heat
Defined in:
lib/sparkle_formation/sparkle_attribute/heat.rb

Overview

Heat specific helper implementations

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object

Set customized struct behavior



12
13
14
15
16
17
# File 'lib/sparkle_formation/sparkle_attribute/heat.rb', line 12

def self.included(klass)
  if(klass.const_defined?(:CAMEL_KEYS))
    klass.send(:remove_const, :CAMEL_KEYS)
  end
  klass.const_set(:CAMEL_KEYS, false)
end

Instance Method Details

#_depends_on(resource_name) ⇒ Array<String> #_depends_on(resource_names) ⇒ Array<String> #_depends_on(*resource_names) ⇒ Array<String> Also known as: depends_on!

Note:

this will directly modify the struct at its current context to inject depends on structure

Resource dependency generator

Overloads:

  • #_depends_on(resource_name) ⇒ Array<String>

    Parameters:

    • resource_name (String, Symbol)

      logical resource name

  • #_depends_on(resource_names) ⇒ Array<String>

    Parameters:

    • resource_names (Array<String, Symbol>)

      list of logical resource names

  • #_depends_on(*resource_names) ⇒ Array<String>

    Parameters:

    • resource_names (Array<String, Symbol>)

      list of logical resource names

Returns:

  • (Array<String>)


178
179
180
# File 'lib/sparkle_formation/sparkle_attribute/heat.rb', line 178

def _depends_on(*args)
  _set('depends_on', [args].flatten.compact.map{|s| __attribute_key(s) })
end

#_digest(value, algorithm = 'sha512') ⇒ Object Also known as: digest!

digest generator

Parameters:

  • value (String, Hash)

    thing to be hashed

  • algorithm (String) (defaults to: 'sha512')

    algorithm to use (defaults to 'sha512')



97
98
99
100
# File 'lib/sparkle_formation/sparkle_attribute/heat.rb', line 97

def _digest(value, algorithm='sha512')
  __t_stringish(algorithm)
  {'digest' => [algorithm, value]}
end

#_get_attr(logical_id, attribute_name) ⇒ Hash Also known as: _attr, attr!

get_attr generator

Parameters:

  • logical_id (String, Symbol)

    logical resource name

  • attribute_name (String, Symbol)

    name of desired resource attribute

Returns:

  • (Hash)


24
25
26
27
28
29
30
# File 'lib/sparkle_formation/sparkle_attribute/heat.rb', line 24

def _get_attr(*args)
  __t_stringish(args.first)
  args = args.map do |thing|
    __attribute_key(thing)
  end
  {'get_attr' => args}
end

#_get_file(loc) ⇒ Hash Also known as: _file, file!

get_file generator

Parameters:

  • loc (String)

Returns:

  • (Hash)


56
57
58
59
# File 'lib/sparkle_formation/sparkle_attribute/heat.rb', line 56

def _get_file(loc)
  __t_stringish(loc)
  {'get_file' => loc}
end

#_get_param(name) ⇒ Hash #_get_param(name, index1, index2, ...) ⇒ Hash Also known as: _param, param!

Overloads:

  • #_get_param(name) ⇒ Hash

    get_param generator

    Parameters:

    • name (String, Symbol)

      name of parameter

  • #_get_param(name, index1, index2, ...) ⇒ Hash

    get_param generator accessing complex data

    Parameters:

    • name (String, Symbol)

      name of parameter

    • index1 (Object)

      value for key/index

    • index2 (Object)

      value for key/index

Returns:

  • (Hash)


72
73
74
75
76
77
78
# File 'lib/sparkle_formation/sparkle_attribute/heat.rb', line 72

def _get_param(*args)
  __t_stringish(args.first)
  args = args.map do |thing|
    __attribute_key(thing)
  end
  {'get_param' => args.size == 1 ? args.first : args}
end

#_get_resource(r_name) ⇒ Hash Also known as: _resource, resource!

get_resource generator

Parameters:

  • r_name (String, Symbol)

Returns:

  • (Hash)


86
87
88
89
# File 'lib/sparkle_formation/sparkle_attribute/heat.rb', line 86

def _get_resource(r_name)
  __t_stringish(r_name)
  {'get_resource' => __attribute_key(r_name)}
end

#_list_join(*args, opts = {}) ⇒ Hash Also known as: _join, join!

list_join generator

Parameters:

  • args (String, Hash)

    list of items to join

  • opts (Hash) (defaults to: {})

Options Hash (opts):

  • :options (Hash)

    options for join function

Returns:

  • (Hash)


41
42
43
44
45
46
47
48
# File 'lib/sparkle_formation/sparkle_attribute/heat.rb', line 41

def _list_join(*args)
  options = args.detect{|i| i.is_a?(::Hash) && i[:options]} || {:options => {}}
  args.delete(options)
  unless(args.size == 1)
    args = [args]
  end
  {'list_join' => [options[:options][:delimiter] || '', *args]}
end

#_map_merge(hash1, hash2, ...) ⇒ Hash Also known as: map_merge!

map_merge generator

Parameters:

  • hash1 (Hash)

    item to merge

  • hash2 (Hash)

    item to merge

Returns:

  • (Hash)


146
147
148
# File 'lib/sparkle_formation/sparkle_attribute/heat.rb', line 146

def _map_merge(*args)
  {'map_merge' => args}
end

#_project_idHash Also known as: project_id!

Returns:

  • (Hash)


164
165
166
# File 'lib/sparkle_formation/sparkle_attribute/heat.rb', line 164

def _project_id
  _get_param('OS::project_id')
end

#_resource_facade(type) ⇒ Hash Also known as: _facade, facade!, resource_facade!

resource_facade generator

Parameters:

  • type (String, Symbol)

Returns:

  • (Hash)


107
108
109
110
# File 'lib/sparkle_formation/sparkle_attribute/heat.rb', line 107

def _resource_facade(type)
  __t_stringish(type)
  {'resource_facade' => type}
end

#_stack_idHash Also known as: stack_id!

Returns:

  • (Hash)


152
153
154
# File 'lib/sparkle_formation/sparkle_attribute/heat.rb', line 152

def _stack_id
  _get_param('OS::stack_id')
end

#_stack_nameHash Also known as: stack_name!

Returns:

  • (Hash)


158
159
160
# File 'lib/sparkle_formation/sparkle_attribute/heat.rb', line 158

def _stack_name
  _get_param('OS::stack_name')
end

#_stack_output(stack_name, output_name) ⇒ Hash Also known as: stack_output!

Reference output value from nested stack

Parameters:

  • stack_name (String, Symbol)

    logical resource name of stack

  • output_name (String, Symbol)

    stack output name

Returns:

  • (Hash)


188
189
190
191
192
193
# File 'lib/sparkle_formation/sparkle_attribute/heat.rb', line 188

def _stack_output(stack_name, output_name)
  _attr(
    __attribute_key(stack_name),
    __attribute_key(output_name)
  )
end

#_str_replace(template, params) ⇒ Hash Also known as: _replace, replace!

str_replace generator

Parameters:

  • template (String)
  • params (Hash)

Returns:

  • (Hash)


120
121
122
123
124
# File 'lib/sparkle_formation/sparkle_attribute/heat.rb', line 120

def _str_replace(template, params)
  __t_stringish(template)
  __t_hashish(params)
  {'str_replace' => {'template' => template, 'params' => params}}
end

#_str_split(splitter, string, idx = nil) ⇒ Hash Also known as: _split, split!

str_split generator

Parameters:

  • splitter (String)
  • string (Object)
  • idx (Numeric) (defaults to: nil)

Returns:

  • (Hash)


134
135
136
137
# File 'lib/sparkle_formation/sparkle_attribute/heat.rb', line 134

def _str_split(splitter, string, idx=nil)
  __t_stringish(splitter) unless splitter.is_a?(Hash)
  {'str_split' => [splitter, string, idx].compact}
end