Module: StackMate::Intrinsic
- Included in:
- CloudStackAffinityGroup, CloudStackAutoScalePolicy, CloudStackAutoScaleVmGroup, CloudStackAutoScaleVmProfile, CloudStackCondition, CloudStackEgressFirewallRule, CloudStackFirewallRule, CloudStackGlobalLoadBalancerRule, CloudStackInstanceGroup, CloudStackIpAddress, CloudStackIpForwardingRule, CloudStackIpToNic, CloudStackIso, CloudStackLBHealthCheckPolicy, CloudStackLBStickinessPolicy, CloudStackLoadBalancer, CloudStackLoadBalancerRule, CloudStackNetwork, CloudStackNetworkACL, CloudStackNetworkACLList, CloudStackNicToVirtualMachine, CloudStackOutput, CloudStackPortForwardingRule, CloudStackProject, CloudStackRemoteAccessVpn, CloudStackSSHKeyPair, CloudStackSecurityGroup, CloudStackSecurityGroupEgress, CloudStackSecurityGroupIngress, CloudStackSnapshot, CloudStackSnapshotPolicy, CloudStackStaticNat, CloudStackStaticRoute, CloudStackTags, CloudStackTemplate, CloudStackToGlobalLoadBalancerRule, CloudStackToLoadBalancerRule, CloudStackVMSnapshot, CloudStackVPC, CloudStackVirtualMachine, CloudStackVirtualMachineOps, CloudStackVolume, CloudStackVolumeOps, CloudStackVpnConnection, CloudStackVpnCustomerGateway, CloudStackVpnGateway, CloudStackVpnUser, Output, StackNest
- Defined in:
- lib/stackmate/intrinsic_functions.rb
Instance Method Summary collapse
- #fn_base64(value, workitem) ⇒ Object
- #fn_getatt(array_value, workitem) ⇒ Object
- #fn_join(value, workitem) ⇒ Object
- #fn_lookup(value, workitem) ⇒ Object
- #fn_map(value, workitem) ⇒ Object
- #fn_ref(value, workitem) ⇒ Object
- #fn_select(array_value) ⇒ Object
- #intrinsic(hash, workitem) ⇒ Object
Instance Method Details
#fn_base64(value, workitem) ⇒ Object
105 106 107 108 109 110 111 112 |
# File 'lib/stackmate/intrinsic_functions.rb', line 105 def fn_base64(value, workitem) case value when String Base64.strict_encode64(value) when Hash Base64.strict_encode64(intrinsic(value, workitem)) end end |
#fn_getatt(array_value, workitem) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/stackmate/intrinsic_functions.rb', line 53 def fn_getatt(array_value, workitem) resource = array_value[0] attribute = array_value[1] #logger.debug "Intrinsic: fn_getatt resource= #{resource} attrib = #{attribute} wi[Resource] = #{workitem[resource]}" workitem[resource][attribute] # attributes = array_value[1..-2] # current_resource = workitem[resource] # attributes.each do |a| # current_resource = current_resource[a] # end # current_resource[array_value[-1]] end |
#fn_join(value, workitem) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/stackmate/intrinsic_functions.rb', line 35 def fn_join(value, workitem) delim = value[0] v = value[1] #logger.debug "Intrinsic: fn_join value = #{v}" result = '' first_ = true v.each do |token| case token when String result = result + (first_ ? "" : delim) + token when Hash result = result + (first_ ? "" : delim) + intrinsic(token, workitem) end first_ = false end result end |
#fn_lookup(value, workitem) ⇒ Object
82 83 84 85 86 87 88 89 |
# File 'lib/stackmate/intrinsic_functions.rb', line 82 def fn_lookup(value, workitem) case value when String workitem['ResolvedNames'][value] when Hash workitem['ResolvedNames'][intrinsic(value, workitem)] end end |
#fn_map(value, workitem) ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/stackmate/intrinsic_functions.rb', line 91 def fn_map(value, workitem) #logger.debug "Intrinsic: fn_ref value = #{value}" resolved_keys = [] value.each do |k| case k when String resolved_keys.push(k) when Hash resolved_keys.push(intrinsic(k,workitem)) end end workitem['Mappings'][resolved_keys[0]][resolved_keys[1]][resolved_keys[2]] end |
#fn_ref(value, workitem) ⇒ Object
73 74 75 76 77 78 79 80 |
# File 'lib/stackmate/intrinsic_functions.rb', line 73 def fn_ref(value, workitem) #logger.debug "Intrinsic: fn_ref value = #{value}" if workitem[value] workitem[value]['physical_id'] #TODO only works with Resources not Params else workitem['ResolvedNames'][value] end end |
#fn_select(array_value) ⇒ Object
66 67 68 69 70 71 |
# File 'lib/stackmate/intrinsic_functions.rb', line 66 def fn_select(array_value) index = array_value[0].to_i #TODO unsafe values = array_value[1] #logger.debug "Intrinsic: fn_select index= #{index} values = #{values.inspect}" values[index] end |
#intrinsic(hash, workitem) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/stackmate/intrinsic_functions.rb', line 13 def intrinsic (hash, workitem) key = hash.keys[0] value = hash[key] #logger.debug "Intrinsic: key = #{key}, value = #{value}" case key when 'Fn::Join' fn_join(value, workitem) when 'Fn::GetAtt' fn_getatt(value, workitem) when 'Fn::Select' fn_select(value) when 'Ref' fn_ref(value, workitem) when 'Fn::Lookup' fn_lookup(value, workitem) when 'Fn::FindInMap' fn_map(value, workitem) when 'Fn::Base64' fn_base64(value, workitem) end end |