Class: Enc::Builder
- Inherits:
-
Object
- Object
- Enc::Builder
- Defined in:
- lib/enc/builder.rb
Instance Method Summary collapse
- #get_asset_attributes ⇒ Object
- #get_asset_extras ⇒ Object
-
#initialize(asset) ⇒ Builder
constructor
A new instance of Builder.
- #to_yaml ⇒ Object
Constructor Details
#initialize(asset) ⇒ Builder
Returns a new instance of Builder.
3 4 5 |
# File 'lib/enc/builder.rb', line 3 def initialize(asset) @asset = asset end |
Instance Method Details
#get_asset_attributes ⇒ Object
33 34 35 |
# File 'lib/enc/builder.rb', line 33 def get_asset_attributes @asset.get_flattened_attributes end |
#get_asset_extras ⇒ Object
27 28 29 30 31 |
# File 'lib/enc/builder.rb', line 27 def get_asset_extras {'TAG' => @asset.tag, 'STATE' => @asset.state.name, 'STATUS' => @asset.status} end |
#to_yaml ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/enc/builder.rb', line 7 def to_yaml return String.new.to_yaml unless @asset.uses_enc? output = {'parameters' => {'deployment_environment' => @asset.get_deployment_environment, 'datacenter' => @asset.get_datacenter, 'roles' => @asset.get_roles_as_string}} # Do not require the puppet environment until we upgrade to puppet 3.x. # output[:environment] => @asset.get_puppet_environment # We do this to satisfy the current requirement to have a roleN for each role, where N is the sorted index of the # role list. @asset.get_roles_by_index.each do |index, role| output['parameters']['role' + (index + 1).to_s] = role end # It's not strictly necessary, but nice to have the $collins parameter at the end of the output. output['parameters']['collins'] = get_asset_extras.merge!(get_asset_attributes) output.to_yaml end |