Renamed the PublicIp and set it to addresses in instance snippet

As the heat format of the Instance has been changed from AWS to HOT,
the PublicIp attribute is not longer available. A "address" should
be used instead.

Also, the resource name has to be renamed from PublicIp to the
assigned-ip, as it is not necessary public

Change-Id: I9a4e99680939b6e31d47a1f181b92d1878f65a5e
Closes-Bug: #1319135
This commit is contained in:
Alexander Tivelkov 2014-05-13 11:13:21 -07:00 committed by Serg Melikyan
parent 36ace6b00b
commit 79e07eeac4
2 changed files with 30 additions and 5 deletions

View File

@ -81,14 +81,14 @@ Workflow:
outputs:
format('{0}-PublicIp', $.name):
description: format('Public IP assigned to {0} instance', $.name)
format('{0}-assigned-ip', $.name):
description: format('IP address assigned to {0} instance', $.name)
value:
get_attr: [$.name, PublicIp]
get_attr: [$.name, addresses]
- $.environment.stack.updateTemplate($template)
- $.environment.stack.push()
- $outputs: $.environment.stack.output()
- $.ipAddresses: $outputs.get(format('{0}-PublicIp', $this.name))
- $.ipAddresses: $outputs.get(format('{0}-assigned-ip', $this.name)).values().flatten().addr.list()
- $.floatingIpAddress: $outputs.get(format('{0}-FloatingIPaddress', $this.name))
- $.environment.instanceNotifier.trackApplication($this)
@ -114,7 +114,7 @@ Workflow:
- $template: $.environment.stack.current()
- $patchBlock:
op: remove
path: format('/Resources/{0}', $.name)
path: format('/resources/{0}', $.name)
- $template: patch($template, $patchBlock)
- $.environment.stack.setTemplate($template)
- $.environment.stack.push()

View File

@ -14,6 +14,7 @@
# limitations under the License.
import base64
import collections
import re
import types
@ -203,6 +204,26 @@ def _patch(obj, patch):
return obj
@yaql.context.EvalArg('self', dict)
def _values(self):
return self.values()
@yaql.context.EvalArg('self', dict)
def _keys(self):
return self.keys()
@yaql.context.EvalArg('self', collections.Iterable)
def _flatten(self):
for i in self:
if isinstance(i, collections.Iterable):
for ii in i:
yield ii
else:
yield i
def register(context):
context.register_function(
lambda json, mappings: _transform_json(json(), mappings()), 'bind')
@ -232,3 +253,7 @@ def register(context):
# Temporary workaround as YAQL does not provide "where" function for
# dictionaries, and there is no easy way to implement it there.
context.register_function(yaql_builtin.dict_attribution, 'get')
# Temporary workaround, these functions should be moved to YAQL
context.register_function(_keys, 'keys')
context.register_function(_values, 'values')
context.register_function(_flatten, 'flatten')