Class: SparkleFormation::Translation::Heat
- Inherits:
-
SparkleFormation::Translation
- Object
- SparkleFormation::Translation
- SparkleFormation::Translation::Heat
- Defined in:
- lib/sparkle_formation/translation/heat.rb
Overview
Translation for Heat (HOT)
Direct Known Subclasses
Constant Summary collapse
- MAP =
Heat translation mapping
{ :resources => { 'AWS::EC2::Instance' => { :name => 'OS::Nova::Server', :finalizer => :nova_server_finalizer, :properties => { 'AvailabilityZone' => 'availability_zone', 'BlockDeviceMappings' => :nova_server_block_device_mapping, 'ImageId' => 'image', 'InstanceType' => 'flavor', 'KeyName' => 'key_name', 'NetworkInterfaces' => 'networks', 'SecurityGroups' => 'security_groups', 'SecurityGroupIds' => 'security_groups', 'Tags' => 'metadata', 'UserData' => :nova_server_user_data } }, 'AWS::AutoScaling::AutoScalingGroup' => { :name => 'OS::Heat::AutoScalingGroup', :properties => { 'Cooldown' => 'cooldown', 'DesiredCapacity' => 'desired_capacity', 'MaxSize' => 'max_size', 'MinSize' => 'min_size', 'LaunchConfigurationName' => :autoscaling_group_launchconfig } }, 'AWS::AutoScaling::LaunchConfiguration' => :delete } }
Instance Attribute Summary
Attributes inherited from SparkleFormation::Translation
#logger, #original, #parameters, #template, #translated
Instance Method Summary collapse
-
#autoscaling_group_launchconfig(value, args = {}) ⇒ Array<String, Object>
Custom mapping for ASG launch configuration.
-
#default_key_format(key) ⇒ String
Default keys to snake cased format (underscore).
-
#nova_server_block_device_mapping(value, args = {}) ⇒ Array<String, Object>
Custom mapping for block device.
-
#nova_server_finalizer(resource_name, new_resource, old_resource) ⇒ Object
Finalizer for the nova server resource.
-
#nova_server_user_data(value, args = {}) ⇒ Array<String, Object>
Custom mapping for server user data.
-
#resource_finalizer(resource_name, new_resource, old_resource) ⇒ TrueClass
Finalizer applied to all new resources.
Methods inherited from SparkleFormation::Translation
#apply_function, #dereference, #dereference_processor, #format_properties, #initialize, #map, #resource_translation, #translate!, #translate_default, #translate_resources
Methods included from SparkleAttribute
#_cf_attr, #_cf_base64, #_cf_get_azs, #_cf_join, #_cf_map, #_cf_ref, #_cf_select, #_platform=, #debian?, #dynamic!, #registry!, #rhel?
Methods included from Utils::AnimalStrings
Constructor Details
This class inherits a constructor from SparkleFormation::Translation
Instance Method Details
#autoscaling_group_launchconfig(value, args = {}) ⇒ Array<String, Object>
implement
Custom mapping for ASG launch configuration
84 85 86 |
# File 'lib/sparkle_formation/translation/heat.rb', line 84 def autoscaling_group_launchconfig(value, args={}) ['resource', value] end |
#default_key_format(key) ⇒ String
Default keys to snake cased format (underscore)
92 93 94 |
# File 'lib/sparkle_formation/translation/heat.rb', line 92 def default_key_format(key) snake(key) end |
#nova_server_block_device_mapping(value, args = {}) ⇒ Array<String, Object>
implement
Custom mapping for block device
15 16 17 |
# File 'lib/sparkle_formation/translation/heat.rb', line 15 def nova_server_block_device_mapping(value, args={}) ['block_device_mapping', value] end |
#nova_server_finalizer(resource_name, new_resource, old_resource) ⇒ Object
Finalizer for the nova server resource. Fixes bug with remotes in metadata
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/sparkle_formation/translation/heat.rb', line 40 def nova_server_finalizer(resource_name, new_resource, old_resource) if(old_resource['Metadata']) new_resource['Metadata'] = old_resource['Metadata'] proceed = new_resource['Metadata'] && new_resource['Metadata']['AWS::CloudFormation::Init'] && config = new_resource['Metadata']['AWS::CloudFormation::Init']['config'] if(proceed) # NOTE: This is a stupid hack since HOT gives the URL to # wget directly and if special characters exist, it fails if(files = config['files']) files.each do |key, args| if(args['source']) args['source'].replace("\"#{args['source']}\"") end end end end end end |
#nova_server_user_data(value, args = {}) ⇒ Array<String, Object>
Custom mapping for server user data
27 28 29 30 31 |
# File 'lib/sparkle_formation/translation/heat.rb', line 27 def nova_server_user_data(value, args={}) args[:new_properties][:user_data_format] = 'RAW' args[:new_properties][:config_drive] = 'true' [:user_data, Hash[value.values.first]] end |
#resource_finalizer(resource_name, new_resource, old_resource) ⇒ TrueClass
Finalizer applied to all new resources
66 67 68 69 70 71 72 73 |
# File 'lib/sparkle_formation/translation/heat.rb', line 66 def resource_finalizer(resource_name, new_resource, old_resource) %w(DependsOn Metadata).each do |key| if(old_resource[key] && !new_resource[key]) new_resource[key] = old_resource[key] end end true end |