diff --git a/meta/io.murano/Classes/resources/Instance.yaml b/meta/io.murano/Classes/resources/Instance.yaml index 9f8c6faa..c9fd228e 100644 --- a/meta/io.murano/Classes/resources/Instance.yaml +++ b/meta/io.murano/Classes/resources/Instance.yaml @@ -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() diff --git a/muranoapi/engine/system/yaql_functions.py b/muranoapi/engine/system/yaql_functions.py index 4e73bda9..0e02c1be 100644 --- a/muranoapi/engine/system/yaql_functions.py +++ b/muranoapi/engine/system/yaql_functions.py @@ -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')