class Enc::Builder
Public Class Methods
new(asset)
click to toggle source
# File lib/enc/builder.rb, line 3 def initialize(asset) @asset = asset end
Public Instance Methods
get_asset_attributes()
click to toggle source
# File lib/enc/builder.rb, line 33 def get_asset_attributes @asset.get_flattened_attributes end
get_asset_extras()
click to toggle source
# File lib/enc/builder.rb, line 27 def get_asset_extras {'TAG' => @asset.tag, 'STATE' => @asset.state.name, 'STATUS' => @asset.status} end
to_yaml()
click to toggle source
# 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