Describe the request
Calm UI allows using a macro today in the cluster selection field, but Calm DSL doesn't support it. Add the capability to use a macro in this field so that Calm UI matches Calm DSL. This field gets used quite often in services and the functionality in Calm DSL needs to match the capabilities of the Calm UI.
Current behaviour
When decompiling the blueprint or building from scratch there is a validation error.
PS C:\Temp\Repo\Test> calm create bp -f blah/blueprint.py --name blah7 --force
Traceback (most recent call last):
File "C:\Program Files\Python311\Lib\site-packages\calm\dsl\tools\utils.py", line 33, in get_module_from_file
spec.loader.exec_module(user_module)
File "<frozen importlib._bootstrap_external>", line 940, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "C:\Temp\Repo\Test\blah/blueprint.py", line 42, in <module>
class vmcalm_array_indexcalm_time(AhvVm):
File "C:\Temp\Repo\Test\blah/blueprint.py", line 46, in vmcalm_array_indexcalm_time
cluster = "@@{cluster}@@"
^^^^^^^
File "C:\Program Files\Python311\Lib\site-packages\calm\dsl\builtins\models\entity.py", line 89, in __setitem__
value = self._validate(name, value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\site-packages\calm\dsl\builtins\models\entity.py", line 83, in _validate
return self._validate_attr(vdict, name, value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\site-packages\calm\dsl\builtins\models\entity.py", line 74, in _validate_attr
ValidatorType.validate(value, is_array)
File "C:\Program Files\Python311\Lib\site-packages\calm\dsl\builtins\models\validator.py", line 68, in validate
cls._validate_item(value)
File "C:\Program Files\Python311\Lib\site-packages\calm\dsl\builtins\models\validator.py", line 55, in _validate_item
or (hasattr(kind, "validate_dict") and (not kind.validate_dict(value)))
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\site-packages\calm\dsl\builtins\models\entity.py", line 148, in validate_dict
validator.validate(entity_dict)
File "C:\Program Files\Python311\Lib\site-packages\jsonschema\validators.py", line 353, in validate
raise error
calm.dsl.tools.validator.validation_error: <exception str() failed>
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "C:\Program Files\Python311\Scripts\calm.exe\__main__.py", line 7, in <module>
File "C:\Program Files\Python311\Lib\site-packages\click\core.py", line 1128, in __call__
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\site-packages\click\core.py", line 1053, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\site-packages\calm\dsl\cli\utils.py", line 127, in invoke
return super().invoke(ctx)
^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\site-packages\click\core.py", line 1659, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\site-packages\calm\dsl\cli\utils.py", line 127, in invoke
return super().invoke(ctx)
^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\site-packages\click\core.py", line 1659, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\site-packages\click\core.py", line 1395, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\site-packages\click\core.py", line 754, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\site-packages\calm\dsl\cli\bp_commands.py", line 203, in create_blueprint_command
res, err = create_blueprint_from_dsl(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\site-packages\calm\dsl\cli\bps.py", line 453, in create_blueprint_from_dsl
bp_payload = compile_blueprint(bp_file)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\site-packages\calm\dsl\cli\bps.py", line 289, in compile_blueprint
metadata_payload = get_metadata_payload(bp_file)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\site-packages\calm\dsl\builtins\models\metadata_payload.py", line 37, in get_metadata_payload
user_metadata_module = get_metadata_module_from_file(dsl_file)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\site-packages\calm\dsl\builtins\models\metadata_payload.py", line 15, in get_metadata_module_from_file
return get_module_from_file("calm.dsl.user_metadata", dsl_file)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\site-packages\calm\dsl\tools\utils.py", line 35, in get_module_from_file
LOG.exception(exp)
File "C:\Program Files\Python311\Lib\site-packages\calm\dsl\log\logger.py", line 170, in exception
self.__add_caller_info(msg), exc_info=exc_info, *args, **kwargs
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\site-packages\calm\dsl\log\logger.py", line 79, in __add_caller_info
return ":{}] {}".format(ln, msg)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\site-packages\calm\dsl\tools\validator.py", line 28, in __unicode__
json.loads(json.dumps(self.schema, sort_keys=True, indent=4))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\json\__init__.py", line 238, in dumps
**kw).encode(obj)
^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\json\encoder.py", line 202, in encode
chunks = list(chunks)
^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\json\encoder.py", line 432, in _iterencode
yield from _iterencode_dict(o, _current_indent_level)
File "C:\Program Files\Python311\Lib\json\encoder.py", line 406, in _iterencode_dict
yield from chunks
File "C:\Program Files\Python311\Lib\json\encoder.py", line 439, in _iterencode
o = _default(o)
^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\json\encoder.py", line 180, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type mappingproxy is not JSON serializable
Expected behaviour
A macro can be used for the cluster
Describe the request Calm UI allows using a macro today in the cluster selection field, but Calm DSL doesn't support it. Add the capability to use a macro in this field so that Calm UI matches Calm DSL. This field gets used quite often in services and the functionality in Calm DSL needs to match the capabilities of the Calm UI.
Current behaviour When decompiling the blueprint or building from scratch there is a validation error.
Expected behaviour A macro can be used for the cluster