diff --git a/CalmVersion b/CalmVersion index eaf967fb8..19811903a 100644 --- a/CalmVersion +++ b/CalmVersion @@ -1 +1 @@ -3.7.2.2 +3.8.0 diff --git a/README.md b/README.md index bb34e314c..f9271810b 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,18 @@ ![Build](https://github.com/nutanix/calm-dsl/workflows/Setup%20&%20build%20calm-dsl/badge.svg) -# calm-dsl +`Latest release version: 3.8.0, Latest-release-tag: v3.8.0` -## About Calm DSL +`Latest Release Notes:` [read here](release-notes/3.8.0) -Calm DSL describes a simpler Python3 based DSL for writing Calm blueprints. As Calm uses Services, Packages, Substrates, Deployments and Application Profiles as building blocks for a Blueprint, these entities can be defined as python classes. Their attributes can be specified as class attributes and actions on those entities (procedural runbooks) can be defined neatly as class methods. Calm blueprint DSL can also accept appropriate native data formats such as YAML and JSON, allowing the reuse and leveraging that work into the larger application lifecycle context of a Calm blueprint. -### Why Python3 as DSL ? +# Nutanix Cloud Manager (NCM) Self Service (formerly Calm) DSL + +## About NCM Self Service DSL + +NCM Self Service DSL describes a simpler Python3 based DSL for writing NCM Self Service blueprints. As NCM Self Service uses Services, Packages, Substrates, Deployments and Application Profiles as building blocks for a Blueprint, these entities can be defined as python classes. Their attributes can be specified as class attributes and actions on those entities (procedural runbooks) can be defined neatly as class methods. NCM Self Service blueprint DSL can also accept appropriate native data formats such as YAML and JSON, allowing the reuse and leveraging that work into the larger application lifecycle context of a NCM Self Service blueprint. + +### Why Python3 as NCM Self Service DSL? Language design is black art, and building upon a well-established language is design-wise a big win. The language has also solved many issues like scoping, modules, if-else, inheritance, etc. Well established languages have great tooling support: IDEs, syntax checkers, third-party modules, coding practices, better readability, editing, syntax highlighting, code completion, versioning, collaboration, etc. They see much more community improvements as well. Python specifically comes with a very good REPL (read–eval–print-loop). Having an interactive prompt to play around and slowly build objects is an order-of-magnitude improvement in developer productivity. Python is very easy language to learn and use; and most of the ITOps/DevOps community already use Python for scripting. @@ -16,10 +21,10 @@ Language design is black art, and building upon a well-established language is d ### Initialization - Setup: `calm init dsl`. Please fill in the right Prism Central (PC) settings. - - Server status: `calm get server status`. Check if Calm is enabled on PC & Calm version is >=2.9.7. + - Server status: `calm get server status`. Check if NCM Self Service is enabled on PC & it's version is >=2.9.7. - Config: `calm show config`. Please see `calm set config --help` to update configuration. -### Calm DSL Context +### NCM Self Service DSL Context Context info includes server, project and log configuration for dsl operations. - Flow: Context info is taken from config file passed inline with cli command or environment data or default config file stored mentioned in `~/.calm/init.ini`. - Environment variables for server configuration: `CALM_DSL_PC_IP`, `CALM_DSL_PC_PORT`, `CALM_DSL_PC_USERNAME`, `CALM_DSL_PC_PASSWORD`. @@ -32,7 +37,7 @@ Context info includes server, project and log configuration for dsl operations. ### Blueprint - First blueprint: `calm init bp`. This will create a folder `HelloBlueprint` with all the necessary files. `HelloBlueprint/blueprint.py` is the main blueprint DSL file. Please read the comments in the beginning of the file for more details about the blueprint. - Compile blueprint: `calm compile bp --file HelloBlueprint/blueprint.py`. This command will print the compiled blueprint JSON. - - Create blueprint on Calm Server: `calm create bp --file HelloBlueprint/blueprint.py --name `. Please use a unique name for ``. + - Create blueprint on NCM Self Service Server: `calm create bp --file HelloBlueprint/blueprint.py --name `. Please use a unique name for ``. - List blueprints: `calm get bps`. You can also pass in filters like `calm get bps --name ` and so on. Please look at `calm get bps --help`. - Describe blueprint: `calm describe bp `. It will print a summary of the blueprint. - Launch blueprint to create Application: `calm launch bp --app_name -i` @@ -113,10 +118,10 @@ Decompilation is process to consume json data for any entity and convert it back ### Initialization - Setup: `calm init dsl`. Please fill in the right Prism Central (PC) settings. - - Server status: `calm get server status`. Check if Calm is enabled on PC & Calm version is >=2.9.7. + - Server status: `calm get server status`. Check if NCM Self Service is enabled on PC & it's version is >=2.9.7. - Config: `calm show config`. Please see `calm set config --help` to update configuration. -### Calm DSL Context +### NCM Self Service DSL Context Context information includes server, project and log configuration for dsl operations. - Flow: Context info is taken from config file passed inline with cli command or environment data or default config file stored mentioned in `~/.calm/init.ini`. - Environment variables for server configuration: `CALM_DSL_PC_IP`, `CALM_DSL_PC_PORT`, `CALM_DSL_PC_USERNAME`, `CALM_DSL_PC_PASSWORD`. @@ -127,7 +132,7 @@ Context information includes server, project and log configuration for dsl opera - Show config in context: `calm show config`. ### Roles -Use `calm get roles` to list all roles in PC. The below roles are relevant for Calm: +Use `calm get roles` to list all roles in PC. The below roles are relevant for NCM Self Service: - `Prism Admin`: Day-to-day admin of a Nutanix deployment. Manages the infrastructure and platform, but cannot entitle other users to be admins. - `Project Admin`: Team lead to whom cloud administration gets delegated in the context of a project. Manages end users within the project and has full access to their entities. - `Developer`: Application developer within a team. Authors blueprints, tests deployments, and publishes applications for other project members. @@ -149,7 +154,7 @@ Use `calm get roles` to list all roles in PC. The below roles are relevant for C ### Projects - Compile project: `calm compile project --file `. This command will print the compiled project JSON. Look at sample file [here](examples/Project/demo_project.py) and [here](examples/Project/project_with_env.py). -- Create project on Calm Server: `calm create project --file --name --description `.\ +- Create project on NCM Self Service Server: `calm create project --file --name --description `.\ **Options:**\           `--no-cache-update`: flag to skip cache updations post operation.\           `--force`: flag to delete existing project with the same name before create, if entities are not associated with it. @@ -237,23 +242,23 @@ Use: ## Documentation - - [Calm Terminology](docs/01-Calm-Terminology/) + - [NCM Self Service Terminology](docs/01-Calm-Terminology/) - [DSL Blueprint Architecture](docs/02-DSL-Blueprint-Architecture/) - [DSL Lab](docs/03-Quickstart/) ## Video Links - [Workstation Setup](https://youtu.be/uIZmHQhioZg) - [Blueprint & App management](https://youtu.be/jb-ZllhaROs) - - [Calm DSL Blueprint Architecture](https://youtu.be/Y-6eq91rtSw) + - [NCM Self Service DSL Blueprint Architecture](https://youtu.be/Y-6eq91rtSw) ## [Blogs](https://www.nutanix.dev/calm-dsl/) - - [Introducing the Nutanix Calm DSL](https://www.nutanix.dev/2020/03/17/introducing-the-nutanix-calm-dsl/) + - [Introducing the NCM Self Service DSL](https://www.nutanix.dev/2020/03/17/introducing-the-nutanix-calm-dsl/) - [Creating Custom Blueprint](https://www.nutanix.dev/2020/03/30/nutanix-calm-dsl-creating-custom-blueprint/) - [Generating VM Specs](https://www.nutanix.dev/2020/04/06/nutanix-calm-dsl-generating-vm-specs/) - [Run Custom Actions](https://www.nutanix.dev/2020/04/17/nutanix-calm-dsl-run-custom-actions/) - [Remote Container Development (Part 1)](https://www.nutanix.dev/2020/04/24/nutanix-calm-dsl-remote-container-development-part-1/) - - [From UI to Code – Calm DSL and Blueprint Decompile](https://www.nutanix.dev/2020/07/20/from-ui-to-code-calm-dsl-and-blueprint-decompile/) + - [From UI to Code – NCM Self Service DSL and Blueprint Decompile](https://www.nutanix.dev/2020/07/20/from-ui-to-code-calm-dsl-and-blueprint-decompile/) ## Demos - - [Zero-touch CI/CD - VDI Template Creation with Nutanix Calm DSL](https://youtu.be/5k_K7idGxsI) + - [Zero-touch CI/CD - VDI Template Creation with NCM Self Service DSL](https://youtu.be/5k_K7idGxsI) - [Integrating with Azure DevOps CI/CD pipeline](https://youtu.be/496bvlIi4pk) diff --git a/calm/dsl/builtins/models/task.py b/calm/dsl/builtins/models/task.py index 5595b14d9..2adfea3bc 100644 --- a/calm/dsl/builtins/models/task.py +++ b/calm/dsl/builtins/models/task.py @@ -611,6 +611,29 @@ def exec_task_powershell( ) +def exec_task_python( + script=None, + filename=None, + name=None, + target=None, + target_endpoint=None, + cred=None, + depth=2, + **kwargs, +): + return _exec_create( + "python_remote", + script=script, + filename=filename, + name=name, + target=target, + target_endpoint=target_endpoint, + cred=cred, + depth=depth, + **kwargs, + ) + + def exec_task_ssh_runbook( script=None, filename=None, name=None, target=None, cred=None, depth=2, **kwargs ): @@ -667,6 +690,34 @@ def exec_task_powershell_runbook( ) +def exec_task_python_runbook( + script=None, filename=None, name=None, target=None, cred=None, depth=2, **kwargs +): + """ + This function is used to create exec task with python_remote target + Args: + script(str): Script which needs to be run + filename(str): file which has script + name(str): Task name + target(Entity/Ref): Entity/Ref that is the target for this task + cred (Entity/Ref): Entity/Ref that is the cred for this task + depth (int): Number of times to look back in call stack, will be used to locate filename specified + :keyword inherit_target (bool): True if target needs to be inherited. + Returns: + obj: Exec task object + """ + return _exec_create( + "python_remote", + script=script, + filename=filename, + name=name, + target=target, + cred=cred, + depth=depth, + **kwargs, + ) + + def decision_task_ssh( script=None, filename=None, name=None, target=None, cred=None, depth=2, **kwargs ): @@ -723,6 +774,34 @@ def decision_task_powershell( ) +def decision_task_python( + script=None, filename=None, name=None, target=None, cred=None, depth=2, **kwargs +): + """ + This function is used to create decision task with python_remote target + Args: + script(str): Script which needs to be run + filename(str): file which has script + name(str): Task name + target(Entity/Ref): Entity/Ref that is the target for this task + cred (Entity/Ref): Entity/Ref that is the cred for this task + depth (int): Number of times to look back in call stack, will be used to locate filename specified + :keyword inherit_target (bool): True if target needs to be inherited. + Returns: + obj: Decision task object + """ + return _decision_create( + "python_remote", + script=script, + filename=filename, + name=name, + target=target, + cred=cred, + depth=depth, + **kwargs, + ) + + def decision_task_escript( script=None, filename=None, @@ -950,6 +1029,43 @@ def set_variable_task_powershell( return _set_variable_create(task, variables) +def set_variable_task_python( + script=None, + filename=None, + name=None, + target=None, + target_endpoint=None, + variables=None, + depth=3, + cred=None, + **kwargs, +): + """ + This function is used to create set variable task with python_remote target + Args: + script(str): Script which needs to be run + filename(str): file which has script + name(str): Task name + target(Entity/Ref): Entity/Ref that is the target for this task + cred (Entity/Ref): Entity/Ref that is the cred for this task + depth (int): Number of times to look back in call stack, will be used to locate filename specified + :keyword inherit_target (bool): True if target needs to be inherited. + Returns: + obj: Set variable task object + """ + task = exec_task_python( + script=script, + filename=filename, + name=name, + target=target, + target_endpoint=target_endpoint, + depth=depth, + cred=cred, + **kwargs, + ) + return _set_variable_create(task, variables) + + class EscriptTaskType: class ExecTask: def __new__( @@ -962,7 +1078,7 @@ def __new__( tunnel=None, **kwargs, ): - return exec_task_escript( + return exec_task_escript_py3( script=script, filename=filename, name=name, @@ -986,7 +1102,7 @@ def __new__( tunnel=None, **kwargs, ): - return decision_task_escript( + return decision_task_escript_py3( script=script, filename=filename, name=name, @@ -1011,7 +1127,7 @@ def __new__( tunnel=None, **kwargs, ): - return set_variable_task_escript( + return set_variable_task_escript_py3( script=script, filename=filename, name=name, @@ -1822,6 +1938,7 @@ class SetVariable: ssh = set_variable_task_ssh powershell = set_variable_task_powershell escript = EscriptTaskType.SetVariableTask + python = set_variable_task_python class Delay: def __new__(cls, delay_seconds=None, name=None, target=None): @@ -1840,6 +1957,7 @@ def __new__(cls, *args, **kwargs): ssh = exec_task_ssh powershell = exec_task_powershell escript = EscriptTaskType.ExecTask + python = exec_task_python class ConfigExec: def __new__(cls, config, name=None): @@ -1859,6 +1977,7 @@ def __new__(cls, *args, **kwargs): ssh = decision_task_ssh powershell = decision_task_powershell escript = EscriptTaskType.DecisionTask + python = decision_task_python class Exec: def __new__(cls, *args, **kwargs): @@ -1867,6 +1986,7 @@ def __new__(cls, *args, **kwargs): ssh = exec_task_ssh_runbook powershell = exec_task_powershell_runbook escript = EscriptTaskType.ExecTask + python = exec_task_python_runbook class ResourceTypeOperationTask: def __new__( diff --git a/calm/dsl/cli/acps.py b/calm/dsl/cli/acps.py index 98935d5dc..876d04de8 100644 --- a/calm/dsl/cli/acps.py +++ b/calm/dsl/cli/acps.py @@ -4,19 +4,22 @@ import uuid from prettytable import PrettyTable +from distutils.version import LooseVersion as LV from calm.dsl.api import get_api_client, get_resource_api from calm.dsl.config import get_context from calm.dsl.log import get_logging_handle from calm.dsl.store import Cache from calm.dsl.constants import CACHE from calm.dsl.builtins import Ref +from calm.dsl.store import Version -from .constants import ACP +from .constants import ACP, ACP_3_8_0, ACP_BEFORE_3_8_0, ROLE from .task_commands import watch_task from .utils import get_name_query, highlight_text LOG = get_logging_handle(__name__) +CALM_VERSION = Version.get_version("Calm") def get_acps_from_project(client, project_uuid, **kwargs): @@ -281,6 +284,18 @@ def create_acp(role, project, acp_users, acp_groups, name): cluster_uuids = list(set(whiltelisted_clusters) | set(cluster_uuids)) # Default context for acp default_context = ACP.DEFAULT_CONTEXT + project_collab_context = ACP.PROJECT_COLLAB_CONTEXT + + # Setting project uuid in project collab context + project_collab_context["scope_filter_expression_list"][0]["right_hand_side"][ + "uuid_list" + ] = [project_uuid] + + project_collab_context[ + "entity_filter_expression_list" + ] = get_updated_acp_filter_list( + role, project_collab_context["entity_filter_expression_list"], "collab" + ) # Setting project uuid in default context default_context["scope_filter_expression_list"][0]["right_hand_side"][ @@ -289,25 +304,55 @@ def create_acp(role, project, acp_users, acp_groups, name): # Role specific filters entity_filter_expression_list = [] - if role == "Project Admin": + if role == ROLE.PROJECT_ADMIN: entity_filter_expression_list = ( ACP.ENTITY_FILTER_EXPRESSION_LIST.PROJECT_ADMIN ) # TODO remove index bases searching entity_filter_expression_list[4]["right_hand_side"]["uuid_list"] = [ project_uuid ] + entity_filter_expression_list = get_updated_acp_filter_list( + role, entity_filter_expression_list, "global" + ) - elif role == "Developer": + elif role == ROLE.DEVELOPER: entity_filter_expression_list = ACP.ENTITY_FILTER_EXPRESSION_LIST.DEVELOPER + entity_filter_expression_list[4]["right_hand_side"]["uuid_list"] = [ + project_uuid + ] + + entity_filter_expression_list = get_updated_acp_filter_list( + role, entity_filter_expression_list, "global" + ) - elif role == "Consumer": + elif role == ROLE.CONSUMER: entity_filter_expression_list = ACP.ENTITY_FILTER_EXPRESSION_LIST.CONSUMER - elif role == "Operator" and cluster_uuids: + entity_filter_expression_list = get_updated_acp_filter_list( + role, entity_filter_expression_list, "global" + ) + + elif role == ROLE.OPERATOR and cluster_uuids: entity_filter_expression_list = ACP.ENTITY_FILTER_EXPRESSION_LIST.OPERATOR + entity_filter_expression_list = get_updated_acp_filter_list( + role, entity_filter_expression_list, "global" + ) + else: - entity_filter_expression_list = get_filters_custom_role(role_uuid, client) + entity_filter_expression_list = get_filters_custom_role( + role_uuid, client, project_uuid + ) + + collab_entity_filter_expression_list = get_updated_acp_filter_list( + role, ACP.CUSTOM_ROLE_SPECIFIC_COLLAB_FILTER, "collab" + ) + + project_collab_context[ + "entity_filter_expression_list" + ] = get_filters_custom_role( + role_uuid, client, None, collab_entity_filter_expression_list + ) if cluster_uuids: entity_filter_expression_list.append( @@ -338,6 +383,7 @@ def create_acp(role, project, acp_users, acp_groups, name): context_list.append( {"entity_filter_expression_list": entity_filter_expression_list} ) + context_list.append(project_collab_context) acp_payload = { "acp": { @@ -377,7 +423,9 @@ def create_acp(role, project, acp_users, acp_groups, name): watch_task(res["status"]["execution_context"]["task_uuid"]) -def get_filters_custom_role(role_uuid, client): +def get_filters_custom_role( + role_uuid, client, project_id=None, custom_role_filter_list=None +): role, err = client.role.read(id=role_uuid) if err: @@ -394,9 +442,26 @@ def get_filters_custom_role(role_uuid, client): if perm_name: permission_names.add(perm_name.lower()) entity_filter_expression_list = [] - for perm_filter in ACP.CUSTOM_ROLE_PERMISSIONS_FILTERS: - if perm_filter.get("permission") in permission_names: - entity_filter_expression_list.append(perm_filter.get("filter")) + if not custom_role_filter_list: + custom_role_filter_list = get_updated_acp_filter_list( + role, ACP.CUSTOM_ROLE_PERMISSIONS_FILTERS, "global" + ) + if project_id: + custom_role_filter_list.append( + { + "permissions": ["view_project"], + "filter": { + "operator": "IN", + "right_hand_side": {"uuid_list": [project_id]}, + "left_hand_side": {"entity_type": "project"}, + }, + } + ) + for perm_filter in custom_role_filter_list: + for permission in perm_filter.get("permissions"): + if permission in permission_names: + entity_filter_expression_list.append(perm_filter.get("filter")) + break return entity_filter_expression_list @@ -690,3 +755,114 @@ def update_acp( click.echo(json.dumps(stdout_dict, indent=4, separators=(",", ": "))) LOG.info("Polling on acp updation task") watch_task(res["status"]["execution_context"]["task_uuid"]) + + +def get_updated_acp_filter_list(role, filter_list, scope): + """ + Returns an updated access control policy (ACP) filter list based on the Calm version, role, filter list, and scope. + + Args: + calm_version (str): The Calm version. + role (str): The role. + filter_list (list): The original ACP filter list. + scope (str): The scope. + + Returns: + list: The updated ACP filter list. + + Raises: + None + + """ + is_custom_role = True + if role in get_system_roles(): + is_custom_role = False + + if LV(CALM_VERSION) >= LV("3.8.0"): + if scope == "global": + return get_updated_acp_filter_list_for_3_8_0_global_scope( + role, filter_list, is_custom_role + ) + + return get_updated_acp_filter_list_for_3_8_0_collab_scope( + role, filter_list, is_custom_role + ) + + if scope == "global": + return get_updated_acp_filter_list_for_before_3_8_0_global_scope( + role, filter_list, is_custom_role + ) + + return filter_list + + +def get_updated_acp_filter_list_for_3_8_0_global_scope( + role, filter_list, is_custom_role +): + """ + Returns an updated access control policy (ACP) filter list for the global scope. + + Args: + role (str): The role of the user. + filter_list (list): The existing ACP filter list. + is_custom_role (bool): Indicates whether the role is a custom role. + + Returns: + list: The updated ACP filter list. + + """ + if is_custom_role: + filter_list.extend(ACP_3_8_0.CUSTOM_ROLE_PERMISSIONS_FILTERS) + else: + filter_list.extend(ACP_3_8_0.ENTITY_FILTER_EXPRESSION_LIST.COMMON) + if role == ROLE.PROJECT_ADMIN: + filter_list.extend(ACP_3_8_0.ENTITY_FILTER_EXPRESSION_LIST.PROJECT_ADMIN) + + return filter_list + + +def get_updated_acp_filter_list_for_3_8_0_collab_scope( + role, filter_list, is_custom_role +): + """ + Get the updated access control policy (ACP) filter list for collaboration scope. + + Args: + role (str): The role of the user. + filter_list (list): The existing filter list. + is_custom_role (bool): Indicates whether the role is a custom role. + + Returns: + list: The updated filter list. + + """ + if is_custom_role: + filter_list.extend(ACP_3_8_0.CUSTOM_ROLE_SPECIFIC_COLLAB_FILTER) + else: + filter_list.extend(ACP_3_8_0.PROJECT_COLLAB_FILTER) + if role == ROLE.PROJECT_ADMIN: + filter_list.extend(ACP_3_8_0.PROJECT_ADMIN_SPECIFIC_COLLAB_FILTER) + + return filter_list + + +def get_updated_acp_filter_list_for_before_3_8_0_global_scope( + role, filter_list, is_custom_role +): + """ + Get the updated access control policy (ACP) filter list for an existing global scope. + + Args: + role (str): The role of the user. + filter_list (list): The current ACP filter list. + is_custom_role (bool): Indicates whether the role is a custom role. + + Returns: + list: The updated ACP filter list. + + """ + if is_custom_role: + filter_list.extend(ACP_BEFORE_3_8_0.CUSTOM_ROLE_PERMISSIONS_FILTERS) + elif role == ROLE.PROJECT_ADMIN: + filter_list.extend(ACP_BEFORE_3_8_0.ENTITY_FILTER_EXPRESSION_LIST.PROJECT_ADMIN) + return filter_list diff --git a/calm/dsl/cli/bps.py b/calm/dsl/cli/bps.py index 1dd9c866a..718b9a08b 100644 --- a/calm/dsl/cli/bps.py +++ b/calm/dsl/cli/bps.py @@ -648,6 +648,10 @@ def decompile_bp_from_file(filename, with_secrets=False, prefix="", bp_dir=None) # ToDo - Fix this bp_payload = json.loads(open(filename).read()) # bp_payload = read_spec(filename) + + # Filter out system created tasks in patch config + filter_patch_config_tasks(bp_payload["spec"]["resources"]) + _decompile_bp( bp_payload=bp_payload, with_secrets=with_secrets, prefix=prefix, bp_dir=bp_dir ) diff --git a/calm/dsl/cli/constants.py b/calm/dsl/cli/constants.py index c319cc1d4..635ec2d80 100644 --- a/calm/dsl/cli/constants.py +++ b/calm/dsl/cli/constants.py @@ -218,6 +218,7 @@ class SCRIPT_TYPES: SHELL = "sh" ESCRIPT = "static" ESCRIPT_PY3 = "static_py3" + PYTHON = "python_remote" class STATES: ACTIVE = "ACTIVE" @@ -244,6 +245,13 @@ class STATUS: FAILURE_STATES = [STATUS.FAILED, STATUS.ABORTED, STATUS.SUSPENDED] +class ROLE: + PROJECT_ADMIN = "Project Admin" + DEVELOPER = "Developer" + CONSUMER = "Consumer" + OPERATOR = "Operator" + + class ACP: class ENTITY_FILTER_EXPRESSION_LIST: DEVELOPER = [ @@ -267,6 +275,11 @@ class ENTITY_FILTER_EXPRESSION_LIST: "right_hand_side": {"collection": "ALL"}, "left_hand_side": {"entity_type": "category"}, }, + { + "operator": "IN", + "right_hand_side": {"uuid_list": []}, + "left_hand_side": {"entity_type": "project"}, + }, { "operator": "IN", "left_hand_side": {"entity_type": "app_task"}, @@ -391,16 +404,6 @@ class ENTITY_FILTER_EXPRESSION_LIST: "right_hand_side": {"uuid_list": []}, "left_hand_side": {"entity_type": "project"}, }, - { - "operator": "IN", - "right_hand_side": {"collection": "ALL"}, - "left_hand_side": {"entity_type": "user"}, - }, - { - "operator": "IN", - "right_hand_side": {"collection": "ALL"}, - "left_hand_side": {"entity_type": "user_group"}, - }, { "operator": "IN", "right_hand_side": {"collection": "SELF_OWNED"}, @@ -445,7 +448,7 @@ class ENTITY_FILTER_EXPRESSION_LIST: CUSTOM_ROLE_PERMISSIONS_FILTERS = [ { - "permission": "view_image", + "permissions": ["view_image"], "filter": { "operator": "IN", "left_hand_side": {"entity_type": "image"}, @@ -453,7 +456,7 @@ class ENTITY_FILTER_EXPRESSION_LIST: }, }, { - "permission": "view_app_icon", + "permissions": ["view_app_icon"], "filter": { "operator": "IN", "right_hand_side": {"collection": "ALL"}, @@ -461,15 +464,7 @@ class ENTITY_FILTER_EXPRESSION_LIST: }, }, { - "permission": "view_name_category", - "filter": { - "operator": "IN", - "right_hand_side": {"collection": "ALL"}, - "left_hand_side": {"entity_type": "category"}, - }, - }, - { - "permission": "create_or_update_name_category", + "permissions": ["view_name_category", "create_or_update_name_category"], "filter": { "operator": "IN", "right_hand_side": {"collection": "ALL"}, @@ -477,7 +472,7 @@ class ENTITY_FILTER_EXPRESSION_LIST: }, }, { - "permission": "view_environment", + "permissions": ["view_environment"], "filter": { "operator": "IN", "left_hand_side": {"entity_type": "environment"}, @@ -485,7 +480,7 @@ class ENTITY_FILTER_EXPRESSION_LIST: }, }, { - "permission": "view_marketplace_item", + "permissions": ["view_marketplace_item"], "filter": { "operator": "IN", "left_hand_side": {"entity_type": "marketplace_item"}, @@ -493,82 +488,85 @@ class ENTITY_FILTER_EXPRESSION_LIST: }, }, { - "permission": "view_user", + "permissions": ["view_role"], "filter": { "operator": "IN", "right_hand_side": {"collection": "ALL"}, - "left_hand_side": {"entity_type": "user"}, + "left_hand_side": {"entity_type": "role"}, }, }, { - "permission": "view_user_group", + "permissions": ["view_directory_service", "search_directory_service"], "filter": { "operator": "IN", "right_hand_side": {"collection": "ALL"}, - "left_hand_side": {"entity_type": "user_group"}, + "left_hand_side": {"entity_type": "directory_service"}, }, }, { - "permission": "view_role", + "permissions": ["view_identity_provider"], "filter": { "operator": "IN", "right_hand_side": {"collection": "ALL"}, - "left_hand_side": {"entity_type": "role"}, + "left_hand_side": {"entity_type": "identity_provider"}, }, }, { - "permission": "view_directory_service", + "permissions": ["view_app_task"], "filter": { "operator": "IN", - "right_hand_side": {"collection": "ALL"}, - "left_hand_side": {"entity_type": "directory_service"}, + "left_hand_side": {"entity_type": "app_task"}, + "right_hand_side": {"collection": "SELF_OWNED"}, }, }, { - "permission": "search_directory_service", + "permissions": ["view_app_variable"], "filter": { "operator": "IN", - "right_hand_side": {"collection": "ALL"}, - "left_hand_side": {"entity_type": "directory_service"}, + "left_hand_side": {"entity_type": "app_variable"}, + "right_hand_side": {"collection": "SELF_OWNED"}, }, }, { - "permission": "view_identity_provider", + "permissions": ["view_resource_type"], "filter": { "operator": "IN", + "left_hand_side": {"entity_type": "resource_type"}, "right_hand_side": {"collection": "ALL"}, - "left_hand_side": {"entity_type": "identity_provider"}, }, }, { - "permission": "view_app_task", + "permissions": ["view_custom_provider"], "filter": { "operator": "IN", - "left_hand_side": {"entity_type": "app_task"}, - "right_hand_side": {"collection": "SELF_OWNED"}, + "left_hand_side": {"entity_type": "custom_provider"}, + "right_hand_side": {"collection": "ALL"}, }, }, + ] + + CUSTOM_ROLE_SPECIFIC_COLLAB_FILTER = [ { - "permission": "view_app_variable", + "permissions": ["view_blueprint"], "filter": { "operator": "IN", - "left_hand_side": {"entity_type": "app_variable"}, - "right_hand_side": {"collection": "SELF_OWNED"}, + "left_hand_side": {"entity_type": "blueprint"}, + "right_hand_side": {"collection": "ALL"}, }, }, { - "permission": "view_image", + "permissions": ["view_environment"], "filter": { "operator": "IN", - "left_hand_side": {"entity_type": "resource_type"}, + "left_hand_side": {"entity_type": "environment"}, "right_hand_side": {"collection": "ALL"}, }, }, { - "permission": "view_image", + "permissions": ["view_marketplace_item"], "filter": { "operator": "IN", - "left_hand_side": {"entity_type": "custom_provider"}, + "left_hand_side": {"entity_type": "marketplace_item"}, "right_hand_side": {"collection": "ALL"}, }, }, @@ -590,3 +588,176 @@ class ENTITY_FILTER_EXPRESSION_LIST: } ], } + + # The entities in this collection are by default collab enabled + PROJECT_COLLAB_CONTEXT = { + "scope_filter_expression_list": [ + { + "operator": "IN", + "left_hand_side": "PROJECT", + "right_hand_side": {"uuid_list": []}, + } + ], + "entity_filter_expression_list": [ + { + "operator": "IN", + "left_hand_side": {"entity_type": "blueprint"}, + "right_hand_side": {"collection": "ALL"}, + }, + { + "operator": "IN", + "left_hand_side": {"entity_type": "environment"}, + "right_hand_side": {"collection": "ALL"}, + }, + { + "operator": "IN", + "left_hand_side": {"entity_type": "marketplace_item"}, + "right_hand_side": {"collection": "ALL"}, + }, + ], + } + + +class ACP_3_8_0: + class ENTITY_FILTER_EXPRESSION_LIST: + COMMON = [ + { + "operator": "IN", + "left_hand_side": {"entity_type": "distributed_virtual_switch"}, + "right_hand_side": {"collection": "ALL"}, + }, + { + "operator": "IN", + "left_hand_side": {"entity_type": "vm_recovery_point"}, + "right_hand_side": {"collection": "ALL"}, + }, + ] + PROJECT_ADMIN = [ + { + "operator": "IN", + "left_hand_side": {"entity_type": "report_config"}, + "right_hand_side": {"collection": "SELF_OWNED"}, + } + ] + + CUSTOM_ROLE_PERMISSIONS_FILTERS = [ + { + "permissions": ["view_vm_recovery_point"], + "filter": { + "operator": "IN", + "left_hand_side": {"entity_type": "vm_recovery_point"}, + "right_hand_side": {"collection": "ALL"}, + }, + }, + { + "permissions": ["view_virtual_switch"], + "filter": { + "operator": "IN", + "left_hand_side": {"entity_type": "distributed_virtual_switch"}, + "right_hand_side": {"collection": "ALL"}, + }, + }, + { + "permissions": ["view_report_config"], + "filter": { + "operator": "IN", + "left_hand_side": {"entity_type": "report_config"}, + "right_hand_side": {"collection": "SELF_OWNED"}, + }, + }, + ] + CUSTOM_ROLE_SPECIFIC_COLLAB_FILTER = [ + { + "permissions": ["view_user"], + "filter": { + "operator": "IN", + "right_hand_side": {"collection": "ALL"}, + "left_hand_side": {"entity_type": "user"}, + }, + }, + { + "permissions": ["view_virtual_machine"], + "filter": { + "operator": "IN", + "left_hand_side": {"entity_type": "vm"}, + "right_hand_side": {"collection": "ALL"}, + }, + }, + { + "permissions": ["view_user_group"], + "filter": { + "operator": "IN", + "right_hand_side": {"collection": "ALL"}, + "left_hand_side": {"entity_type": "user_group"}, + }, + }, + { + "permissions": ["view_runbook"], + "filter": { + "operator": "IN", + "left_hand_side": {"entity_type": "runbook"}, + "right_hand_side": {"collection": "ALL"}, + }, + }, + ] + + PROJECT_COLLAB_FILTER = [ + { + "operator": "IN", + "left_hand_side": {"entity_type": "runbook"}, + "right_hand_side": {"collection": "ALL"}, + } + ] + + PROJECT_ADMIN_SPECIFIC_COLLAB_FILTER = [ + { + "operator": "IN", + "left_hand_side": {"entity_type": "vm"}, + "right_hand_side": {"collection": "ALL"}, + }, + { + "operator": "IN", + "right_hand_side": {"collection": "ALL"}, + "left_hand_side": {"entity_type": "user"}, + }, + { + "operator": "IN", + "right_hand_side": {"collection": "ALL"}, + "left_hand_side": {"entity_type": "user_group"}, + }, + ] + + +class ACP_BEFORE_3_8_0: + class ENTITY_FILTER_EXPRESSION_LIST: + PROJECT_ADMIN = [ + { + "operator": "IN", + "right_hand_side": {"collection": "ALL"}, + "left_hand_side": {"entity_type": "user"}, + }, + { + "operator": "IN", + "right_hand_side": {"collection": "ALL"}, + "left_hand_side": {"entity_type": "user_group"}, + }, + ] + + CUSTOM_ROLE_PERMISSIONS_FILTERS = [ + { + "permissions": ["view_user"], + "filter": { + "operator": "IN", + "right_hand_side": {"collection": "ALL"}, + "left_hand_side": {"entity_type": "user"}, + }, + }, + { + "permissions": ["view_user_group"], + "filter": { + "operator": "IN", + "right_hand_side": {"collection": "ALL"}, + "left_hand_side": {"entity_type": "user_group"}, + }, + }, + ] diff --git a/calm/dsl/cli/library_tasks.py b/calm/dsl/cli/library_tasks.py index bb5f2f5d3..ece97d27e 100644 --- a/calm/dsl/cli/library_tasks.py +++ b/calm/dsl/cli/library_tasks.py @@ -504,15 +504,18 @@ def import_task(task_file, name, description, out_vars, force): or task_file.endswith(".escript.py2") or task_file.endswith(".escript.py3") or task_file.endswith(".ps1") + or task_file.endswith(".python") ): if task_file.endswith(".sh"): script_type = TASKS.SCRIPT_TYPES.SHELL - elif task_file.endswith(".escript") or task_file.endswith(".escript.py2"): + elif task_file.endswith(".escript.py2"): script_type = TASKS.SCRIPT_TYPES.ESCRIPT - elif task_file.endswith(".escript.py3"): + elif task_file.endswith(".escript") or task_file.endswith(".escript.py3"): script_type = TASKS.SCRIPT_TYPES.ESCRIPT_PY3 elif task_file.endswith(".ps1"): script_type = TASKS.SCRIPT_TYPES.POWERSHELL + elif task_file.endswith(".python"): + script_type = TASKS.SCRIPT_TYPES.PYTHON if out_vars is not None: task_type = TASKS.TASK_TYPES.SET_VARIABLE diff --git a/calm/dsl/cli/library_tasks_commands.py b/calm/dsl/cli/library_tasks_commands.py index 2c122fc07..e77bf5bc8 100644 --- a/calm/dsl/cli/library_tasks_commands.py +++ b/calm/dsl/cli/library_tasks_commands.py @@ -82,7 +82,7 @@ def _delete_task(task_names): "task_file", type=click.Path(exists=True, file_okay=True, dir_okay=False, readable=True), required=True, - help="Path of task file (.sh, .escript, .escript.py2, .escript.py3, .ps1)", + help="Path of task file (.sh, .escript, .escript.py2, .escript.py3, .ps1, .python)", ) @click.option("--name", "-n", default=None, help="Task Library item name (Optional)") @click.option( @@ -109,10 +109,11 @@ def _import_task(task_file, name, description, out_vars, force): (-f | --file) supports:\n \t.sh - Shell script file\n - \t.escript - Escript file(python2)\n + \t.escript - Escript file(python3)\n \t.escript.py2 - Escript file(python2)\n \t.escript.py3 - Escript file(python3)\n \t.ps1 - Powershell Script File\n + \t.python - Python Script File(python3)\n Note:\n To import Set-Variable task, use --out-vars="OUT1,OUT2". diff --git a/calm/dsl/cli/main.py b/calm/dsl/cli/main.py index ac124a512..e33155738 100644 --- a/calm/dsl/cli/main.py +++ b/calm/dsl/cli/main.py @@ -50,7 +50,7 @@ default=False, help="Update cache before running command", ) -@click.version_option("3.7.2.1") +@click.version_option("3.8.0") @click.pass_context def main(ctx, config_file, sync): """Calm CLI diff --git a/calm/dsl/decompile/bp_file_helper.py b/calm/dsl/decompile/bp_file_helper.py index be770698a..b8b7aea3c 100644 --- a/calm/dsl/decompile/bp_file_helper.py +++ b/calm/dsl/decompile/bp_file_helper.py @@ -195,6 +195,9 @@ def render_bp_file_template( for k, v in enumerate(dependepent_entities): update_entity_gui_dsl_name(v.get_gui_name(), v.__name__) + # Stores config attr classes to be rendered + config_attr_classes = {} + # Rendering templates for k, v in enumerate(dependepent_entities): if isinstance(v, ServiceType): @@ -203,13 +206,7 @@ def render_bp_file_template( ) elif isinstance(v, ConfigAttrs): - dependepent_entities[k] = render_config_attr_template( - v, - patch_attr_update_config_map, - secrets_dict, - endpoints=endpoints, - ep_list=ep_list, - ) + config_attr_classes[k] = v elif isinstance(v, PackageType): dependepent_entities[k] = render_package_template( @@ -237,6 +234,29 @@ def render_bp_file_template( ep_list=ep_list, ) + """" + Render config attr class after all other classes are rendered because it may have dependency on other classes. For instance: + + Case 1: + -> Multiple service classes present + -> Config attr contains tasks that have call runbook task for a service + -> Config attr class comes before a service class in dependepent_entities list + + In this case service class hasn't stored it's action map (RUNBOOK_ACTION_MAP) and config attr class gets rendered first, + then a look up for matching action in RUNBOOK_ACTION_MAP will fail and decompile fails. + + Solution: Store all config attr classes encountered in dependepent_entities and render them later when all other classes are rendered. + """ + + for k, v in config_attr_classes.items(): + dependepent_entities[k] = render_config_attr_template( + v, + patch_attr_update_config_map, + secrets_dict, + endpoints=endpoints, + ep_list=ep_list, + ) + is_any_secret_value_available = False for _e in secrets_dict: if _e.get("secret_value", ""): diff --git a/calm/dsl/decompile/schemas/task_decision_python.py.jinja2 b/calm/dsl/decompile/schemas/task_decision_python.py.jinja2 new file mode 100644 index 000000000..13c4b7e59 --- /dev/null +++ b/calm/dsl/decompile/schemas/task_decision_python.py.jinja2 @@ -0,0 +1,13 @@ +{%- macro decision_python_task(obj) -%} +{%- if obj.cred is not defined and obj.target is not defined %} +CalmTask.Decision.python(name='{{obj.name}}', filename={{obj.attrs.script_file}}) +{%- elif obj.cred is not defined %} +CalmTask.Decision.python(name='{{obj.name}}', filename={{obj.attrs.script_file}}, target={{obj.target}}) +{%- elif obj.target is not defined %} +CalmTask.Decision.python(name='{{obj.name}}', filename={{obj.attrs.script_file}}, cred={{obj.cred}}) +{%- else %} +CalmTask.Decision.python(name='{{obj.name}}', filename={{obj.attrs.script_file}}, cred={{obj.cred}}, target={{obj.target}}) +{%- endif %} +{%- endmacro %} + +{{ decision_python_task(obj) }} diff --git a/calm/dsl/decompile/schemas/task_exec_python.py.jinja2 b/calm/dsl/decompile/schemas/task_exec_python.py.jinja2 new file mode 100644 index 000000000..63e1a40a2 --- /dev/null +++ b/calm/dsl/decompile/schemas/task_exec_python.py.jinja2 @@ -0,0 +1,13 @@ +{%- macro exec_python_task(obj) -%} +{%- if obj.cred is not defined and obj.target is not defined %} +CalmTask.Exec.python(name='{{obj.name}}', filename={{obj.attrs.script_file}} {%- if obj.target_endpoint %}, target_endpoint={{obj.target_endpoint}} {%- endif %}) +{%- elif obj.cred is not defined %} +CalmTask.Exec.python(name='{{obj.name}}', filename={{obj.attrs.script_file}}, target={{obj.target}} {%- if obj.target_endpoint %}, target_endpoint={{obj.target_endpoint}} {%- endif %}) +{%- elif obj.target is not defined %} +CalmTask.Exec.python(name='{{obj.name}}', filename={{obj.attrs.script_file}}, cred={{obj.cred}} {%- if obj.target_endpoint %}, target_endpoint={{obj.target_endpoint}} {%- endif %}) +{%- else %} +CalmTask.Exec.python(name='{{obj.name}}', filename={{obj.attrs.script_file}}, cred={{obj.cred}}, target={{obj.target}} {%- if obj.target_endpoint %}, target_endpoint={{obj.target_endpoint}} {%- endif %}) +{%- endif %} +{%- endmacro %} + +{{ exec_python_task(obj) }} diff --git a/calm/dsl/decompile/schemas/task_setvariable_python.py.jinja2 b/calm/dsl/decompile/schemas/task_setvariable_python.py.jinja2 new file mode 100644 index 000000000..4125c0af5 --- /dev/null +++ b/calm/dsl/decompile/schemas/task_setvariable_python.py.jinja2 @@ -0,0 +1,15 @@ +{%- macro setvariable_python_task(obj) -%} +{%- if obj.cred is not defined and obj.target and obj.variables is not defined %} +CalmTask.SetVariable.python(name='{{obj.name}}', filename={{obj.attrs.script_file}} {%- if obj.target_endpoint %}, target_endpoint={{obj.target_endpoint}} {%- endif %}) +{%- elif obj.cred is not defined %} +CalmTask.SetVariable.python(name='{{obj.name}}', filename={{obj.attrs.script_file}} {%- if obj.target %}, target={{obj.target}}{% endif %}, variables={{obj.variables}} {%- if obj.target_endpoint %}, target_endpoint={{obj.target_endpoint}} {%- endif %}) +{%- elif obj.target is not defined %} +CalmTask.SetVariable.python(name='{{obj.name}}', filename={{obj.attrs.script_file}}, cred={{obj.cred}}, variables={{obj.variables}} {%- if obj.target_endpoint %}, target_endpoint={{obj.target_endpoint}} {%- endif %}) +{%- elif obj.variables is not defined %} +CalmTask.SetVariable.python(name='{{obj.name}}', filename={{obj.attrs.script_file}}, cred={{obj.cred}}, target={{obj.target}} {%- if obj.target_endpoint %}, target_endpoint={{obj.target_endpoint}} {%- endif %}) +{%- else %} +CalmTask.SetVariable.python(name='{{obj.name}}', filename={{obj.attrs.script_file}}, cred={{obj.cred}}, target={{obj.target}}, variables={{obj.variables}} {%- if obj.target_endpoint %}, target_endpoint={{obj.target_endpoint}} {%- endif %}) +{%- endif %} +{%- endmacro %} + +{{ setvariable_python_task(obj) }} diff --git a/calm/dsl/decompile/task.py b/calm/dsl/decompile/task.py index 61264caec..66f7a6e08 100644 --- a/calm/dsl/decompile/task.py +++ b/calm/dsl/decompile/task.py @@ -77,6 +77,9 @@ def render_task_template( elif script_type == "npsscript": schema_file = "task_exec_powershell.py.jinja2" + elif script_type == "python_remote": + schema_file = "task_exec_python.py.jinja2" + elif cls.type == "SET_VARIABLE": variables = cls.attrs.get("eval_variables", None) if variables: @@ -98,6 +101,9 @@ def render_task_template( elif script_type == "npsscript": schema_file = "task_setvariable_powershell.py.jinja2" + elif script_type == "python_remote": + schema_file = "task_setvariable_python.py.jinja2" + elif cls.type == "DELAY": if hasattr(cls, "attrs"): user_attrs["delay_seconds"] = cls.attrs.get("interval_secs", 0) @@ -262,6 +268,10 @@ def render_task_template( elif script_type == "npsscript": schema_file = "task_decision_powershell.py.jinja2" + + elif script_type == "python_remote": + schema_file = "task_decision_python.py.jinja2" + elif cls.type == "WHILE_LOOP": exit_condition_type = cls.attrs["exit_condition_type"] for key in EXIT_CONDITION_MAP: @@ -295,7 +305,7 @@ def create_script_file(script_type, script="", entity_context=""): elif script_type == "npsscript": file_name += ".ps1" - elif script_type in ["static", "static_py3"]: + elif script_type in ["static", "static_py3", "python_remote"]: file_name += ".py" else: diff --git a/examples/AHV_CONFIG/snapshot_restore/blueprint.py b/examples/AHV_CONFIG/snapshot_restore/blueprint.py index 10285d0e4..9efb2938e 100644 --- a/examples/AHV_CONFIG/snapshot_restore/blueprint.py +++ b/examples/AHV_CONFIG/snapshot_restore/blueprint.py @@ -115,16 +115,16 @@ class HelloSubstrate(Substrate): def __pre_create__(): # Step 1 - Task.Exec.escript( - name="Task1", script="print 'Pre Create task runs before VM is created'" + Task.Exec.escript.py3( + name="Task1", script="print ('Pre Create task runs before VM is created')" ) @action def __post_delete__(): # Step 1 - Task.Exec.escript( - name="Task1", script="print 'Post delete task runs after VM is deleted'" + Task.Exec.escript.py3( + name="Task1", script="print ('Post delete task runs after VM is deleted')" ) diff --git a/examples/AHV_CONFIG/snapshot_restore/demo_blueprint.py b/examples/AHV_CONFIG/snapshot_restore/demo_blueprint.py index 33cb3abb6..088e1872b 100644 --- a/examples/AHV_CONFIG/snapshot_restore/demo_blueprint.py +++ b/examples/AHV_CONFIG/snapshot_restore/demo_blueprint.py @@ -83,16 +83,16 @@ class HelloSubstrate(Substrate): def __pre_create__(): # Step 1 - Task.Exec.escript( - name="Task1", script="print 'Pre Create task runs before VM is created'" + Task.Exec.escript.py3( + name="Task1", script="print ('Pre Create task runs before VM is created')" ) @action def __post_delete__(): # Step 1 - Task.Exec.escript( - name="Task1", script="print 'Post delete task runs after VM is deleted'" + Task.Exec.escript.py3( + name="Task1", script="print ('Post delete task runs after VM is deleted')" ) diff --git a/examples/AHV_K8S_Discourse/AHV_K8S_Discourse.py b/examples/AHV_K8S_Discourse/AHV_K8S_Discourse.py index 7e05c8a3b..00c0a93c1 100644 --- a/examples/AHV_K8S_Discourse/AHV_K8S_Discourse.py +++ b/examples/AHV_K8S_Discourse/AHV_K8S_Discourse.py @@ -80,7 +80,7 @@ class DiscourseContainer(Service): @action def sample_action(): - CalmTask.Exec.escript(name="Sample Task", script="print 'Hello!'") + CalmTask.Exec.escript.py3(name="Sample Task", script="print ('Hello!')") class DiscourseDeployment(PODDeployment): diff --git a/examples/AHV_MACRO_BLUEPRINT/blueprint.py b/examples/AHV_MACRO_BLUEPRINT/blueprint.py index 744d2f78b..22bcb45dc 100644 --- a/examples/AHV_MACRO_BLUEPRINT/blueprint.py +++ b/examples/AHV_MACRO_BLUEPRINT/blueprint.py @@ -50,7 +50,7 @@ class VMSubstrate(Substrate): @action def __pre_create__(): - CalmTask.SetVariable.escript( + CalmTask.SetVariable.escript.py3( name="Pre_create task1", filename=os.path.join("scripts", "pre_create_script.py"), target=ref(VMSubstrate), diff --git a/examples/AHV_MACRO_BLUEPRINT/blueprint_em.py b/examples/AHV_MACRO_BLUEPRINT/blueprint_em.py index 35eaf348e..61e42e49e 100644 --- a/examples/AHV_MACRO_BLUEPRINT/blueprint_em.py +++ b/examples/AHV_MACRO_BLUEPRINT/blueprint_em.py @@ -49,7 +49,7 @@ class ExistingVM(Substrate): @action def __pre_create__(): - CalmTask.Exec.escript(name="Pre Create Task", script="print 'Hello!'") + CalmTask.Exec.escript.py3(name="Pre Create Task", script="print ('Hello!')") class MacroBlueprintDeployment(Deployment): diff --git a/examples/AHV_MACRO_BLUEPRINT/sample_runbook.py b/examples/AHV_MACRO_BLUEPRINT/sample_runbook.py index 1adc54091..4513b0564 100644 --- a/examples/AHV_MACRO_BLUEPRINT/sample_runbook.py +++ b/examples/AHV_MACRO_BLUEPRINT/sample_runbook.py @@ -16,4 +16,4 @@ def DslSetVariableRunbook(): Task.SetVariable.ssh( name="Task2", filename=os.path.join("scripts", "set_variable_task2_script.sh"), variables=["var2"], target=ref(Endpoint.use_existing("linux_bedag")) ) - Task.Exec.escript(name="Task3", script="print '@@{var1}@@ @@{var2}@@'") + Task.Exec.escript(name="Task3", script="print ('@@{var1}@@ @@{var2}@@')") diff --git a/examples/AHV_MACRO_BLUEPRINT/sample_runbook_2.py b/examples/AHV_MACRO_BLUEPRINT/sample_runbook_2.py index b7eee3c26..2ca3149e3 100644 --- a/examples/AHV_MACRO_BLUEPRINT/sample_runbook_2.py +++ b/examples/AHV_MACRO_BLUEPRINT/sample_runbook_2.py @@ -11,5 +11,5 @@ def DslSetVariableRunbook(): "Runbook example with Set Variable Tasks" - Task.SetVariable.escript(name="Task1", script="print 'var1=test'", variables=["var1"]) - Task.Exec.escript(name="Task3", script="print '@@{var1}@@ @@{var2}@@'") + Task.SetVariable.escript(name="Task1", script="print ('var1=test')", variables=["var1"]) + Task.Exec.escript(name="Task3", script="print ('@@{var1}@@ @@{var2}@@')") diff --git a/examples/AHV_MACRO_BLUEPRINT/scripts/pre_create_script.py b/examples/AHV_MACRO_BLUEPRINT/scripts/pre_create_script.py index b26a84024..2d0d891ee 100644 --- a/examples/AHV_MACRO_BLUEPRINT/scripts/pre_create_script.py +++ b/examples/AHV_MACRO_BLUEPRINT/scripts/pre_create_script.py @@ -1 +1 @@ -print 'custom_nic={"kind": "subnet", "uuid": "6db195b8-438a-e301-6ec7-bea88ee197f1"}' \ No newline at end of file +print ('custom_nic={"kind": "subnet", "uuid": "6db195b8-438a-e301-6ec7-bea88ee197f1"}') \ No newline at end of file diff --git a/examples/AHV_MACRO_BLUEPRINT/scripts/set_variable_task1_script.py b/examples/AHV_MACRO_BLUEPRINT/scripts/set_variable_task1_script.py index c05433458..8a623fbaf 100644 --- a/examples/AHV_MACRO_BLUEPRINT/scripts/set_variable_task1_script.py +++ b/examples/AHV_MACRO_BLUEPRINT/scripts/set_variable_task1_script.py @@ -1 +1 @@ -print 'var1=test' \ No newline at end of file +print ('var1=test') \ No newline at end of file diff --git a/examples/Dev_Cpnhgn_Hybrid/devcpnhgnhybrd.py b/examples/Dev_Cpnhgn_Hybrid/devcpnhgnhybrd.py index 0971a8bd9..1e958b33b 100644 --- a/examples/Dev_Cpnhgn_Hybrid/devcpnhgnhybrd.py +++ b/examples/Dev_Cpnhgn_Hybrid/devcpnhgnhybrd.py @@ -198,12 +198,12 @@ class Era_PostgreSQL_DB(Substrate): @action def __pre_create__(): - CalmTask.SetVariable.escript( + CalmTask.SetVariable.escript.py3( name="1GetClusterID", filename="scripts/postgres/precreate/1GetClusterID.py", variables=["CLUSTER_ID", "TIME"], ) - CalmTask.SetVariable.escript( + CalmTask.SetVariable.escript.py3( name="2GetProfileIDs", filename="scripts/postgres/precreate/2GetProfileIDs.py", variables=[ @@ -213,22 +213,22 @@ def __pre_create__(): "DB_PARAM_ID", ], ) - CalmTask.SetVariable.escript( + CalmTask.SetVariable.escript.py3( name="3GetSLAID", filename="scripts/postgres/precreate/3GetSLAID.py", variables=["SLA_ID", "DB_NAME"], ) - CalmTask.SetVariable.escript( + CalmTask.SetVariable.escript.py3( name="4ProvisionDB", filename="scripts/postgres/precreate/4ProvisionDB.py", variables=["CREATE_OPERATION_ID"], ) - CalmTask.SetVariable.escript( + CalmTask.SetVariable.escript.py3( name="5MonitorOperation", filename="scripts/postgres/precreate/5MonitorOperation.py", variables=["DB_ENTITY_NAME"], ) - CalmTask.SetVariable.escript( + CalmTask.SetVariable.escript.py3( name="6GetDatabaseInfo", filename="scripts/postgres/precreate/6GetDatabaseInfo.py", variables=["DB_SERVER_IP", "DB_ID", "DB_SERVER_ID"], @@ -237,21 +237,21 @@ def __pre_create__(): @action def __post_delete__(): - CalmTask.SetVariable.escript( + CalmTask.SetVariable.escript.py3( name="1CleanupDB", filename="scripts/postgres/postdelete/1CleanupDB.py", variables=["CLEANUP_OPERATION_ID"], ) - CalmTask.Exec.escript( + CalmTask.Exec.escript.py3( name="2MonitorCleanupOp", filename="scripts/postgres/postdelete/2MonitorCleanupOp.py", ) - CalmTask.SetVariable.escript( + CalmTask.SetVariable.escript.py3( name="3DeregisterDBServer", filename="scripts/postgres/postdelete/3DeregisterDBServer.py", variables=["DEREGISTER_OPERATION_ID"], ) - CalmTask.Exec.escript( + CalmTask.Exec.escript.py3( name="4MonitorDeregOp", filename="scripts/postgres/postdelete/4MonitorDeregOp.py", ) @@ -387,7 +387,7 @@ def UpdateApp(): filename="scripts/haproxy/updateapp/RemoveWS1.sh", target=ref(HaProxy), ) - CalmTask.Exec.escript( + CalmTask.Exec.escript.py3( name="1UpdateContainers", filename="scripts/webserver/updateapp/UpdateContainers.py", target=ref(WebServerK8s), diff --git a/examples/Dev_Cpnhgn_Hybrid/scripts/postgres/postdelete/3DeregisterDBServer.py b/examples/Dev_Cpnhgn_Hybrid/scripts/postgres/postdelete/3DeregisterDBServer.py index b93939e99..7afc06631 100644 --- a/examples/Dev_Cpnhgn_Hybrid/scripts/postgres/postdelete/3DeregisterDBServer.py +++ b/examples/Dev_Cpnhgn_Hybrid/scripts/postgres/postdelete/3DeregisterDBServer.py @@ -9,9 +9,9 @@ url, verb="DELETE", auth="BASIC", user=era_user, passwd=era_pass, headers=headers ) if resp.ok: - print "DEREGISTER_OPERATION_ID={0}".format(json.loads(resp.content)["operationId"]) + print ("DEREGISTER_OPERATION_ID={0}".format(json.loads(resp.content)["operationId"])) else: - print "Deregister DB Server Operation failed", json.dumps( + print ("Deregister DB Server Operation failed", json.dumps( json.loads(resp.content), indent=4 - ) + )) exit(1) diff --git a/examples/Dev_Cpnhgn_Hybrid/scripts/webserver/updateapp/UpdateContainers.py b/examples/Dev_Cpnhgn_Hybrid/scripts/webserver/updateapp/UpdateContainers.py index c3fd5322f..3b6c40451 100644 --- a/examples/Dev_Cpnhgn_Hybrid/scripts/webserver/updateapp/UpdateContainers.py +++ b/examples/Dev_Cpnhgn_Hybrid/scripts/webserver/updateapp/UpdateContainers.py @@ -25,10 +25,10 @@ resp = urlreq(url, verb='PATCH', auth='BASIC', user=kube_user, passwd=kube_pass, params=json.dumps(payload), headers=headers) if resp.ok: - print json.dumps(json.loads(resp.content), indent=4) + print (json.dumps(json.loads(resp.content), indent=4)) else: - print "Patch K8S Deployment request failed", json.dumps(json.loads(resp.content), indent=4) + print ("Patch K8S Deployment request failed", json.dumps(json.loads(resp.content), indent=4)) exit(1) else: - print "calm_array_index is not 0, skipping." + print ("calm_array_index is not 0, skipping.") diff --git a/examples/EraPostgres/erapostgres.py b/examples/EraPostgres/erapostgres.py index 218007509..0d3db9b82 100644 --- a/examples/EraPostgres/erapostgres.py +++ b/examples/EraPostgres/erapostgres.py @@ -45,12 +45,12 @@ class Era_PostgreSQL_DB(Substrate): @action def __pre_create__(): - CalmTask.SetVariable.escript( + CalmTask.SetVariable.escript.py3( name="1GetClusterID", filename="scripts/postgres/precreate/1GetClusterID.py", variables=["CLUSTER_ID"], ) - CalmTask.SetVariable.escript( + CalmTask.SetVariable.escript.py3( name="2GetProfileIDs", filename="scripts/postgres/precreate/2GetProfileIDs.py", variables=[ @@ -60,22 +60,22 @@ def __pre_create__(): "DB_PARAM_ID", ], ) - CalmTask.SetVariable.escript( + CalmTask.SetVariable.escript.py3( name="3GetSLAID", filename="scripts/postgres/precreate/3GetSLAID.py", variables=["SLA_ID"], ) - CalmTask.SetVariable.escript( + CalmTask.SetVariable.escript.py3( name="4ProvisionDB", filename="scripts/postgres/precreate/4ProvisionDB.py", variables=["CREATE_OPERATION_ID"], ) - CalmTask.SetVariable.escript( + CalmTask.SetVariable.escript.py3( name="5MonitorOperation", filename="scripts/postgres/precreate/5MonitorOperation.py", variables=["DB_ENTITY_NAME"], ) - CalmTask.SetVariable.escript( + CalmTask.SetVariable.escript.py3( name="6GetDatabaseInfo", filename="scripts/postgres/precreate/6GetDatabaseInfo.py", variables=["DB_SERVER_IP", "DB_ID", "DB_SERVER_ID"], @@ -84,21 +84,21 @@ def __pre_create__(): @action def __post_delete__(): - CalmTask.SetVariable.escript( + CalmTask.SetVariable.escript.py3( name="1CleanupDB", filename="scripts/postgres/postdelete/1CleanupDB.py", variables=["CLEANUP_OPERATION_ID"], ) - CalmTask.Exec.escript( + CalmTask.Exec.escript.py3( name="2MonitorCleanupOp", filename="scripts/postgres/postdelete/2MonitorCleanupOp.py", ) - CalmTask.SetVariable.escript( + CalmTask.SetVariable.escript.py3( name="3DeregisterDBServer", filename="scripts/postgres/postdelete/3DeregisterDBServer.py", variables=["DEREGISTER_OPERATION_ID"], ) - CalmTask.Exec.escript( + CalmTask.Exec.escript.py3( name="4MonitorDeregOp", filename="scripts/postgres/postdelete/4MonitorDeregOp.py", ) diff --git a/examples/Kubernetes/kubernetes.py b/examples/Kubernetes/kubernetes.py index 1cf1c207e..1e640ea43 100644 --- a/examples/Kubernetes/kubernetes.py +++ b/examples/Kubernetes/kubernetes.py @@ -51,9 +51,9 @@ class MasterPackage(Package): @action def __install__(): - CalmTask.SetVariable.escript( + CalmTask.SetVariable.escript.py3( name="Set Kubernetes Version", - script="print 'VERSION=@@{KUBE_VERSION}@@'", + script="print ('VERSION=@@{KUBE_VERSION}@@')", variables=["VERSION"], ) CalmTask.Exec.ssh( @@ -76,9 +76,9 @@ class WorkerPackage(Package): @action def __install__(): - CalmTask.SetVariable.escript( + CalmTask.SetVariable.escript.py3( name="Set Kubernetes Version", - script="print 'VERSION=@@{KUBE_VERSION}@@'", + script="print ('VERSION=@@{KUBE_VERSION}@@')", variables=["VERSION"], ) CalmTask.Exec.ssh(name="Docker Kubelet Install", filename="scripts/Worker01.sh") @@ -218,15 +218,15 @@ def Upgrade(): ) with parallel(): - CalmTask.SetVariable.escript( + CalmTask.SetVariable.escript.py3( name="Set Version Master", - script="print 'VERSION=@@{KUBE_VERSION_NEW}@@'", + script="print ('VERSION=@@{KUBE_VERSION_NEW}@@')", variables=["VERSION"], target=ref(Master), ) - CalmTask.SetVariable.escript( + CalmTask.SetVariable.escript.py3( name="Set Version Slave", - script="print 'VERSION=@@{KUBE_VERSION_NEW}@@'", + script="print ('VERSION=@@{KUBE_VERSION_NEW}@@')", variables=["VERSION"], target=ref(Worker), ) diff --git a/examples/OscarApp/oscarapp.py b/examples/OscarApp/oscarapp.py index 9e9272f9d..555efc855 100644 --- a/examples/OscarApp/oscarapp.py +++ b/examples/OscarApp/oscarapp.py @@ -137,31 +137,31 @@ def __install__(): cred=CentOsCreds, ) - CalmTask.SetVariable.escript( + CalmTask.SetVariable.escript.py3( name="02CreateAlert", filename="scripts/oscar/package_install/02CreateAlert.py", variables=["ALERT_UUID"], ) - CalmTask.SetVariable.escript( + CalmTask.SetVariable.escript.py3( name="03GetAlertUid", filename="scripts/oscar/package_install/03GetAlertUid.py", variables=["ALERT_UID"], ) - CalmTask.SetVariable.escript( + CalmTask.SetVariable.escript.py3( name="04GetTriggerTypes", filename="scripts/oscar/package_install/04GetTriggerTypes.py", variables=["ALERT_TRIGGER_UUID"], ) - CalmTask.SetVariable.escript( + CalmTask.SetVariable.escript.py3( name="05GetActionTypes", filename="scripts/oscar/package_install/05GetActionTypes.py", variables=["ACTION_VMAMA_UUID", "ACTION_RA_UUID", "ACTION_EA_UUID"], ) - CalmTask.SetVariable.escript( + CalmTask.SetVariable.escript.py3( name="06CreatePlaybook", filename="scripts/oscar/package_install/06CreatePlaybook.py", variables=["PLAYBOOK_UUID"], @@ -176,12 +176,12 @@ def __uninstall__(): cred=CentOsCreds, ) - CalmTask.Exec.escript( + CalmTask.Exec.escript.py3( name="02DeleteAlert", filename="scripts/oscar/package_uninstall/02DeleteAlert.py", ) - CalmTask.Exec.escript( + CalmTask.Exec.escript.py3( name="03DeletePlaybook", filename="scripts/oscar/package_uninstall/03DeletePlaybook.py", ) @@ -224,12 +224,12 @@ class Era_PostgreSQL_DB(Substrate): @action def __pre_create__(): - CalmTask.SetVariable.escript( + CalmTask.SetVariable.escript.py3( name="1GetClusterID", filename="scripts/postgres/precreate/1GetClusterID.py", variables=["CLUSTER_ID"], ) - CalmTask.SetVariable.escript( + CalmTask.SetVariable.escript.py3( name="2GetProfileIDs", filename="scripts/postgres/precreate/2GetProfileIDs.py", variables=[ @@ -240,22 +240,22 @@ def __pre_create__(): "TIMESTAMP", ], ) - CalmTask.SetVariable.escript( + CalmTask.SetVariable.escript.py3( name="3GetSLAID", filename="scripts/postgres/precreate/3GetSLAID.py", variables=["SLA_ID", "DB_NAME"], ) - CalmTask.SetVariable.escript( + CalmTask.SetVariable.escript.py3( name="4ProvisionDB", filename="scripts/postgres/precreate/4ProvisionDB.py", variables=["CREATE_OPERATION_ID"], ) - CalmTask.SetVariable.escript( + CalmTask.SetVariable.escript.py3( name="5MonitorOperation", filename="scripts/postgres/precreate/5MonitorOperation.py", variables=["DB_ENTITY_NAME"], ) - CalmTask.SetVariable.escript( + CalmTask.SetVariable.escript.py3( name="6GetDatabaseInfo", filename="scripts/postgres/precreate/6GetDatabaseInfo.py", variables=["DB_SERVER_IP", "DB_ID", "DB_SERVER_ID"], @@ -264,21 +264,21 @@ def __pre_create__(): @action def __post_delete__(): - CalmTask.SetVariable.escript( + CalmTask.SetVariable.escript.py3( name="1CleanupDB", filename="scripts/postgres/postdelete/1CleanupDB.py", variables=["CLEANUP_OPERATION_ID"], ) - CalmTask.Exec.escript( + CalmTask.Exec.escript.py3( name="2MonitorCleanupOp", filename="scripts/postgres/postdelete/2MonitorCleanupOp.py", ) - CalmTask.SetVariable.escript( + CalmTask.SetVariable.escript.py3( name="3DeregisterDBServer", filename="scripts/postgres/postdelete/3DeregisterDBServer.py", variables=["DEREGISTER_OPERATION_ID"], ) - CalmTask.Exec.escript( + CalmTask.Exec.escript.py3( name="4MonitorDeregOp", filename="scripts/postgres/postdelete/4MonitorDeregOp.py", ) diff --git a/examples/Runbooks/NutanixDB_runbooks/ndb_example/scripts/GetTimemachineID.py b/examples/Runbooks/NutanixDB_runbooks/ndb_example/scripts/GetTimemachineID.py index c9921cacd..2045318c9 100644 --- a/examples/Runbooks/NutanixDB_runbooks/ndb_example/scripts/GetTimemachineID.py +++ b/examples/Runbooks/NutanixDB_runbooks/ndb_example/scripts/GetTimemachineID.py @@ -1,3 +1,3 @@ #Lets get the timemachine ID and create a snapshot time_machines = json.loads('''@@{time_machine}@@''') -print "time_machine_id={}".format(time_machines[0]["id"]) \ No newline at end of file +print ("time_machine_id={}".format(time_machines[0]["id"])) \ No newline at end of file diff --git a/examples/Runbooks/NutanixDB_runbooks/ndb_example/scripts/ReserveanIPAddress.py b/examples/Runbooks/NutanixDB_runbooks/ndb_example/scripts/ReserveanIPAddress.py index d054b2648..518e402e8 100644 --- a/examples/Runbooks/NutanixDB_runbooks/ndb_example/scripts/ReserveanIPAddress.py +++ b/examples/Runbooks/NutanixDB_runbooks/ndb_example/scripts/ReserveanIPAddress.py @@ -1,2 +1,2 @@ -print "@@{user_provided_static_ip}@@" -print "This task is used to simulate the IPAM IP Address reservation" \ No newline at end of file +print ("@@{user_provided_static_ip}@@") +print ("This task is used to simulate the IPAM IP Address reservation") \ No newline at end of file diff --git a/examples/Runbooks/NutanixDB_runbooks/postgresDB_create_snapshot.py b/examples/Runbooks/NutanixDB_runbooks/postgresDB_create_snapshot.py index d44776e39..fb80715d7 100644 --- a/examples/Runbooks/NutanixDB_runbooks/postgresDB_create_snapshot.py +++ b/examples/Runbooks/NutanixDB_runbooks/postgresDB_create_snapshot.py @@ -25,4 +25,4 @@ def NDBSnapshotCreate(): ) # Escript task to print output variables from above snapshot action - Task.Exec.escript(name="Print Outputs", script="print '@@{myplatformdata}@@'") \ No newline at end of file + Task.Exec.escript.py3(name="Print Outputs", script="print ('@@{myplatformdata}@@')") \ No newline at end of file diff --git a/examples/Runbooks/entity_stats.py b/examples/Runbooks/entity_stats.py index 5e901f31c..904048d51 100644 --- a/examples/Runbooks/entity_stats.py +++ b/examples/Runbooks/entity_stats.py @@ -11,11 +11,11 @@ PCEndpoint = Endpoint.HTTP("https://localhost:9440/api/nutanix/v3") script = """ -print "Calm Entity Stats are as follows -" -print "Endpoint Count - @@{endpoints_count}@@" -print "Blueprint Count - @@{blueprints_count}@@" -print "Runbook Count - @@{runbooks_count}@@" -print "Apps Count - @@{apps_count}@@" +print ("Calm Entity Stats are as follows -") +print ("Endpoint Count - @@{endpoints_count}@@") +print ("Blueprint Count - @@{blueprints_count}@@") +print ("Runbook Count - @@{runbooks_count}@@") +print ("Apps Count - @@{apps_count}@@") """ diff --git a/examples/Runbooks/logs_cleanup.py b/examples/Runbooks/logs_cleanup.py index ac74b29b4..dd403e4de 100644 --- a/examples/Runbooks/logs_cleanup.py +++ b/examples/Runbooks/logs_cleanup.py @@ -38,12 +38,12 @@ def DslLogsCleanupRunbook(endpoints=[DslLinuxEndpoint]): ) Task.Exec.escript( name="FinalOutput", - script="print 'logs size changed from @@{size_before_cleanup}@@ => @@{size_after_cleanup}@@'", + script="print ('logs size changed from @@{size_before_cleanup}@@ => @@{size_after_cleanup}@@')", target=endpoints[0], ) else: - Task.Exec.escript(script='''print "Given Logs Directory doesn't exists"''') + Task.Exec.escript.py3(script='''print ("Given Logs Directory doesn't exists")''') def main(): diff --git a/examples/Runbooks/runbook_approval_policy_entity_stats.py b/examples/Runbooks/runbook_approval_policy_entity_stats.py index b5faa3f90..50c242f5e 100644 --- a/examples/Runbooks/runbook_approval_policy_entity_stats.py +++ b/examples/Runbooks/runbook_approval_policy_entity_stats.py @@ -18,11 +18,11 @@ PCEndpoint = Endpoint.HTTP("https://localhost:9440/api/nutanix/v3") script = """ -print "Calm Entity Stats are as follows -" -print "Endpoint Count - @@{endpoints_count}@@" -print "Blueprint Count - @@{blueprints_count}@@" -print "Runbook Count - @@{runbooks_count}@@" -print "Apps Count - @@{apps_count}@@" +print ("Calm Entity Stats are as follows -") +print ("Endpoint Count - @@{endpoints_count}@@") +print ("Blueprint Count - @@{blueprints_count}@@") +print ("Runbook Count - @@{runbooks_count}@@") +print ("Apps Count - @@{apps_count}@@") """ diff --git a/examples/vpcBlueprint/Hello/blueprint.py b/examples/vpcBlueprint/Hello/blueprint.py index 6e8f7bf69..42cb33fd7 100644 --- a/examples/vpcBlueprint/Hello/blueprint.py +++ b/examples/vpcBlueprint/Hello/blueprint.py @@ -195,7 +195,7 @@ class HelloSubstrate(Substrate): @action def __pre_create__(): - CalmTask.Exec.escript( + CalmTask.Exec.escript.py3( name="Task1", filename=os.path.join( "scripts", @@ -207,7 +207,7 @@ def __pre_create__(): @action def __post_delete__(): - CalmTask.Exec.escript( + CalmTask.Exec.escript.py3( name="Task1", filename=os.path.join( "scripts", diff --git a/examples/vpcBlueprint/Hello/scripts/Substrate_HelloSubstrate_Action___post_delete___Task_Task1.py b/examples/vpcBlueprint/Hello/scripts/Substrate_HelloSubstrate_Action___post_delete___Task_Task1.py index b6c6ee3b7..b71a056f5 100644 --- a/examples/vpcBlueprint/Hello/scripts/Substrate_HelloSubstrate_Action___post_delete___Task_Task1.py +++ b/examples/vpcBlueprint/Hello/scripts/Substrate_HelloSubstrate_Action___post_delete___Task_Task1.py @@ -1 +1 @@ -print 'Post delete task runs after VM is deleted' \ No newline at end of file +print ('Post delete task runs after VM is deleted') \ No newline at end of file diff --git a/examples/vpcBlueprint/Hello/scripts/Substrate_HelloSubstrate_Action___pre_create___Task_Task1.py b/examples/vpcBlueprint/Hello/scripts/Substrate_HelloSubstrate_Action___pre_create___Task_Task1.py index d457fd023..26d9ac9ad 100644 --- a/examples/vpcBlueprint/Hello/scripts/Substrate_HelloSubstrate_Action___pre_create___Task_Task1.py +++ b/examples/vpcBlueprint/Hello/scripts/Substrate_HelloSubstrate_Action___pre_create___Task_Task1.py @@ -1 +1 @@ -print 'Pre Create task runs before VM is created' \ No newline at end of file +print ('Pre Create task runs before VM is created') \ No newline at end of file diff --git a/examples/vpcBlueprint/blueprint.py b/examples/vpcBlueprint/blueprint.py index 1a3c4d77f..324763ba6 100644 --- a/examples/vpcBlueprint/blueprint.py +++ b/examples/vpcBlueprint/blueprint.py @@ -200,16 +200,16 @@ class HelloSubstrate(Substrate): def __pre_create__(): # Step 1 - Task.Exec.escript( - name="Task1", script="print 'Pre Create task runs before VM is created'" + Task.Exec.escript.py3( + name="Task1", script="print ('Pre Create task runs before VM is created')" ) @action def __post_delete__(): # Step 1 - Task.Exec.escript( - name="Task1", script="print 'Post delete task runs after VM is deleted'" + Task.Exec.escript.py3( + name="Task1", script="print ('Post delete task runs after VM is deleted')" ) diff --git a/examples/vpcBlueprint/temp b/examples/vpcBlueprint/temp index 1f4c3bb0a..f371d1c9c 100644 --- a/examples/vpcBlueprint/temp +++ b/examples/vpcBlueprint/temp @@ -1 +1 @@ -{"status":{},"contains_secrets":true,"product_version":"3.4.0","spec":{"description":"Sample blueprint for Hello app using AHV VM","resources":{"client_attrs":{"None":{"Profile":{"HelloProfile":{"Action":{},"dsl_name":"HelloProfile"}},"Package":{"HelloPackage":{"Action":{},"dsl_name":"HelloPackage"},"centos_disk":{"Action":{},"dsl_name":"centos_disk"}},"Substrate":{"HelloSubstrate":{"Action":{},"AhvVm":{"HelloVm":{"dsl_name":"HelloVm"}},"dsl_name":"HelloSubstrate"}},"Service":{"HelloService":{"Action":{},"dsl_name":"HelloService"}},"Deployment":{"HelloDeployment":{"Action":{},"dsl_name":"HelloDeployment"}}}},"service_definition_list":[{"singleton":false,"action_list":[{"description":"System action for creating an application","type":"system","critical":true,"runbook":{"task_definition_list":[{"target_any_local_reference":{"kind":"app_service","name":"HelloService"},"retries":"0","description":"","child_tasks_local_reference_list":[{"kind":"app_task","name":"Task1"}],"name":"HelloService___create___dag","attrs":{"edges":[],"type":""},"timeout_secs":"0","type":"DAG","variable_list":[]},{"target_any_local_reference":{"kind":"app_service","name":"HelloService"},"retries":"0","description":"","child_tasks_local_reference_list":[],"name":"Task1","attrs":{"script":"echo 'Service create in ENV=@@{ENV}@@'","type":"","command_line_args":"","exit_status":[],"script_type":"sh"},"timeout_secs":"0","type":"EXEC","variable_list":[]}],"description":"","name":"HelloService___create___runbook","main_task_local_reference":{"kind":"app_task","name":"HelloService___create___dag"},"variable_list":[]},"name":"action_create"},{"description":"System action for starting an application","type":"system","critical":true,"runbook":{"task_definition_list":[{"target_any_local_reference":{"kind":"app_service","name":"HelloService"},"retries":"0","description":"","child_tasks_local_reference_list":[{"kind":"app_task","name":"Task1"}],"name":"HelloService___start___dag","attrs":{"edges":[],"type":""},"timeout_secs":"0","type":"DAG","variable_list":[]},{"target_any_local_reference":{"kind":"app_service","name":"HelloService"},"retries":"0","description":"","child_tasks_local_reference_list":[],"name":"Task1","attrs":{"script":"echo 'Service start in ENV=@@{ENV}@@'","type":"","command_line_args":"","exit_status":[],"script_type":"sh"},"timeout_secs":"0","type":"EXEC","variable_list":[]}],"description":"","name":"HelloService___start___runbook","main_task_local_reference":{"kind":"app_task","name":"HelloService___start___dag"},"variable_list":[]},"name":"action_start"},{"description":"System action for stopping an application","type":"system","critical":true,"runbook":{"task_definition_list":[{"target_any_local_reference":{"kind":"app_service","name":"HelloService"},"retries":"0","description":"","child_tasks_local_reference_list":[{"kind":"app_task","name":"Task1"}],"name":"HelloService___stop___dag","attrs":{"edges":[],"type":""},"timeout_secs":"0","type":"DAG","variable_list":[]},{"target_any_local_reference":{"kind":"app_service","name":"HelloService"},"retries":"0","description":"","child_tasks_local_reference_list":[],"name":"Task1","attrs":{"script":"echo 'Service stop in ENV=@@{ENV}@@'","type":"","command_line_args":"","exit_status":[],"script_type":"sh"},"timeout_secs":"0","type":"EXEC","variable_list":[]}],"description":"","name":"HelloService___stop___runbook","main_task_local_reference":{"kind":"app_task","name":"HelloService___stop___dag"},"variable_list":[]},"name":"action_stop"},{"description":"System action for deleting an application. Deletes created VMs as well","type":"system","critical":true,"runbook":{"task_definition_list":[{"target_any_local_reference":{"kind":"app_service","name":"HelloService"},"retries":"0","description":"","child_tasks_local_reference_list":[{"kind":"app_task","name":"Task1"}],"name":"HelloService___delete___dag","attrs":{"edges":[],"type":""},"timeout_secs":"0","type":"DAG","variable_list":[]},{"target_any_local_reference":{"kind":"app_service","name":"HelloService"},"retries":"0","description":"","child_tasks_local_reference_list":[],"name":"Task1","attrs":{"script":"echo 'Service delete in ENV=@@{ENV}@@'","type":"","command_line_args":"","exit_status":[],"script_type":"sh"},"timeout_secs":"0","type":"EXEC","variable_list":[]}],"description":"","name":"HelloService___delete___runbook","main_task_local_reference":{"kind":"app_task","name":"HelloService___delete___dag"},"variable_list":[]},"name":"action_delete"},{"description":"System action for restarting an application","type":"system","critical":true,"runbook":{"task_definition_list":[{"target_any_local_reference":{"kind":"app_service","name":"HelloService"},"retries":"0","description":"","child_tasks_local_reference_list":[],"name":"HelloService___restart___dag","attrs":{"edges":[],"type":""},"timeout_secs":"0","type":"DAG","variable_list":[]}],"description":"","name":"HelloService___restart___runbook","main_task_local_reference":{"kind":"app_task","name":"HelloService___restart___dag"},"variable_list":[]},"name":"action_restart"},{"description":"System action for deleting an application. Does not delete created VMs","type":"system","critical":true,"runbook":{"task_definition_list":[{"target_any_local_reference":{"kind":"app_service","name":"HelloService"},"retries":"0","description":"","child_tasks_local_reference_list":[],"name":"HelloService___soft_delete___dag","attrs":{"edges":[],"type":""},"timeout_secs":"0","type":"DAG","variable_list":[]}],"description":"","name":"HelloService___soft_delete___runbook","main_task_local_reference":{"kind":"app_task","name":"HelloService___soft_delete___dag"},"variable_list":[]},"name":"action_soft_delete"},{"description":"Sample service action","type":"user","critical":false,"runbook":{"task_definition_list":[{"target_any_local_reference":{"kind":"app_service","name":"HelloService"},"retries":"0","description":"","child_tasks_local_reference_list":[{"kind":"app_task","name":"Task11"},{"kind":"app_task","name":"Task12"}],"name":"HelloService_custom_action_1_dag","attrs":{"edges":[{"from_task_reference":{"kind":"app_task","name":"Task11"},"edge_type":"user_defined","type":"","to_task_reference":{"kind":"app_task","name":"Task12"}}],"type":""},"timeout_secs":"0","type":"DAG","variable_list":[]},{"target_any_local_reference":{"kind":"app_service","name":"HelloService"},"retries":"0","description":"","child_tasks_local_reference_list":[],"name":"Task11","attrs":{"script":"echo \"Hello\"","type":"","command_line_args":"","exit_status":[],"script_type":"sh"},"timeout_secs":"0","type":"EXEC","variable_list":[]},{"target_any_local_reference":{"kind":"app_service","name":"HelloService"},"retries":"0","description":"","child_tasks_local_reference_list":[],"name":"Task12","attrs":{"script":"echo \"Hello again\"","type":"","command_line_args":"","exit_status":[],"script_type":"sh"},"timeout_secs":"0","type":"EXEC","variable_list":[]}],"description":"","name":"HelloService_custom_action_1_runbook","main_task_local_reference":{"kind":"app_task","name":"HelloService_custom_action_1_dag"},"variable_list":[]},"name":"custom_action_1"},{"description":"","type":"user","critical":false,"runbook":{"task_definition_list":[{"target_any_local_reference":{"kind":"app_service","name":"HelloService"},"retries":"0","description":"","child_tasks_local_reference_list":[{"kind":"app_task","name":"Task21"},{"kind":"app_task","name":"Task22b"},{"kind":"app_task","name":"Task22a"},{"kind":"app_task","name":"Task23"}],"name":"HelloService_custom_action_2_dag","attrs":{"edges":[{"from_task_reference":{"kind":"app_task","name":"Task21"},"edge_type":"user_defined","type":"","to_task_reference":{"kind":"app_task","name":"Task22a"}},{"from_task_reference":{"kind":"app_task","name":"Task21"},"edge_type":"user_defined","type":"","to_task_reference":{"kind":"app_task","name":"Task22b"}},{"from_task_reference":{"kind":"app_task","name":"Task22a"},"edge_type":"user_defined","type":"","to_task_reference":{"kind":"app_task","name":"Task23"}},{"from_task_reference":{"kind":"app_task","name":"Task22b"},"edge_type":"user_defined","type":"","to_task_reference":{"kind":"app_task","name":"Task23"}}],"type":""},"timeout_secs":"0","type":"DAG","variable_list":[]},{"target_any_local_reference":{"kind":"app_service","name":"HelloService"},"retries":"0","description":"","child_tasks_local_reference_list":[],"name":"Task21","attrs":{"script":"date","type":"","command_line_args":"","exit_status":[],"script_type":"sh"},"timeout_secs":"0","type":"EXEC","variable_list":[]},{"target_any_local_reference":{"kind":"app_service","name":"HelloService"},"retries":"0","description":"","child_tasks_local_reference_list":[],"name":"Task22b","attrs":{"script":"date","type":"","command_line_args":"","exit_status":[],"script_type":"sh"},"timeout_secs":"0","type":"EXEC","variable_list":[]},{"target_any_local_reference":{"kind":"app_service","name":"HelloService"},"retries":"0","description":"","child_tasks_local_reference_list":[],"name":"Task22a","attrs":{"script":"date","type":"","command_line_args":"","exit_status":[],"script_type":"sh"},"timeout_secs":"0","type":"EXEC","variable_list":[]},{"target_any_local_reference":{"kind":"app_service","name":"HelloService"},"retries":"0","description":"","child_tasks_local_reference_list":[],"name":"Task23","attrs":{"script":"date","type":"","command_line_args":"","exit_status":[],"script_type":"sh"},"timeout_secs":"0","type":"EXEC","variable_list":[]}],"description":"","name":"HelloService_custom_action_2_runbook","main_task_local_reference":{"kind":"app_task","name":"HelloService_custom_action_2_dag"},"variable_list":[]},"name":"custom_action_2"}],"depends_on_list":[],"name":"HelloService","port_list":[],"tier":"","variable_list":[{"val_type":"STRING","is_mandatory":true,"description":"","data_type":"BASE","type":"LOCAL","name":"ENV","value":"DEV","label":"","attrs":{"type":""},"editables":{"value":true},"is_hidden":false,"options":{"type":"PREDEFINED","choices":["DEV","PROD"]}}],"description":"Sample Service"}],"substrate_definition_list":[{"description":"AHV VM Substrate","action_list":[{"description":"","type":"fragment","critical":false,"runbook":{"task_definition_list":[{"target_any_local_reference":{"kind":"app_substrate","name":"HelloSubstrate"},"retries":"0","description":"","child_tasks_local_reference_list":[{"kind":"app_task","name":"Task1"}],"name":"HelloSubstrate___pre_create___dag","attrs":{"edges":[],"type":""},"timeout_secs":"0","type":"DAG","variable_list":[]},{"target_any_local_reference":{"kind":"app_substrate","name":"HelloSubstrate"},"retries":"0","description":"","child_tasks_local_reference_list":[],"name":"Task1","attrs":{"script":"print 'Pre Create task runs before VM is created'","type":"","command_line_args":"","exit_status":[],"script_type":"static"},"timeout_secs":"0","type":"EXEC","variable_list":[]}],"description":"","name":"HelloSubstrate___pre_create___runbook","main_task_local_reference":{"kind":"app_task","name":"HelloSubstrate___pre_create___dag"},"variable_list":[]},"name":"pre_action_create"},{"description":"","type":"fragment","critical":false,"runbook":{"task_definition_list":[{"target_any_local_reference":{"kind":"app_substrate","name":"HelloSubstrate"},"retries":"0","description":"","child_tasks_local_reference_list":[{"kind":"app_task","name":"Task1"}],"name":"HelloSubstrate___post_delete___dag","attrs":{"edges":[],"type":""},"timeout_secs":"0","type":"DAG","variable_list":[]},{"target_any_local_reference":{"kind":"app_substrate","name":"HelloSubstrate"},"retries":"0","description":"","child_tasks_local_reference_list":[],"name":"Task1","attrs":{"script":"print 'Post delete task runs after VM is deleted'","type":"","command_line_args":"","exit_status":[],"script_type":"static"},"timeout_secs":"0","type":"EXEC","variable_list":[]}],"description":"","name":"HelloSubstrate___post_delete___runbook","main_task_local_reference":{"kind":"app_task","name":"HelloSubstrate___post_delete___dag"},"variable_list":[]},"name":"post_action_delete"}],"type":"AHV_VM","name":"HelloSubstrate","readiness_probe":{"connection_type":"SSH","retries":"5","connection_protocol":"","connection_port":22,"address":"@@{platform.status.resources.nic_list[0].ip_endpoint_list[0].ip}@@","delay_secs":"60","disable_readiness_probe":true},"os_type":"Linux","create_spec":{"name":"HelloVm","resources":{"nic_list":[{"nic_type":"NORMAL_NIC","vpc_reference":{"kind":"vpc","type":"","name":"Sk_VPC","uuid":"ac050eed-aa6d-4177-a6e4-b4e5a7c1925c"},"ip_endpoint_list":[],"network_function_chain_reference":null,"network_function_nic_type":"INGRESS","mac_address":"","subnet_reference":{"kind":"subnet","type":"","name":"SkSubnet","uuid":"09e70679-eacb-49c4-ab18-38067dd1e2b1"},"type":""}],"serial_port_list":[],"guest_tools":null,"num_vcpus_per_socket":1,"num_sockets":2,"gpu_list":[],"memory_size_mib":4096,"parent_reference":null,"hardware_clock_timezone":"","guest_customization":{"cloud_init":{"meta_data":"","type":"","user_data":"#cloud-config\nusers:\n- name: centos\n ssh-authorized-keys:\n - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDOqtxbVdrDfhCRKlJdUwDnmUY96NIV6MLVcHlBrSYJbkaD3huooCWaDojyk2R4ZYL\/ECbSYfIHlAMxp5yzKgT1m1wVK7J6ZLyszV\/4LduKrfC7W60cdBf1nNDznmcRmfpDJl3Qp2PPc+qW8RTSJkrp02ToQKyOLFPC2e9Nv5Ik00UKZ45wzT8ow0nqbp4pZGxfFNII5dOVwkdTnG1pL0\/yDYNLeNv9RrNObjLRHhouZDUnV6XqtiCPtue83c2OSmKkqS9vnNMCPyfofdD8nWzS7VFPiYwX6oIKSjsL651K4MMcq0O4ihMxZ3Elb0qx5mkBNGqsooufBYyKiwnek2pn\n sudo:\n - ALL=(ALL) NOPASSWD:ALL\n"},"type":"","sysprep":null},"power_state":"ON","type":"","account_uuid":"498726d3-7522-46eb-9c01-a7453e2d6105","boot_config":{"boot_device":{"type":"","disk_address":{"type":"","device_index":0,"adapter_type":"SCSI"}},"type":"","boot_type":"","mac_address":""},"disk_list":[{"data_source_reference":{"kind":"app_package","type":"","name":"centos_disk","uuid":"a077c444-573f-40a9-8cba-1f104087862b"},"type":"","disk_size_mib":0,"volume_group_reference":null,"device_properties":{"type":"","disk_address":{"type":"","device_index":0,"adapter_type":"SCSI"},"device_type":"DISK"}}]},"availability_zone_reference":null,"backup_policy":null,"type":"","cluster_reference":{"kind":"cluster","type":"","name":"auto_cluster_prod_1a619308826b","uuid":"0005cb6b-07a1-71e5-0000-00000002901e"},"categories":{"AppFamily":"Demo","AppType":"Default"}},"variable_list":[]}],"credential_definition_list":[{"username":"centos","description":"","type":"KEY","secret":{"attrs":{"is_secret_modified":true,"secret_reference":{}},"value":"wFCb7Un1bXUVCpHcJmrWI8kZGn9GAZVUFm87u+rUMBhDm75ebrysjtp9x+FbZJ0IZS+HQkhCnMj+oVvv1ZDflOJclhSVcillXOD8Myi03cl\/ummi\/PJWrIrzCjVwmOKJKnnx8RiiSeDEyfSdgVHuE2gIH1XsVBwRLzMbX3YQXRlkNdwRXrLXv0DjAM3hYgROiqhMdJ+Gc7rXZSiCILC3FbbYZMvsg+xUkq4ZrUI\/FY39tRjJY3Y4rkEiG7iZKKzsHGOAOB90+nVqp+TTRk0u4hVedRtXDZbQEbQ9k5gxLLeySGA06lX6D44EToxJG94jg\/hsGY3fZT5bSvi08YhmfwITSwuzSCz\/J1BMTH9ljFR6EKBnRqm\/ypbDmzriUl\/Rq2qlYF5HWtMWxOAip3DSdTyfVUGTMZRRfLR4hDyD38dkrYSS46T+jDQ\/m0XjO8c8h2bRuphxUA3t35P\/bvwP3vVkQJE8NrOGVURJfJuMKPf\/vNQbQ0+0etY8bwivnbUm1IvgsOsywz+6FZyaNCpd9HqXoQHFMihGtvWshalIeSjlsP4\/pM3P\/xzWOgjVloDNkND3pWX9ULx1rCYlQjz4yqPks65KagiUd1+ccepxw5WRLIMstu\/F0G3Y3lluotnPrhSt36r\/trCdFd+Gnn2Z2COQk5laa\/YXmukoVjiwSJfpJMMvt\/DPB\/5zwWLtp\/NbKDeu\/mhX4NALnaNrnXlBPps8hV8nYMCtE+Zb89vUOFRCkxzRKG\/JL6IlXiikc3V1Knpp18HGAnxApskITUHgJpiRDyqQRWsgBfGjFr83T3i5r+FmdqKNOurKruw7B0K6D5Y5VfCXyoQ4UyM+6rC2X6takVjePo+YpQ\/RSC6IrB9cavDrYhorLczcoEsxaCt9tEJh\/utkDOpWsnJ0sbn0nPPexHOtL\/BJ2vIo3yeJjpc8173LzgWsqd\/o6XD\/7JBmstVv2re9JF7f03p6BjTBhNvwOS71K02pTj6bzTd5n4lA4r6Syxjy3BK7jZhO36HruIxELOTdesMByIWSM3ZRzNPQrOd3l\/zquIp7WFbMAUj+J3j2EUaEVTF0XK95kpkHKzD61hPQVC1FQrEhgQVTyFbwTS90gV9jPljXVliDFFHfKLQ7yH2wgD4NcsNI2+kGmBiRA7O5l1WWMbF0DUg2Mc4uMFl4qt8EODMr+Q\/Iioe3WJbFLLiTk7eYWuByJvryBnL5kGOcKPTgImshNZMrKRHt1PkVWTm9n2sjz6kgumeU0ZfUFD1Po+2fUYtwBpEjDSYaAvX8dpavxaSXcrh\/Yo1eQVf1IrsAZCzul134zqLfgsE4mV6o1e\/5C8Bvs1hRL9egUN0rJ\/80pHaC2vwhjL0kcnIPyvyDjyPrAUabporO\/OOof4NG8CsP4\/ZzSbQR17K1w6D2KehzmYIyMvpyaXiPCKc\/wx9i+WO7kD8M19W0\/qhkpK0veSiihVubinxMLbrcBoo1ijvHa3Ph+soJWldfohMcAKVkj23Thwnm1K5J3uvZqmafkL9dxUjszppBh9YG4oGIAq2OFYq0U3tjum4w7sJXBgh2uBXdGRzgSeaevwdWxBMF4qx\/MHeGEbx9VS8Lsp1BqoIuVOHIfCZdUyEMSdjWVGRINLClcWh9AZ2t0jG4aFUI5okW23lniwcD7RYlzvcNQ+tGayo4rHqTVTj4sj7nOLO4ccmLLa93C5fzp+ivMjeKcpXDwx5b2wmk+GELc3NLPXpEL4SusBk2crdmezAARtIwOo8rFkfMU\/Cn0SumdEF7LNflTXmsJMxh0bt6n\/5JqtrpRew2OLPoJ9aNBNCHe7U51+t2wFbP8VHqisbDZwstg3JwWCgcPj8fZ9\/zYpPuSRxPJeJ4Kwrrz64gOSc+mJZeCDa5Q0hxp0f3KhrmUJ17ovGsUBcmTy4qxniWqiIKuRwbqJPc6ud1bUooGK0QvFrt61pFpRWqeMyURnzoqyGWEUq1PjTHIFwHsAamOYCm5jaVtM6rFb7YKyXW3Y3Di61NZAYLjCC9PvLYqJGGKf\/zKcycKAS38VYCn0KXjkHonOHU2N+3wLbiLEABnHRLAJhP0NhutLNFG9PylfHRPtsq\/0RR0jzktn67UEXlr96D0iHHj4YgoDeW0o294Y0GpjTB2FxcFdDudPm3BVyr\/Sn6\/9Axi2YMCx7lRkP0+2oiy8amR9HVNKNIGzAa7nxMQXXM+YUavNYlr0DSzuEohDc\/G2sqNElP0Kw9gwFxB2q+7qMfLKqxVulbdIsEABFd\/qrm9zo=:utf-8"},"name":"Centos","cred_class":"static"}],"package_definition_list":[{"description":"Sample Package","action_list":[],"type":"CUSTOM","service_local_reference_list":[{"kind":"app_service","name":"HelloService"}],"name":"HelloPackage","version":"","options":{"install_runbook":{"task_definition_list":[{"target_any_local_reference":{"kind":"app_service","name":"HelloService"},"retries":"0","description":"","child_tasks_local_reference_list":[{"kind":"app_task","name":"Task1"}],"name":"HelloPackage___install___dag","attrs":{"edges":[],"type":""},"timeout_secs":"0","type":"DAG","variable_list":[]},{"target_any_local_reference":{"kind":"app_service","name":"HelloService"},"retries":"0","description":"","child_tasks_local_reference_list":[],"name":"Task1","attrs":{"script":"#!\/bin\/bash\n\nset -ex\n\necho \"@@{sample_pkg_var}@@\"\n\nsudo yum install epel-release -y\nsudo yum update -y\n\necho \"Package installation steps go here ...\"\n","type":"","command_line_args":"","exit_status":[],"script_type":"sh"},"timeout_secs":"0","type":"EXEC","variable_list":[]}],"description":"","name":"HelloPackage___install___runbook","main_task_local_reference":{"kind":"app_task","name":"HelloPackage___install___dag"},"variable_list":[]},"type":"","uninstall_runbook":{"task_definition_list":[{"target_any_local_reference":{"kind":"app_service","name":"HelloService"},"retries":"0","description":"","child_tasks_local_reference_list":[{"kind":"app_task","name":"Task1"}],"name":"HelloPackage___uninstall___dag","attrs":{"edges":[],"type":""},"timeout_secs":"0","type":"DAG","variable_list":[]},{"target_any_local_reference":{"kind":"app_service","name":"HelloService"},"retries":"0","description":"","child_tasks_local_reference_list":[],"name":"Task1","attrs":{"script":"#!\/bin\/bash\n\nset -ex\n\necho \"Package uninstallation steps go here ...\"\n","type":"","command_line_args":"","exit_status":[],"script_type":"sh"},"timeout_secs":"0","type":"EXEC","variable_list":[]}],"description":"","name":"HelloPackage___uninstall___runbook","main_task_local_reference":{"kind":"app_task","name":"HelloPackage___uninstall___dag"},"variable_list":[]}},"variable_list":[{"val_type":"STRING","is_mandatory":false,"description":"","data_type":"BASE","type":"LOCAL","name":"sample_pkg_var","value":"Sample package installation","label":"","attrs":{"type":""},"is_hidden":false}]},{"description":"","action_list":[],"type":"SUBSTRATE_IMAGE","service_local_reference_list":[],"name":"centos_disk","version":"","options":{"type":"","name":"centos_disk","resources":{"image_type":"DISK_IMAGE","checksum":{"checksum_algorithm":"","type":"","checksum_value":""},"source_uri":"http:\/\/download.nutanix.com\/calm\/CentOS-7-x86_64-1810.qcow2","version":{"product_version":"1.0","type":"","product_name":"centos_disk"},"architecture":"X86_64","type":""},"description":""},"variable_list":[]}],"app_profile_list":[{"deployment_create_list":[{"type":"GREENFIELD","action_list":[],"name":"HelloDeployment","min_replicas":"1","default_replicas":"","depends_on_list":[],"published_service_local_reference_list":[],"max_replicas":"1","package_local_reference_list":[{"kind":"app_package","name":"HelloPackage"}],"substrate_local_reference":{"kind":"app_substrate","name":"HelloSubstrate"},"options":{"type":""},"variable_list":[],"description":"Sample Deployment"}],"environment_reference_list":[],"patch_list":[],"description":"","action_list":[{"description":"Sample description for a profile action","type":"user","critical":false,"runbook":{"task_definition_list":[{"retries":"0","description":"","child_tasks_local_reference_list":[{"kind":"app_task","name":"Task1"},{"kind":"app_task","name":"Task6"}],"name":"HelloProfile_custom_profile_action_1_dag","attrs":{"edges":[{"from_task_reference":{"kind":"app_task","name":"Task1"},"edge_type":"user_defined","type":"","to_task_reference":{"kind":"app_task","name":"Task6"}}],"type":""},"timeout_secs":"0","type":"DAG","variable_list":[]},{"target_any_local_reference":{"kind":"app_service","name":"HelloService"},"retries":"0","description":"","child_tasks_local_reference_list":[],"name":"Task1","attrs":{"script":"echo \"Profile level action using @@{var1}@@ and @@{var2}@@ and @@{var3}@@\"","type":"","command_line_args":"","exit_status":[],"script_type":"sh"},"timeout_secs":"0","type":"EXEC","variable_list":[]},{"target_any_local_reference":{"kind":"app_service","name":"HelloService"},"retries":"0","description":"","child_tasks_local_reference_list":[],"name":"Task6","attrs":{"type":"","inarg_list":[],"runbook_reference":{"kind":"app_runbook","name":"HelloService_custom_action_1_runbook"}},"timeout_secs":"0","type":"CALL_RUNBOOK","variable_list":[]}],"description":"","name":"HelloProfile_custom_profile_action_1_runbook","main_task_local_reference":{"kind":"app_task","name":"HelloProfile_custom_profile_action_1_dag"},"variable_list":[]},"name":"custom_profile_action_1"}],"name":"HelloProfile","restore_config_list":[],"snapshot_config_list":[],"variable_list":[{"val_type":"STRING","is_mandatory":false,"description":"","data_type":"BASE","type":"LOCAL","name":"var1","value":"sample_val1","label":"","attrs":{"type":""},"editables":{"value":true},"is_hidden":false},{"val_type":"STRING","is_mandatory":false,"description":"","data_type":"BASE","type":"LOCAL","name":"var2","value":"sample_val2","label":"","attrs":{"type":""},"editables":{"value":true},"is_hidden":false},{"regex":{"should_validate":true,"value":"^[\\d]*$"},"val_type":"INT","is_mandatory":false,"description":"","data_type":"BASE","type":"LOCAL","name":"var3","value":"2","label":"","attrs":{"type":""},"is_hidden":false}]}],"published_service_definition_list":[],"default_credential_local_reference":{"kind":"app_credential","name":"Centos"},"type":"USER"},"name":"Hello"},"api_version":"3.0","metadata":{"last_update_time":"1634729406663887","kind":"blueprint","spec_version":1,"creation_time":"1634729402763687","name":"Hello"}} +{"status":{},"contains_secrets":true,"product_version":"3.4.0","spec":{"description":"Sample blueprint for Hello app using AHV VM","resources":{"client_attrs":{"None":{"Profile":{"HelloProfile":{"Action":{},"dsl_name":"HelloProfile"}},"Package":{"HelloPackage":{"Action":{},"dsl_name":"HelloPackage"},"centos_disk":{"Action":{},"dsl_name":"centos_disk"}},"Substrate":{"HelloSubstrate":{"Action":{},"AhvVm":{"HelloVm":{"dsl_name":"HelloVm"}},"dsl_name":"HelloSubstrate"}},"Service":{"HelloService":{"Action":{},"dsl_name":"HelloService"}},"Deployment":{"HelloDeployment":{"Action":{},"dsl_name":"HelloDeployment"}}}},"service_definition_list":[{"singleton":false,"action_list":[{"description":"System action for creating an application","type":"system","critical":true,"runbook":{"task_definition_list":[{"target_any_local_reference":{"kind":"app_service","name":"HelloService"},"retries":"0","description":"","child_tasks_local_reference_list":[{"kind":"app_task","name":"Task1"}],"name":"HelloService___create___dag","attrs":{"edges":[],"type":""},"timeout_secs":"0","type":"DAG","variable_list":[]},{"target_any_local_reference":{"kind":"app_service","name":"HelloService"},"retries":"0","description":"","child_tasks_local_reference_list":[],"name":"Task1","attrs":{"script":"echo 'Service create in ENV=@@{ENV}@@'","type":"","command_line_args":"","exit_status":[],"script_type":"sh"},"timeout_secs":"0","type":"EXEC","variable_list":[]}],"description":"","name":"HelloService___create___runbook","main_task_local_reference":{"kind":"app_task","name":"HelloService___create___dag"},"variable_list":[]},"name":"action_create"},{"description":"System action for starting an application","type":"system","critical":true,"runbook":{"task_definition_list":[{"target_any_local_reference":{"kind":"app_service","name":"HelloService"},"retries":"0","description":"","child_tasks_local_reference_list":[{"kind":"app_task","name":"Task1"}],"name":"HelloService___start___dag","attrs":{"edges":[],"type":""},"timeout_secs":"0","type":"DAG","variable_list":[]},{"target_any_local_reference":{"kind":"app_service","name":"HelloService"},"retries":"0","description":"","child_tasks_local_reference_list":[],"name":"Task1","attrs":{"script":"echo 'Service start in ENV=@@{ENV}@@'","type":"","command_line_args":"","exit_status":[],"script_type":"sh"},"timeout_secs":"0","type":"EXEC","variable_list":[]}],"description":"","name":"HelloService___start___runbook","main_task_local_reference":{"kind":"app_task","name":"HelloService___start___dag"},"variable_list":[]},"name":"action_start"},{"description":"System action for stopping an application","type":"system","critical":true,"runbook":{"task_definition_list":[{"target_any_local_reference":{"kind":"app_service","name":"HelloService"},"retries":"0","description":"","child_tasks_local_reference_list":[{"kind":"app_task","name":"Task1"}],"name":"HelloService___stop___dag","attrs":{"edges":[],"type":""},"timeout_secs":"0","type":"DAG","variable_list":[]},{"target_any_local_reference":{"kind":"app_service","name":"HelloService"},"retries":"0","description":"","child_tasks_local_reference_list":[],"name":"Task1","attrs":{"script":"echo 'Service stop in ENV=@@{ENV}@@'","type":"","command_line_args":"","exit_status":[],"script_type":"sh"},"timeout_secs":"0","type":"EXEC","variable_list":[]}],"description":"","name":"HelloService___stop___runbook","main_task_local_reference":{"kind":"app_task","name":"HelloService___stop___dag"},"variable_list":[]},"name":"action_stop"},{"description":"System action for deleting an application. Deletes created VMs as well","type":"system","critical":true,"runbook":{"task_definition_list":[{"target_any_local_reference":{"kind":"app_service","name":"HelloService"},"retries":"0","description":"","child_tasks_local_reference_list":[{"kind":"app_task","name":"Task1"}],"name":"HelloService___delete___dag","attrs":{"edges":[],"type":""},"timeout_secs":"0","type":"DAG","variable_list":[]},{"target_any_local_reference":{"kind":"app_service","name":"HelloService"},"retries":"0","description":"","child_tasks_local_reference_list":[],"name":"Task1","attrs":{"script":"echo 'Service delete in ENV=@@{ENV}@@'","type":"","command_line_args":"","exit_status":[],"script_type":"sh"},"timeout_secs":"0","type":"EXEC","variable_list":[]}],"description":"","name":"HelloService___delete___runbook","main_task_local_reference":{"kind":"app_task","name":"HelloService___delete___dag"},"variable_list":[]},"name":"action_delete"},{"description":"System action for restarting an application","type":"system","critical":true,"runbook":{"task_definition_list":[{"target_any_local_reference":{"kind":"app_service","name":"HelloService"},"retries":"0","description":"","child_tasks_local_reference_list":[],"name":"HelloService___restart___dag","attrs":{"edges":[],"type":""},"timeout_secs":"0","type":"DAG","variable_list":[]}],"description":"","name":"HelloService___restart___runbook","main_task_local_reference":{"kind":"app_task","name":"HelloService___restart___dag"},"variable_list":[]},"name":"action_restart"},{"description":"System action for deleting an application. Does not delete created VMs","type":"system","critical":true,"runbook":{"task_definition_list":[{"target_any_local_reference":{"kind":"app_service","name":"HelloService"},"retries":"0","description":"","child_tasks_local_reference_list":[],"name":"HelloService___soft_delete___dag","attrs":{"edges":[],"type":""},"timeout_secs":"0","type":"DAG","variable_list":[]}],"description":"","name":"HelloService___soft_delete___runbook","main_task_local_reference":{"kind":"app_task","name":"HelloService___soft_delete___dag"},"variable_list":[]},"name":"action_soft_delete"},{"description":"Sample service action","type":"user","critical":false,"runbook":{"task_definition_list":[{"target_any_local_reference":{"kind":"app_service","name":"HelloService"},"retries":"0","description":"","child_tasks_local_reference_list":[{"kind":"app_task","name":"Task11"},{"kind":"app_task","name":"Task12"}],"name":"HelloService_custom_action_1_dag","attrs":{"edges":[{"from_task_reference":{"kind":"app_task","name":"Task11"},"edge_type":"user_defined","type":"","to_task_reference":{"kind":"app_task","name":"Task12"}}],"type":""},"timeout_secs":"0","type":"DAG","variable_list":[]},{"target_any_local_reference":{"kind":"app_service","name":"HelloService"},"retries":"0","description":"","child_tasks_local_reference_list":[],"name":"Task11","attrs":{"script":"echo \"Hello\"","type":"","command_line_args":"","exit_status":[],"script_type":"sh"},"timeout_secs":"0","type":"EXEC","variable_list":[]},{"target_any_local_reference":{"kind":"app_service","name":"HelloService"},"retries":"0","description":"","child_tasks_local_reference_list":[],"name":"Task12","attrs":{"script":"echo \"Hello again\"","type":"","command_line_args":"","exit_status":[],"script_type":"sh"},"timeout_secs":"0","type":"EXEC","variable_list":[]}],"description":"","name":"HelloService_custom_action_1_runbook","main_task_local_reference":{"kind":"app_task","name":"HelloService_custom_action_1_dag"},"variable_list":[]},"name":"custom_action_1"},{"description":"","type":"user","critical":false,"runbook":{"task_definition_list":[{"target_any_local_reference":{"kind":"app_service","name":"HelloService"},"retries":"0","description":"","child_tasks_local_reference_list":[{"kind":"app_task","name":"Task21"},{"kind":"app_task","name":"Task22b"},{"kind":"app_task","name":"Task22a"},{"kind":"app_task","name":"Task23"}],"name":"HelloService_custom_action_2_dag","attrs":{"edges":[{"from_task_reference":{"kind":"app_task","name":"Task21"},"edge_type":"user_defined","type":"","to_task_reference":{"kind":"app_task","name":"Task22a"}},{"from_task_reference":{"kind":"app_task","name":"Task21"},"edge_type":"user_defined","type":"","to_task_reference":{"kind":"app_task","name":"Task22b"}},{"from_task_reference":{"kind":"app_task","name":"Task22a"},"edge_type":"user_defined","type":"","to_task_reference":{"kind":"app_task","name":"Task23"}},{"from_task_reference":{"kind":"app_task","name":"Task22b"},"edge_type":"user_defined","type":"","to_task_reference":{"kind":"app_task","name":"Task23"}}],"type":""},"timeout_secs":"0","type":"DAG","variable_list":[]},{"target_any_local_reference":{"kind":"app_service","name":"HelloService"},"retries":"0","description":"","child_tasks_local_reference_list":[],"name":"Task21","attrs":{"script":"date","type":"","command_line_args":"","exit_status":[],"script_type":"sh"},"timeout_secs":"0","type":"EXEC","variable_list":[]},{"target_any_local_reference":{"kind":"app_service","name":"HelloService"},"retries":"0","description":"","child_tasks_local_reference_list":[],"name":"Task22b","attrs":{"script":"date","type":"","command_line_args":"","exit_status":[],"script_type":"sh"},"timeout_secs":"0","type":"EXEC","variable_list":[]},{"target_any_local_reference":{"kind":"app_service","name":"HelloService"},"retries":"0","description":"","child_tasks_local_reference_list":[],"name":"Task22a","attrs":{"script":"date","type":"","command_line_args":"","exit_status":[],"script_type":"sh"},"timeout_secs":"0","type":"EXEC","variable_list":[]},{"target_any_local_reference":{"kind":"app_service","name":"HelloService"},"retries":"0","description":"","child_tasks_local_reference_list":[],"name":"Task23","attrs":{"script":"date","type":"","command_line_args":"","exit_status":[],"script_type":"sh"},"timeout_secs":"0","type":"EXEC","variable_list":[]}],"description":"","name":"HelloService_custom_action_2_runbook","main_task_local_reference":{"kind":"app_task","name":"HelloService_custom_action_2_dag"},"variable_list":[]},"name":"custom_action_2"}],"depends_on_list":[],"name":"HelloService","port_list":[],"tier":"","variable_list":[{"val_type":"STRING","is_mandatory":true,"description":"","data_type":"BASE","type":"LOCAL","name":"ENV","value":"DEV","label":"","attrs":{"type":""},"editables":{"value":true},"is_hidden":false,"options":{"type":"PREDEFINED","choices":["DEV","PROD"]}}],"description":"Sample Service"}],"substrate_definition_list":[{"description":"AHV VM Substrate","action_list":[{"description":"","type":"fragment","critical":false,"runbook":{"task_definition_list":[{"target_any_local_reference":{"kind":"app_substrate","name":"HelloSubstrate"},"retries":"0","description":"","child_tasks_local_reference_list":[{"kind":"app_task","name":"Task1"}],"name":"HelloSubstrate___pre_create___dag","attrs":{"edges":[],"type":""},"timeout_secs":"0","type":"DAG","variable_list":[]},{"target_any_local_reference":{"kind":"app_substrate","name":"HelloSubstrate"},"retries":"0","description":"","child_tasks_local_reference_list":[],"name":"Task1","attrs":{"script":"print ('Pre Create task runs before VM is created')","type":"","command_line_args":"","exit_status":[],"script_type":"static_py3"},"timeout_secs":"0","type":"EXEC","variable_list":[]}],"description":"","name":"HelloSubstrate___pre_create___runbook","main_task_local_reference":{"kind":"app_task","name":"HelloSubstrate___pre_create___dag"},"variable_list":[]},"name":"pre_action_create"},{"description":"","type":"fragment","critical":false,"runbook":{"task_definition_list":[{"target_any_local_reference":{"kind":"app_substrate","name":"HelloSubstrate"},"retries":"0","description":"","child_tasks_local_reference_list":[{"kind":"app_task","name":"Task1"}],"name":"HelloSubstrate___post_delete___dag","attrs":{"edges":[],"type":""},"timeout_secs":"0","type":"DAG","variable_list":[]},{"target_any_local_reference":{"kind":"app_substrate","name":"HelloSubstrate"},"retries":"0","description":"","child_tasks_local_reference_list":[],"name":"Task1","attrs":{"script":"print ('Post delete task runs after VM is deleted')","type":"","command_line_args":"","exit_status":[],"script_type":"static_py3"},"timeout_secs":"0","type":"EXEC","variable_list":[]}],"description":"","name":"HelloSubstrate___post_delete___runbook","main_task_local_reference":{"kind":"app_task","name":"HelloSubstrate___post_delete___dag"},"variable_list":[]},"name":"post_action_delete"}],"type":"AHV_VM","name":"HelloSubstrate","readiness_probe":{"connection_type":"SSH","retries":"5","connection_protocol":"","connection_port":22,"address":"@@{platform.status.resources.nic_list[0].ip_endpoint_list[0].ip}@@","delay_secs":"60","disable_readiness_probe":true},"os_type":"Linux","create_spec":{"name":"HelloVm","resources":{"nic_list":[{"nic_type":"NORMAL_NIC","vpc_reference":{"kind":"vpc","type":"","name":"Sk_VPC","uuid":"ac050eed-aa6d-4177-a6e4-b4e5a7c1925c"},"ip_endpoint_list":[],"network_function_chain_reference":null,"network_function_nic_type":"INGRESS","mac_address":"","subnet_reference":{"kind":"subnet","type":"","name":"SkSubnet","uuid":"09e70679-eacb-49c4-ab18-38067dd1e2b1"},"type":""}],"serial_port_list":[],"guest_tools":null,"num_vcpus_per_socket":1,"num_sockets":2,"gpu_list":[],"memory_size_mib":4096,"parent_reference":null,"hardware_clock_timezone":"","guest_customization":{"cloud_init":{"meta_data":"","type":"","user_data":"#cloud-config\nusers:\n- name: centos\n ssh-authorized-keys:\n - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDOqtxbVdrDfhCRKlJdUwDnmUY96NIV6MLVcHlBrSYJbkaD3huooCWaDojyk2R4ZYL\/ECbSYfIHlAMxp5yzKgT1m1wVK7J6ZLyszV\/4LduKrfC7W60cdBf1nNDznmcRmfpDJl3Qp2PPc+qW8RTSJkrp02ToQKyOLFPC2e9Nv5Ik00UKZ45wzT8ow0nqbp4pZGxfFNII5dOVwkdTnG1pL0\/yDYNLeNv9RrNObjLRHhouZDUnV6XqtiCPtue83c2OSmKkqS9vnNMCPyfofdD8nWzS7VFPiYwX6oIKSjsL651K4MMcq0O4ihMxZ3Elb0qx5mkBNGqsooufBYyKiwnek2pn\n sudo:\n - ALL=(ALL) NOPASSWD:ALL\n"},"type":"","sysprep":null},"power_state":"ON","type":"","account_uuid":"498726d3-7522-46eb-9c01-a7453e2d6105","boot_config":{"boot_device":{"type":"","disk_address":{"type":"","device_index":0,"adapter_type":"SCSI"}},"type":"","boot_type":"","mac_address":""},"disk_list":[{"data_source_reference":{"kind":"app_package","type":"","name":"centos_disk","uuid":"a077c444-573f-40a9-8cba-1f104087862b"},"type":"","disk_size_mib":0,"volume_group_reference":null,"device_properties":{"type":"","disk_address":{"type":"","device_index":0,"adapter_type":"SCSI"},"device_type":"DISK"}}]},"availability_zone_reference":null,"backup_policy":null,"type":"","cluster_reference":{"kind":"cluster","type":"","name":"auto_cluster_prod_1a619308826b","uuid":"0005cb6b-07a1-71e5-0000-00000002901e"},"categories":{"AppFamily":"Demo","AppType":"Default"}},"variable_list":[]}],"credential_definition_list":[{"username":"centos","description":"","type":"KEY","secret":{"attrs":{"is_secret_modified":true,"secret_reference":{}},"value":"wFCb7Un1bXUVCpHcJmrWI8kZGn9GAZVUFm87u+rUMBhDm75ebrysjtp9x+FbZJ0IZS+HQkhCnMj+oVvv1ZDflOJclhSVcillXOD8Myi03cl\/ummi\/PJWrIrzCjVwmOKJKnnx8RiiSeDEyfSdgVHuE2gIH1XsVBwRLzMbX3YQXRlkNdwRXrLXv0DjAM3hYgROiqhMdJ+Gc7rXZSiCILC3FbbYZMvsg+xUkq4ZrUI\/FY39tRjJY3Y4rkEiG7iZKKzsHGOAOB90+nVqp+TTRk0u4hVedRtXDZbQEbQ9k5gxLLeySGA06lX6D44EToxJG94jg\/hsGY3fZT5bSvi08YhmfwITSwuzSCz\/J1BMTH9ljFR6EKBnRqm\/ypbDmzriUl\/Rq2qlYF5HWtMWxOAip3DSdTyfVUGTMZRRfLR4hDyD38dkrYSS46T+jDQ\/m0XjO8c8h2bRuphxUA3t35P\/bvwP3vVkQJE8NrOGVURJfJuMKPf\/vNQbQ0+0etY8bwivnbUm1IvgsOsywz+6FZyaNCpd9HqXoQHFMihGtvWshalIeSjlsP4\/pM3P\/xzWOgjVloDNkND3pWX9ULx1rCYlQjz4yqPks65KagiUd1+ccepxw5WRLIMstu\/F0G3Y3lluotnPrhSt36r\/trCdFd+Gnn2Z2COQk5laa\/YXmukoVjiwSJfpJMMvt\/DPB\/5zwWLtp\/NbKDeu\/mhX4NALnaNrnXlBPps8hV8nYMCtE+Zb89vUOFRCkxzRKG\/JL6IlXiikc3V1Knpp18HGAnxApskITUHgJpiRDyqQRWsgBfGjFr83T3i5r+FmdqKNOurKruw7B0K6D5Y5VfCXyoQ4UyM+6rC2X6takVjePo+YpQ\/RSC6IrB9cavDrYhorLczcoEsxaCt9tEJh\/utkDOpWsnJ0sbn0nPPexHOtL\/BJ2vIo3yeJjpc8173LzgWsqd\/o6XD\/7JBmstVv2re9JF7f03p6BjTBhNvwOS71K02pTj6bzTd5n4lA4r6Syxjy3BK7jZhO36HruIxELOTdesMByIWSM3ZRzNPQrOd3l\/zquIp7WFbMAUj+J3j2EUaEVTF0XK95kpkHKzD61hPQVC1FQrEhgQVTyFbwTS90gV9jPljXVliDFFHfKLQ7yH2wgD4NcsNI2+kGmBiRA7O5l1WWMbF0DUg2Mc4uMFl4qt8EODMr+Q\/Iioe3WJbFLLiTk7eYWuByJvryBnL5kGOcKPTgImshNZMrKRHt1PkVWTm9n2sjz6kgumeU0ZfUFD1Po+2fUYtwBpEjDSYaAvX8dpavxaSXcrh\/Yo1eQVf1IrsAZCzul134zqLfgsE4mV6o1e\/5C8Bvs1hRL9egUN0rJ\/80pHaC2vwhjL0kcnIPyvyDjyPrAUabporO\/OOof4NG8CsP4\/ZzSbQR17K1w6D2KehzmYIyMvpyaXiPCKc\/wx9i+WO7kD8M19W0\/qhkpK0veSiihVubinxMLbrcBoo1ijvHa3Ph+soJWldfohMcAKVkj23Thwnm1K5J3uvZqmafkL9dxUjszppBh9YG4oGIAq2OFYq0U3tjum4w7sJXBgh2uBXdGRzgSeaevwdWxBMF4qx\/MHeGEbx9VS8Lsp1BqoIuVOHIfCZdUyEMSdjWVGRINLClcWh9AZ2t0jG4aFUI5okW23lniwcD7RYlzvcNQ+tGayo4rHqTVTj4sj7nOLO4ccmLLa93C5fzp+ivMjeKcpXDwx5b2wmk+GELc3NLPXpEL4SusBk2crdmezAARtIwOo8rFkfMU\/Cn0SumdEF7LNflTXmsJMxh0bt6n\/5JqtrpRew2OLPoJ9aNBNCHe7U51+t2wFbP8VHqisbDZwstg3JwWCgcPj8fZ9\/zYpPuSRxPJeJ4Kwrrz64gOSc+mJZeCDa5Q0hxp0f3KhrmUJ17ovGsUBcmTy4qxniWqiIKuRwbqJPc6ud1bUooGK0QvFrt61pFpRWqeMyURnzoqyGWEUq1PjTHIFwHsAamOYCm5jaVtM6rFb7YKyXW3Y3Di61NZAYLjCC9PvLYqJGGKf\/zKcycKAS38VYCn0KXjkHonOHU2N+3wLbiLEABnHRLAJhP0NhutLNFG9PylfHRPtsq\/0RR0jzktn67UEXlr96D0iHHj4YgoDeW0o294Y0GpjTB2FxcFdDudPm3BVyr\/Sn6\/9Axi2YMCx7lRkP0+2oiy8amR9HVNKNIGzAa7nxMQXXM+YUavNYlr0DSzuEohDc\/G2sqNElP0Kw9gwFxB2q+7qMfLKqxVulbdIsEABFd\/qrm9zo=:utf-8"},"name":"Centos","cred_class":"static"}],"package_definition_list":[{"description":"Sample Package","action_list":[],"type":"CUSTOM","service_local_reference_list":[{"kind":"app_service","name":"HelloService"}],"name":"HelloPackage","version":"","options":{"install_runbook":{"task_definition_list":[{"target_any_local_reference":{"kind":"app_service","name":"HelloService"},"retries":"0","description":"","child_tasks_local_reference_list":[{"kind":"app_task","name":"Task1"}],"name":"HelloPackage___install___dag","attrs":{"edges":[],"type":""},"timeout_secs":"0","type":"DAG","variable_list":[]},{"target_any_local_reference":{"kind":"app_service","name":"HelloService"},"retries":"0","description":"","child_tasks_local_reference_list":[],"name":"Task1","attrs":{"script":"#!\/bin\/bash\n\nset -ex\n\necho \"@@{sample_pkg_var}@@\"\n\nsudo yum install epel-release -y\nsudo yum update -y\n\necho \"Package installation steps go here ...\"\n","type":"","command_line_args":"","exit_status":[],"script_type":"sh"},"timeout_secs":"0","type":"EXEC","variable_list":[]}],"description":"","name":"HelloPackage___install___runbook","main_task_local_reference":{"kind":"app_task","name":"HelloPackage___install___dag"},"variable_list":[]},"type":"","uninstall_runbook":{"task_definition_list":[{"target_any_local_reference":{"kind":"app_service","name":"HelloService"},"retries":"0","description":"","child_tasks_local_reference_list":[{"kind":"app_task","name":"Task1"}],"name":"HelloPackage___uninstall___dag","attrs":{"edges":[],"type":""},"timeout_secs":"0","type":"DAG","variable_list":[]},{"target_any_local_reference":{"kind":"app_service","name":"HelloService"},"retries":"0","description":"","child_tasks_local_reference_list":[],"name":"Task1","attrs":{"script":"#!\/bin\/bash\n\nset -ex\n\necho \"Package uninstallation steps go here ...\"\n","type":"","command_line_args":"","exit_status":[],"script_type":"sh"},"timeout_secs":"0","type":"EXEC","variable_list":[]}],"description":"","name":"HelloPackage___uninstall___runbook","main_task_local_reference":{"kind":"app_task","name":"HelloPackage___uninstall___dag"},"variable_list":[]}},"variable_list":[{"val_type":"STRING","is_mandatory":false,"description":"","data_type":"BASE","type":"LOCAL","name":"sample_pkg_var","value":"Sample package installation","label":"","attrs":{"type":""},"is_hidden":false}]},{"description":"","action_list":[],"type":"SUBSTRATE_IMAGE","service_local_reference_list":[],"name":"centos_disk","version":"","options":{"type":"","name":"centos_disk","resources":{"image_type":"DISK_IMAGE","checksum":{"checksum_algorithm":"","type":"","checksum_value":""},"source_uri":"http:\/\/download.nutanix.com\/calm\/CentOS-7-x86_64-1810.qcow2","version":{"product_version":"1.0","type":"","product_name":"centos_disk"},"architecture":"X86_64","type":""},"description":""},"variable_list":[]}],"app_profile_list":[{"deployment_create_list":[{"type":"GREENFIELD","action_list":[],"name":"HelloDeployment","min_replicas":"1","default_replicas":"","depends_on_list":[],"published_service_local_reference_list":[],"max_replicas":"1","package_local_reference_list":[{"kind":"app_package","name":"HelloPackage"}],"substrate_local_reference":{"kind":"app_substrate","name":"HelloSubstrate"},"options":{"type":""},"variable_list":[],"description":"Sample Deployment"}],"environment_reference_list":[],"patch_list":[],"description":"","action_list":[{"description":"Sample description for a profile action","type":"user","critical":false,"runbook":{"task_definition_list":[{"retries":"0","description":"","child_tasks_local_reference_list":[{"kind":"app_task","name":"Task1"},{"kind":"app_task","name":"Task6"}],"name":"HelloProfile_custom_profile_action_1_dag","attrs":{"edges":[{"from_task_reference":{"kind":"app_task","name":"Task1"},"edge_type":"user_defined","type":"","to_task_reference":{"kind":"app_task","name":"Task6"}}],"type":""},"timeout_secs":"0","type":"DAG","variable_list":[]},{"target_any_local_reference":{"kind":"app_service","name":"HelloService"},"retries":"0","description":"","child_tasks_local_reference_list":[],"name":"Task1","attrs":{"script":"echo \"Profile level action using @@{var1}@@ and @@{var2}@@ and @@{var3}@@\"","type":"","command_line_args":"","exit_status":[],"script_type":"sh"},"timeout_secs":"0","type":"EXEC","variable_list":[]},{"target_any_local_reference":{"kind":"app_service","name":"HelloService"},"retries":"0","description":"","child_tasks_local_reference_list":[],"name":"Task6","attrs":{"type":"","inarg_list":[],"runbook_reference":{"kind":"app_runbook","name":"HelloService_custom_action_1_runbook"}},"timeout_secs":"0","type":"CALL_RUNBOOK","variable_list":[]}],"description":"","name":"HelloProfile_custom_profile_action_1_runbook","main_task_local_reference":{"kind":"app_task","name":"HelloProfile_custom_profile_action_1_dag"},"variable_list":[]},"name":"custom_profile_action_1"}],"name":"HelloProfile","restore_config_list":[],"snapshot_config_list":[],"variable_list":[{"val_type":"STRING","is_mandatory":false,"description":"","data_type":"BASE","type":"LOCAL","name":"var1","value":"sample_val1","label":"","attrs":{"type":""},"editables":{"value":true},"is_hidden":false},{"val_type":"STRING","is_mandatory":false,"description":"","data_type":"BASE","type":"LOCAL","name":"var2","value":"sample_val2","label":"","attrs":{"type":""},"editables":{"value":true},"is_hidden":false},{"regex":{"should_validate":true,"value":"^[\\d]*$"},"val_type":"INT","is_mandatory":false,"description":"","data_type":"BASE","type":"LOCAL","name":"var3","value":"2","label":"","attrs":{"type":""},"is_hidden":false}]}],"published_service_definition_list":[],"default_credential_local_reference":{"kind":"app_credential","name":"Centos"},"type":"USER"},"name":"Hello"},"api_version":"3.0","metadata":{"last_update_time":"1634729406663887","kind":"blueprint","spec_version":1,"creation_time":"1634729402763687","name":"Hello"}} diff --git a/metadata.json b/metadata.json index 27cee2fbc..222461b93 100644 --- a/metadata.json +++ b/metadata.json @@ -1,3 +1,3 @@ { - "version": "3.7.2.1" + "version": "3.8.0" } \ No newline at end of file diff --git a/release-notes/3.8.0/README.md b/release-notes/3.8.0/README.md new file mode 100644 index 000000000..03f0a4478 --- /dev/null +++ b/release-notes/3.8.0/README.md @@ -0,0 +1,20 @@ + +# Major Feats + +1. Added support to create python remote tasks that runs python script on remote machines, similar to ssh and powershell tasks. Use EXEC, SET_VARIABLE and DECISION class to make these remote python tasks. + + - `CalmTask.Exec.python(name="python_exec", filename=os.path.join("scripts", "escript_exec.py"), target=IPEndpoint)` + - `CalmTask.SetVariable.python(name="python_exec", filename=os.path.join("scripts", "set_variable.py"), target=IPEndpoint)` + - `CalmTask.Decision.python(name="python_exec", filename=os.path.join("scripts", "decision_script.py"), target=IPEndpoint)` + + +# Bug Fixes/Improvements + +- **`Python 2 escripts will be deprecated from DSL v3.8.0 onwards.`** +- Default flow of escript is changed from python 2 to python 3 i.e. `CalmTask.Exec.escript, RunbookTask.Exec.escript, RunbookTask.Decision.escript, CalmTask.SetVariable.escript` will now point to python3 escripts. +- Migration support to upgrade python2 patch/update config tasks to python3 using command - `calm update app-migratable-bp` +- Delete orphan app of older tunnel post reset of tunnel VM using command - `calm reset network-group-tunnel-vm` +- Add ACP for Self Owned Access of report_config for project admin and acp for distributed_virtual_switch, recovery_point for all users in project. +- Moved user and user group to project scope. + + diff --git a/release_config.json b/release_config.json index 50e37ac8d..719fc5149 100644 --- a/release_config.json +++ b/release_config.json @@ -2,7 +2,7 @@ "releases": [ { "product": "calm-dsl", - "version": "3.7.2.1", + "version": "3.8.0", "exclude": [ "" ], diff --git a/tests/3_2_0/blueprints/vm_blueprints/blueprint.py b/tests/3_2_0/blueprints/vm_blueprints/blueprint.py index 06ce622e1..9e4385ae9 100644 --- a/tests/3_2_0/blueprints/vm_blueprints/blueprint.py +++ b/tests/3_2_0/blueprints/vm_blueprints/blueprint.py @@ -81,7 +81,7 @@ def __install__(): @action def __pre_create__(): - Task.Exec.escript(name="Pre Create Task", script="print 'Hello!'") + Task.Exec.escript.py3(name="Pre Create Task", script="print ('Hello!')") @action def test_profile_action(): diff --git a/tests/ahv_vm_overlay_subnet/testDSLDecompileBlueprint/blueprint.py b/tests/ahv_vm_overlay_subnet/testDSLDecompileBlueprint/blueprint.py index 88ac08561..6f9a5530d 100644 --- a/tests/ahv_vm_overlay_subnet/testDSLDecompileBlueprint/blueprint.py +++ b/tests/ahv_vm_overlay_subnet/testDSLDecompileBlueprint/blueprint.py @@ -102,7 +102,7 @@ def TestProfileAction(): target=ref(Service1), tunnel=Ref.Tunnel(name="NewNetworkGroupTunnel2"), ) - CalmTask.SetVariable.escript( + CalmTask.SetVariable.escript.py3( name="SetVariableTaskWithTunnel", filename=os.path.join( "scripts", @@ -112,7 +112,7 @@ def TestProfileAction(): variables=["var1"], tunnel=Ref.Tunnel(name="NewNetworkGroupTunnel2"), ) - CalmTask.Exec.escript( + CalmTask.Exec.escript.py3( name="Task3", filename=os.path.join( "scripts", "Profile_Default_Action_TestProfileAction_Task_Task3.py" diff --git a/tests/ahv_vm_overlay_subnet/test_overlay_subnet_blueprint.json b/tests/ahv_vm_overlay_subnet/test_overlay_subnet_blueprint.json index eece0c0bd..cc04b64ec 100644 --- a/tests/ahv_vm_overlay_subnet/test_overlay_subnet_blueprint.json +++ b/tests/ahv_vm_overlay_subnet/test_overlay_subnet_blueprint.json @@ -519,8 +519,8 @@ "name": "HelloSubstrate" }, "attrs": { - "script_type": "static", - "script": "print 'Pre Create task runs before VM is created'" + "script_type": "static_py3", + "script": "print ('Pre Create task runs before VM is created')" }, "child_tasks_local_reference_list": [], "variable_list": [], @@ -574,8 +574,8 @@ "name": "HelloSubstrate" }, "attrs": { - "script_type": "static", - "script": "print 'Post delete task runs after VM is deleted'" + "script_type": "static_py3", + "script": "print ('Post delete task runs after VM is deleted')" }, "child_tasks_local_reference_list": [], "variable_list": [], diff --git a/tests/ahv_vm_overlay_subnet/test_overlay_subnet_blueprint.py b/tests/ahv_vm_overlay_subnet/test_overlay_subnet_blueprint.py index c76c39a2c..88f6523ab 100644 --- a/tests/ahv_vm_overlay_subnet/test_overlay_subnet_blueprint.py +++ b/tests/ahv_vm_overlay_subnet/test_overlay_subnet_blueprint.py @@ -103,16 +103,16 @@ class HelloSubstrate(Substrate): def __pre_create__(): # Step 1 - Task.Exec.escript( - name="Task1", script="print 'Pre Create task runs before VM is created'" + Task.Exec.escript.py3( + name="Task1", script="print ('Pre Create task runs before VM is created')" ) @action def __post_delete__(): # Step 1 - Task.Exec.escript( - name="Task1", script="print 'Post delete task runs after VM is deleted'" + Task.Exec.escript.py3( + name="Task1", script="print ('Post delete task runs after VM is deleted')" ) diff --git a/tests/api_interface/entity_spec/existing_vm_bp.py b/tests/api_interface/entity_spec/existing_vm_bp.py index a72c74be1..e3655c2ca 100644 --- a/tests/api_interface/entity_spec/existing_vm_bp.py +++ b/tests/api_interface/entity_spec/existing_vm_bp.py @@ -91,7 +91,7 @@ class ExistingVM(Substrate): @action def __pre_create__(): - CalmTask.Exec.escript(name="Pre Create Task", script="print 'Hello!'") + CalmTask.Exec.escript.py3(name="Pre Create Task", script="print ('Hello!')") class LampDeployment(Deployment): @@ -166,11 +166,11 @@ def test_profile_action(): name="Test HTTP Task", target=ref(MySQLService), ) - CalmTask.Exec.escript( - "print 'Hello World!'", name="Test Escript", target=ref(MySQLService) + CalmTask.Exec.escript.py3( + "print ('Hello World!')", name="Test Escript", target=ref(MySQLService) ) - CalmTask.SetVariable.escript( - script="print 'var1=test'", + CalmTask.SetVariable.escript.py3( + script="print ('var1=test')", name="Test Setvar Escript", variables=["var1"], target=ref(MySQLService), diff --git a/tests/blueprint_example/test_blueprint_example.py b/tests/blueprint_example/test_blueprint_example.py index 44b989b5e..efe4ff090 100644 --- a/tests/blueprint_example/test_blueprint_example.py +++ b/tests/blueprint_example/test_blueprint_example.py @@ -80,8 +80,8 @@ class ExistingVM(Substrate): @action def __pre_create__(): - CalmTask.Exec.escript( - name="Pre Create Task", script="print 'Pre Create task for ExistingVM'" + CalmTask.Exec.escript.py3( + name="Pre Create Task", script="print ('Pre Create task for ExistingVM')" ) diff --git a/tests/decompile/test_decompile.py b/tests/decompile/test_decompile.py index 782a9bf4a..e6859479d 100644 --- a/tests/decompile/test_decompile.py +++ b/tests/decompile/test_decompile.py @@ -116,7 +116,7 @@ class AHVVMforMySQL(Substrate): @action def __pre_create__(): - CalmTask.SetVariable.escript( + CalmTask.SetVariable.escript.py3( name="Pre_create task1", script='nic_var={"uuid": "eab99eb7-302f-4e1a-a1a4-5cc901fb9259"}', target=ref(AHVVMforMySQL), @@ -222,11 +222,11 @@ def test_profile_action(name="test profile action"): ) PHPService.test_action(name="Call Runbook Task") with parallel: - CalmTask.Exec.escript( - "print 'Hello World!'", name="Test Escript", target=ref(MySQLService) + CalmTask.Exec.escript.py3( + "print ('Hello World!')", name="Test Escript", target=ref(MySQLService) ) - CalmTask.SetVariable.escript( - script="print 'var1=test'", + CalmTask.SetVariable.escript.py3( + script="print ('var1=test')", name="Test Setvar Escript", variables=["var1"], target=ref(MySQLService), diff --git a/tests/decompile/test_task_tree_bp.py b/tests/decompile/test_task_tree_bp.py index e007ab271..2cd284286 100644 --- a/tests/decompile/test_task_tree_bp.py +++ b/tests/decompile/test_task_tree_bp.py @@ -70,38 +70,38 @@ def __uninstall__(): with parallel() as p0: with branch(p0): - CalmTask.Exec.escript( + CalmTask.Exec.escript.py3( name="Task1", - script="print 'Task1'", + script="print ('Task1')", target=ref(Service1), ) with parallel() as p1: with branch(p1): - CalmTask.Exec.escript( + CalmTask.Exec.escript.py3( name="Task1_1", - script="print 'Task1_1'", + script="print ('Task1_1')", target=ref(Service1), ) with branch(p1): - CalmTask.Exec.escript( + CalmTask.Exec.escript.py3( name="Task1_2", - script="print 'Task1_2'", + script="print ('Task1_2')", target=ref(Service1), ) with branch(p0): - CalmTask.Exec.escript( + CalmTask.Exec.escript.py3( name="Task2", - script="print 'Task2'", + script="print ('Task2')", target=ref(Service1), ) - CalmTask.Exec.escript( + CalmTask.Exec.escript.py3( name="Task2_1", - script="print 'Task2_1'", + script="print ('Task2_1')", target=ref(Service1), ) diff --git a/tests/dynamic_creds/test_credential_bp.py b/tests/dynamic_creds/test_credential_bp.py index ff88de846..4867f03aa 100644 --- a/tests/dynamic_creds/test_credential_bp.py +++ b/tests/dynamic_creds/test_credential_bp.py @@ -84,8 +84,8 @@ class ExistingVM(Substrate): @action def __pre_create__(): - CalmTask.Exec.escript( - name="Pre Create Task", script="print 'Pre Create task for ExistingVM'" + CalmTask.Exec.escript.py3( + name="Pre Create Task", script="print ('Pre Create task for ExistingVM')" ) diff --git a/tests/escript/scripts/escript1.py b/tests/escript/scripts/escript1.py deleted file mode 100644 index 37fb02129..000000000 --- a/tests/escript/scripts/escript1.py +++ /dev/null @@ -1,12 +0,0 @@ -# python2;success -print "python2" -output = urlreq("https://pypi.org/pypi/sampleproject/json", verb="GET") -author_email = output.json()['info']['author_email'] - -pprint(author_email) - -pprint(pformat(author_email)) - -import requests -req_out = requests.get("https://pypi.org/pypi/sampleproject/json") -print req_out.text == output.text diff --git a/tests/escript/scripts/escript1.py.out b/tests/escript/scripts/escript1.py.out deleted file mode 100644 index 87221d228..000000000 --- a/tests/escript/scripts/escript1.py.out +++ /dev/null @@ -1,4 +0,0 @@ -python2 -u'"A. Random Developer" ' -'u\'"A. Random Developer" \'' -True diff --git a/tests/escript/scripts/escript2.py b/tests/escript/scripts/escript2.py deleted file mode 100644 index 971119ad2..000000000 --- a/tests/escript/scripts/escript2.py +++ /dev/null @@ -1,8 +0,0 @@ -# python2;success - -print uuid.uuid4() == uuid.uuid4() - -val = """number: 3.14 -string: !!str 3.14 -""" -pprint(yaml.safe_load(val)) diff --git a/tests/escript/scripts/escript2.py.out b/tests/escript/scripts/escript2.py.out deleted file mode 100644 index 713aa5234..000000000 --- a/tests/escript/scripts/escript2.py.out +++ /dev/null @@ -1,2 +0,0 @@ -False -{'number': 3.14, 'string': '3.14'} diff --git a/tests/escript/scripts/escript3.py b/tests/escript/scripts/escript3.py deleted file mode 100644 index a1b2f1243..000000000 --- a/tests/escript/scripts/escript3.py +++ /dev/null @@ -1,19 +0,0 @@ -# python2;success - -import boto3 -from google.oauth2 import service_account -tn = telnet.Telnet('www.redhat.com', 80) -print tn.read_eager() - -xml_val = """ - -Belgian Waffles -$5.95 -Two of our famous Belgian Waffles with plenty of real maple syrup -650 - - -""" -xml_root=xml.etree.ElementTree.fromstring(xml_val) -for i in range(1): - print "cost of",xml_root[i][0].text,"is",xml_root[i][1].text,"with",xml_root[i][3].text,"calories" diff --git a/tests/escript/scripts/escript3.py.out b/tests/escript/scripts/escript3.py.out deleted file mode 100644 index b6edb0f86..000000000 --- a/tests/escript/scripts/escript3.py.out +++ /dev/null @@ -1,2 +0,0 @@ - -cost of Belgian Waffles is $5.95 with 650 calories diff --git a/tests/escript/scripts/escript_z6.py b/tests/escript/scripts/escript_z6.py index f0007d692..13757f0fc 100644 --- a/tests/escript/scripts/escript_z6.py +++ b/tests/escript/scripts/escript_z6.py @@ -1,2 +1,2 @@ -# python2;failure +# python3;failure pnt diff --git a/tests/escript/scripts/escript_z6.py.out b/tests/escript/scripts/escript_z6.py.out index 90eb81054..29b5e6bd1 100644 --- a/tests/escript/scripts/escript_z6.py.out +++ b/tests/escript/scripts/escript_z6.py.out @@ -1 +1 @@ -Error at line 3> name 'pnt' is not defined +Error in script: name 'pnt' is not defined diff --git a/tests/escript/scripts/parallel_escript_py2.py b/tests/escript/scripts/parallel_escript_py2.py deleted file mode 100644 index 206d77e87..000000000 --- a/tests/escript/scripts/parallel_escript_py2.py +++ /dev/null @@ -1,2 +0,0 @@ -# python2;success;30 -print "just printing..." diff --git a/tests/escript/scripts/parallel_escript_py2.py.out b/tests/escript/scripts/parallel_escript_py2.py.out deleted file mode 100644 index 2a12b6bf9..000000000 --- a/tests/escript/scripts/parallel_escript_py2.py.out +++ /dev/null @@ -1 +0,0 @@ -just printing... diff --git a/tests/escript/test_parallel_escript.py b/tests/escript/test_parallel_escript.py index f400ea544..0d14cb084 100644 --- a/tests/escript/test_parallel_escript.py +++ b/tests/escript/test_parallel_escript.py @@ -87,10 +87,7 @@ def get_escript_version_status(escript): class TestEscript: @pytest.mark.parametrize( "escript, parallel_count", - [ - pytest.param("parallel_escript_py3.py", 60), - pytest.param("parallel_escript_py2.py", 60), - ], + [pytest.param("parallel_escript_py3.py", 60)], ) def test_run_parallel_escript_via_runbook(self, escript, parallel_count): """ diff --git a/tests/existing_vm_example/test_existing_vm_bp.json b/tests/existing_vm_example/test_existing_vm_bp.json index a66b55d02..1006eb85c 100644 --- a/tests/existing_vm_example/test_existing_vm_bp.json +++ b/tests/existing_vm_example/test_existing_vm_bp.json @@ -853,8 +853,8 @@ "name": "ExistingVM" }, "attrs": { - "script_type": "static", - "script": "print 'Hello!'" + "script_type": "static_py3", + "script": "print ('Hello!')" }, "child_tasks_local_reference_list": [], "variable_list": [], @@ -1510,8 +1510,8 @@ "options": { "type": "EXEC", "attrs": { - "script_type": "static", - "script": "print '0'", + "script_type": "static_py3", + "script": "print ('0')", "type": "EXEC" } }, @@ -1537,8 +1537,8 @@ "options": { "type": "EXEC", "attrs": { - "script_type": "static", - "script": "print '30/02/2019'", + "script_type": "static_py3", + "script": "print ('30/02/2019')", "type": "EXEC" } }, @@ -1564,8 +1564,8 @@ "options": { "type": "EXEC", "attrs": { - "script_type": "static", - "script": "print '22:35:00'", + "script_type": "static_py3", + "script": "print ('22:35:00')", "type": "EXEC" } }, @@ -1591,8 +1591,8 @@ "options": { "type": "EXEC", "attrs": { - "script_type": "static", - "script": "print '30/02/2019 - 22:35:00'", + "script_type": "static_py3", + "script": "print ('30/02/2019 - 22:35:00')", "type": "EXEC" } }, @@ -1614,8 +1614,8 @@ "options": { "type": "EXEC", "attrs": { - "script_type": "static", - "script": "print 'x\ny'", + "script_type": "static_py3", + "script": "print ('x\ny')", "type": "EXEC" } }, @@ -1681,8 +1681,8 @@ "options": { "type": "EXEC", "attrs": { - "script_type": "static", - "script": "print '0,1'", + "script_type": "static_py3", + "script": "print ('0,1')", "type": "EXEC" } }, @@ -1708,8 +1708,8 @@ "options": { "type": "EXEC", "attrs": { - "script_type": "static", - "script": "print '30/02/2019,31/06/2019'", + "script_type": "static_py3", + "script": "print ('30/02/2019,31/06/2019')", "type": "EXEC" } }, @@ -1735,8 +1735,8 @@ "options": { "type": "EXEC", "attrs": { - "script_type": "static", - "script": "print '22:35:00,10:35:00'", + "script_type": "static_py3", + "script": "print ('22:35:00,10:35:00')", "type": "EXEC" } }, @@ -1762,8 +1762,8 @@ "options": { "type": "EXEC", "attrs": { - "script_type": "static", - "script": "print '30/02/2019 - 22:35:00,31/06/2019 - 10:35:00'", + "script_type": "static_py3", + "script": "print ('30/02/2019 - 22:35:00,31/06/2019 - 10:35:00')", "type": "EXEC" } }, @@ -1785,8 +1785,8 @@ "options": { "type": "EXEC", "attrs": { - "script_type": "static", - "script": "print 'var36=x\ny,a\nb'", + "script_type": "static_py3", + "script": "print ('var36=x\ny,a\nb')", "type": "EXEC" } }, @@ -2354,8 +2354,8 @@ "name": "MySQLService" }, "attrs": { - "script_type": "static", - "script": "print 'Hello World!'" + "script_type": "static_py3", + "script": "print ('Hello World!')" }, "child_tasks_local_reference_list": [], "variable_list": [], @@ -2371,8 +2371,8 @@ "name": "MySQLService" }, "attrs": { - "script_type": "static", - "script": "print 'var1=test'", + "script_type": "static_py3", + "script": "print ('var1=test')", "eval_variables": [ "var1" ] diff --git a/tests/existing_vm_example/test_existing_vm_bp.py b/tests/existing_vm_example/test_existing_vm_bp.py index 1813a7565..336c05efc 100644 --- a/tests/existing_vm_example/test_existing_vm_bp.py +++ b/tests/existing_vm_example/test_existing_vm_bp.py @@ -101,7 +101,7 @@ class ExistingVM(Substrate): @action def __pre_create__(): - CalmTask.Exec.escript(name="Pre Create Task", script="print 'Hello!'") + CalmTask.Exec.escript.py3(name="Pre Create Task", script="print ('Hello!')") class LampDeployment(Deployment): @@ -303,31 +303,31 @@ class DefaultProfile(Profile): description="var25 description", ) var26 = CalmVariable.WithOptions.FromTask.int( - CalmTask.Exec.escript(script="print '0'"), + CalmTask.Exec.escript.py3(script="print ('0')"), label="var26_label", validate_regex=True, description="var26 description", ) var27 = CalmVariable.WithOptions.FromTask.date( - CalmTask.Exec.escript(script="print '30/02/2019'"), + CalmTask.Exec.escript.py3(script="print ('30/02/2019')"), label="var27_label", validate_regex=True, description="var27 description", ) var28 = CalmVariable.WithOptions.FromTask.time( - CalmTask.Exec.escript(script="print '22:35:00'"), + CalmTask.Exec.escript.py3(script="print ('22:35:00')"), label="var28_label", validate_regex=True, description="var28 description", ) var29 = CalmVariable.WithOptions.FromTask.datetime( - CalmTask.Exec.escript(script="print '30/02/2019 - 22:35:00'"), + CalmTask.Exec.escript.py3(script="print ('30/02/2019 - 22:35:00')"), label="var29_label", validate_regex=True, description="var29 description", ) var30 = CalmVariable.WithOptions.FromTask.multiline( - CalmTask.Exec.escript(script="print 'x\ny'"), + CalmTask.Exec.escript.py3(script="print ('x\ny')"), label="var30_label", description="var30 description", ) @@ -346,33 +346,33 @@ class DefaultProfile(Profile): description="var31 description", ) var32 = CalmVariable.WithOptions.FromTask.Array.int( - CalmTask.Exec.escript(script="print '0,1'"), + CalmTask.Exec.escript.py3(script="print ('0,1')"), label="var32_label", validate_regex=True, description="var32 description", ) var33 = CalmVariable.WithOptions.FromTask.Array.date( - CalmTask.Exec.escript(script="print '30/02/2019,31/06/2019'"), + CalmTask.Exec.escript.py3(script="print ('30/02/2019,31/06/2019')"), label="var33_label", validate_regex=True, description="var33 description", ) var34 = CalmVariable.WithOptions.FromTask.Array.time( - CalmTask.Exec.escript(script="print '22:35:00,10:35:00'"), + CalmTask.Exec.escript.py3(script="print ('22:35:00,10:35:00')"), label="var28_label", validate_regex=True, description="var34 description", ) var35 = CalmVariable.WithOptions.FromTask.Array.datetime( - CalmTask.Exec.escript( - script="print '30/02/2019 - 22:35:00,31/06/2019 - 10:35:00'" + CalmTask.Exec.escript.py3( + script="print ('30/02/2019 - 22:35:00,31/06/2019 - 10:35:00')" ), label="var35_label", validate_regex=True, description="var35 description", ) var36 = CalmVariable.WithOptions.FromTask.Array.multiline( - CalmTask.Exec.escript(script="print 'var36=x\ny,a\nb'"), + CalmTask.Exec.escript.py3(script="print ('var36=x\ny,a\nb')"), label="var36_label", description="var36 description", ) @@ -458,11 +458,11 @@ def test_profile_action(): CalmTask.Delay(delay_seconds=60, target=ref(MySQLService), name="Delay") CalmTask.Scaling.scale_in(1, target=LampDeployment, name="Scale in Lamp") with parallel(): - CalmTask.Exec.escript( - "print 'Hello World!'", name="Test Escript", target=ref(MySQLService) + CalmTask.Exec.escript.py3( + "print ('Hello World!')", name="Test Escript", target=ref(MySQLService) ) - CalmTask.SetVariable.escript( - script="print 'var1=test'", + CalmTask.SetVariable.escript.py3( + script="print ('var1=test')", name="Test Setvar Escript", variables=["var1"], target=ref(MySQLService), diff --git a/tests/existing_vm_example_with_target_endpoint/test_existing_vm_bp.json b/tests/existing_vm_example_with_target_endpoint/test_existing_vm_bp.json index 324920ae5..fe15d0152 100644 --- a/tests/existing_vm_example_with_target_endpoint/test_existing_vm_bp.json +++ b/tests/existing_vm_example_with_target_endpoint/test_existing_vm_bp.json @@ -868,8 +868,8 @@ "name": "ExistingVM" }, "attrs": { - "script_type": "static", - "script": "print 'Hello!'" + "script_type": "static_py3", + "script": "print ('Hello!')" }, "child_tasks_local_reference_list": [], "variable_list": [], @@ -1545,8 +1545,8 @@ "options": { "type": "EXEC", "attrs": { - "script_type": "static", - "script": "print '0'", + "script_type": "static_py3", + "script": "print ('0')", "type": "EXEC" } }, @@ -1572,8 +1572,8 @@ "options": { "type": "EXEC", "attrs": { - "script_type": "static", - "script": "print '30/02/2019'", + "script_type": "static_py3", + "script": "print ('30/02/2019')", "type": "EXEC" } }, @@ -1599,8 +1599,8 @@ "options": { "type": "EXEC", "attrs": { - "script_type": "static", - "script": "print '22:35:00'", + "script_type": "static_py3", + "script": "print ('22:35:00')", "type": "EXEC" } }, @@ -1626,8 +1626,8 @@ "options": { "type": "EXEC", "attrs": { - "script_type": "static", - "script": "print '30/02/2019 - 22:35:00'", + "script_type": "static_py3", + "script": "print ('30/02/2019 - 22:35:00')", "type": "EXEC" } }, @@ -1649,8 +1649,8 @@ "options": { "type": "EXEC", "attrs": { - "script_type": "static", - "script": "print 'x\ny'", + "script_type": "static_py3", + "script": "print ('x\ny')", "type": "EXEC" } }, @@ -1716,8 +1716,8 @@ "options": { "type": "EXEC", "attrs": { - "script_type": "static", - "script": "print '0,1'", + "script_type": "static_py3", + "script": "print ('0,1')", "type": "EXEC" } }, @@ -1743,8 +1743,8 @@ "options": { "type": "EXEC", "attrs": { - "script_type": "static", - "script": "print '30/02/2019,31/06/2019'", + "script_type": "static_py3", + "script": "print ('30/02/2019,31/06/2019')", "type": "EXEC" } }, @@ -1770,8 +1770,8 @@ "options": { "type": "EXEC", "attrs": { - "script_type": "static", - "script": "print '22:35:00,10:35:00'", + "script_type": "static_py3", + "script": "print ('22:35:00,10:35:00')", "type": "EXEC" } }, @@ -1797,8 +1797,8 @@ "options": { "type": "EXEC", "attrs": { - "script_type": "static", - "script": "print '30/02/2019 - 22:35:00,31/06/2019 - 10:35:00'", + "script_type": "static_py3", + "script": "print ('30/02/2019 - 22:35:00,31/06/2019 - 10:35:00')", "type": "EXEC" } }, @@ -1820,8 +1820,8 @@ "options": { "type": "EXEC", "attrs": { - "script_type": "static", - "script": "print 'var36=x\ny,a\nb'", + "script_type": "static_py3", + "script": "print ('var36=x\ny,a\nb')", "type": "EXEC" } }, @@ -2359,8 +2359,8 @@ "name": "MySQLService" }, "attrs": { - "script_type": "static", - "script": "print 'Hello World!'" + "script_type": "static_py3", + "script": "print ('Hello World!')" }, "child_tasks_local_reference_list": [], "variable_list": [], @@ -2376,8 +2376,8 @@ "name": "MySQLService" }, "attrs": { - "script_type": "static", - "script": "print 'var1=test'", + "script_type": "static_py3", + "script": "print ('var1=test')", "eval_variables": [ "var1" ] diff --git a/tests/existing_vm_example_with_target_endpoint/test_existing_vm_bp_with_endpoint_target_task.py b/tests/existing_vm_example_with_target_endpoint/test_existing_vm_bp_with_endpoint_target_task.py index d4794a22a..cf7f2fecb 100644 --- a/tests/existing_vm_example_with_target_endpoint/test_existing_vm_bp_with_endpoint_target_task.py +++ b/tests/existing_vm_example_with_target_endpoint/test_existing_vm_bp_with_endpoint_target_task.py @@ -101,7 +101,7 @@ class ExistingVM(Substrate): @action def __pre_create__(): - CalmTask.Exec.escript(name="Pre Create Task", script="print 'Hello!'") + CalmTask.Exec.escript.py3(name="Pre Create Task", script="print ('Hello!')") CalmTask.Exec.ssh( name="Pre Create on Target Endpoint", filename="scripts/sample_script.sh", @@ -308,31 +308,31 @@ class DefaultProfile(Profile): description="var25 description", ) var26 = CalmVariable.WithOptions.FromTask.int( - CalmTask.Exec.escript(script="print '0'"), + CalmTask.Exec.escript.py3(script="print ('0')"), label="var26_label", validate_regex=True, description="var26 description", ) var27 = CalmVariable.WithOptions.FromTask.date( - CalmTask.Exec.escript(script="print '30/02/2019'"), + CalmTask.Exec.escript.py3(script="print ('30/02/2019')"), label="var27_label", validate_regex=True, description="var27 description", ) var28 = CalmVariable.WithOptions.FromTask.time( - CalmTask.Exec.escript(script="print '22:35:00'"), + CalmTask.Exec.escript.py3(script="print ('22:35:00')"), label="var28_label", validate_regex=True, description="var28 description", ) var29 = CalmVariable.WithOptions.FromTask.datetime( - CalmTask.Exec.escript(script="print '30/02/2019 - 22:35:00'"), + CalmTask.Exec.escript.py3(script="print ('30/02/2019 - 22:35:00')"), label="var29_label", validate_regex=True, description="var29 description", ) var30 = CalmVariable.WithOptions.FromTask.multiline( - CalmTask.Exec.escript(script="print 'x\ny'"), + CalmTask.Exec.escript.py3(script="print ('x\ny')"), label="var30_label", description="var30 description", ) @@ -351,33 +351,33 @@ class DefaultProfile(Profile): description="var31 description", ) var32 = CalmVariable.WithOptions.FromTask.Array.int( - CalmTask.Exec.escript(script="print '0,1'"), + CalmTask.Exec.escript.py3(script="print ('0,1')"), label="var32_label", validate_regex=True, description="var32 description", ) var33 = CalmVariable.WithOptions.FromTask.Array.date( - CalmTask.Exec.escript(script="print '30/02/2019,31/06/2019'"), + CalmTask.Exec.escript.py3(script="print ('30/02/2019,31/06/2019')"), label="var33_label", validate_regex=True, description="var33 description", ) var34 = CalmVariable.WithOptions.FromTask.Array.time( - CalmTask.Exec.escript(script="print '22:35:00,10:35:00'"), + CalmTask.Exec.escript.py3(script="print ('22:35:00,10:35:00')"), label="var28_label", validate_regex=True, description="var34 description", ) var35 = CalmVariable.WithOptions.FromTask.Array.datetime( - CalmTask.Exec.escript( - script="print '30/02/2019 - 22:35:00,31/06/2019 - 10:35:00'" + CalmTask.Exec.escript.py3( + script="print ('30/02/2019 - 22:35:00,31/06/2019 - 10:35:00')" ), label="var35_label", validate_regex=True, description="var35 description", ) var36 = CalmVariable.WithOptions.FromTask.Array.multiline( - CalmTask.Exec.escript(script="print 'var36=x\ny,a\nb'"), + CalmTask.Exec.escript.py3(script="print ('var36=x\ny,a\nb')"), label="var36_label", description="var36 description", ) @@ -460,11 +460,11 @@ def test_profile_action(): target=ref(MySQLService), ) with parallel(): - CalmTask.Exec.escript( - "print 'Hello World!'", name="Test Escript", target=ref(MySQLService) + CalmTask.Exec.escript.py3( + "print ('Hello World!')", name="Test Escript", target=ref(MySQLService) ) - CalmTask.SetVariable.escript( - script="print 'var1=test'", + CalmTask.SetVariable.escript.py3( + script="print ('var1=test')", name="Test Setvar Escript", variables=["var1"], target=ref(MySQLService), diff --git a/tests/multivm_migrate/specs/test_bp_python2_tasks_at_all_levels.py b/tests/multivm_migrate/specs/test_bp_python2_tasks_at_all_levels.py index 6f5531b60..d5aabd917 100644 --- a/tests/multivm_migrate/specs/test_bp_python2_tasks_at_all_levels.py +++ b/tests/multivm_migrate/specs/test_bp_python2_tasks_at_all_levels.py @@ -29,9 +29,9 @@ class Service1(Service): service_var = CalmVariable.WithOptions.FromTask( - CalmTask.Exec.escript.py2( + CalmTask.Exec.escript.py3( name="", - script='print "akhil"', + script='print ("akhil")', ), label="", is_mandatory=False, @@ -50,9 +50,9 @@ def service_action(): runtime=False, description="", ) - CalmTask.Exec.escript.py2( + CalmTask.Exec.escript.py3( name="service_action_task", - script='print "@@{service_var}@@"', + script='print ("@@{service_var}@@")', target=ref(Service1), ) @@ -98,34 +98,34 @@ class Service_VM(Substrate): @action def __pre_create__(): - CalmTask.Exec.escript.py2( + CalmTask.Exec.escript.py3( name="Python 2 precreate", - script='print "precreate"', + script='print ("precreate")', target=ref(Service_VM), ) @action def post_action_create(): - CalmTask.Exec.escript.py2( + CalmTask.Exec.escript.py3( name="python 2 post create", - script='print "post create"', + script='print ("post create")', target=ref(Service_VM), ) @action def __post_delete__(): - CalmTask.SetVariable.escript.py2( + CalmTask.SetVariable.escript.py3( name="python 2 set var", - script='print "var=postdelete"', + script='print ("var=postdelete")', target=ref(Service_VM), variables=["var"], ) - CalmTask.Exec.escript.py2( + CalmTask.Exec.escript.py3( name="python 2 post delete", - script='print "@@{var}@@"', + script='print ("@@{var}@@")', target=ref(Service_VM), ) @@ -137,25 +137,25 @@ class Package1(Package): @action def __install__(): - CalmTask.Exec.escript.py2( + CalmTask.Exec.escript.py3( name="python2 package install", - script='print "package_install"', + script='print ("package_install")', target=ref(Service1), ) @action def __uninstall__(): - CalmTask.SetVariable.escript.py2( + CalmTask.SetVariable.escript.py3( name="python2 package uninstall set var", - script='print "pack_var=package_unainsta"', + script='print ("pack_var=package_unainsta")', target=ref(Service1), variables=["pack_var"], ) - CalmTask.Exec.escript.py2( + CalmTask.Exec.escript.py3( name="python 2 package uninstall read", - script='print "@@{pack_var}@@"', + script='print ("@@{pack_var}@@")', target=ref(Service1), ) @@ -177,7 +177,7 @@ class Default(Profile): deployments = [_8488e0af_deployment] profile_level_var = CalmVariable.WithOptions.FromTask( - CalmTask.Exec.escript.py2(name="", script='print "profile level var"'), + CalmTask.Exec.escript.py3(name="", script='print ("profile level var")'), label="", is_mandatory=False, is_hidden=False, @@ -188,8 +188,8 @@ class Default(Profile): def pythonaction(name="python action"): profile_level_action_var = CalmVariable.WithOptions.FromTask( - CalmTask.Exec.escript.py2( - name="", script='print "profile_level_action_var"' + CalmTask.Exec.escript.py3( + name="", script='print ("profile_level_action_var")' ), label="", is_mandatory=False, @@ -198,30 +198,30 @@ def pythonaction(name="python action"): ) with parallel() as p0: with branch(p0): - CalmTask.Exec.escript.py2( + CalmTask.Exec.escript.py3( name="read_profile_level_var", - script='print "@@{profile_level_var}@@"', + script='print ("@@{profile_level_var}@@")', target=ref(Service1), ) - CalmTask.Exec.escript.py2( + CalmTask.Exec.escript.py3( name="read profile level action var", - script='print "@@{profile_level_action_var}@@"', + script='print ("@@{profile_level_action_var}@@")', target=ref(Service1), ) Service1.service_action(name="read service action") - CalmTask.SetVariable.escript.py2( + CalmTask.SetVariable.escript.py3( name="set var in profile level", - script='print "profile_var=akhil"', + script='print ("profile_var=akhil")', target=ref(Service1), variables=["profile_var"], ) - CalmTask.Exec.escript.py2( + CalmTask.Exec.escript.py3( name="read set var in profile level", - script='print "@@{profile_var}@@"', + script='print ("@@{profile_var}@@")', target=ref(Service1), ) diff --git a/tests/multivm_migrate/test_multivm_migrate.py b/tests/multivm_migrate/test_multivm_migrate.py index a17436e57..a5d49ca37 100644 --- a/tests/multivm_migrate/test_multivm_migrate.py +++ b/tests/multivm_migrate/test_multivm_migrate.py @@ -36,6 +36,7 @@ @pytest.mark.nightly_380 +@pytest.mark.skip class TestMultiVmMigrate: app_helper = ApplicationHelper() diff --git a/tests/runbook_decompile/runbook_json/task_tree_runbook.json b/tests/runbook_decompile/runbook_json/task_tree_runbook.json index cc9322e61..f8acb9595 100644 --- a/tests/runbook_decompile/runbook_json/task_tree_runbook.json +++ b/tests/runbook_decompile/runbook_json/task_tree_runbook.json @@ -309,7 +309,7 @@ "child_tasks_local_reference_list": [], "state": "ACTIVE", "attrs": { - "script_type": "static", + "script_type": "static_py3", "type": "", "command_line_args": "", "exit_status": [], @@ -438,7 +438,7 @@ "child_tasks_local_reference_list": [], "state": "ACTIVE", "attrs": { - "script_type": "static", + "script_type": "static_py3", "type": "", "command_line_args": "", "exit_status": [], @@ -834,7 +834,7 @@ "uuid": "d1a72636-0cbf-d68b-23c9-c5ca3c732cc7", "child_tasks_local_reference_list": [], "attrs": { - "script_type": "static", + "script_type": "static_py3", "script": "print('hello')" }, "type": "EXEC", @@ -882,7 +882,7 @@ "uuid": "e65df912-8434-3187-4dab-4532b5579c6e", "child_tasks_local_reference_list": [], "attrs": { - "script_type": "static", + "script_type": "static_py3", "script": "print('success')" }, "type": "EXEC", diff --git a/tests/scheduler/decision_task.py b/tests/scheduler/decision_task.py index 09c6f7b09..6f53849f6 100644 --- a/tests/scheduler/decision_task.py +++ b/tests/scheduler/decision_task.py @@ -40,9 +40,9 @@ def DslDecisionRunbook(endpoints=[endpoint]): ) as d: if d.ok: - Task.Exec.escript( - name="Task1", script="print 'Decision Task is Successful'" + Task.Exec.escript.py3( + name="Task1", script="print ('Decision Task is Successful')" ) else: - Task.Exec.escript(name="Task2", script="print 'Decision Task Failed'") + Task.Exec.escript.py3(name="Task2", script="print ('Decision Task Failed')") diff --git a/tests/scheduler/example_blueprint.py b/tests/scheduler/example_blueprint.py index d005a7733..b1cc144e3 100644 --- a/tests/scheduler/example_blueprint.py +++ b/tests/scheduler/example_blueprint.py @@ -80,8 +80,8 @@ class ExistingVM(Substrate): @action def __pre_create__(): - CalmTask.Exec.escript( - name="Pre Create Task", script="print 'Pre Create task for ExistingVM'" + CalmTask.Exec.escript.py3( + name="Pre Create Task", script="print ('Pre Create task for ExistingVM')" ) diff --git a/tests/simple_blueprint/test_simple_blueprint.json b/tests/simple_blueprint/test_simple_blueprint.json index 1472e6074..db36b7bd1 100644 --- a/tests/simple_blueprint/test_simple_blueprint.json +++ b/tests/simple_blueprint/test_simple_blueprint.json @@ -1567,8 +1567,8 @@ "name": "MySQLDeploymentSubstrate" }, "attrs": { - "script_type": "static", - "script": "print 'Hello!'" + "script_type": "static_py3", + "script": "print ('Hello!')" }, "child_tasks_local_reference_list": [], "variable_list": [], diff --git a/tests/simple_blueprint/test_simple_blueprint.py b/tests/simple_blueprint/test_simple_blueprint.py index 398702628..9a6fee46e 100644 --- a/tests/simple_blueprint/test_simple_blueprint.py +++ b/tests/simple_blueprint/test_simple_blueprint.py @@ -57,7 +57,7 @@ def __stop__(): @action def __pre_create__(): - Task.Exec.escript(name="Pre Create Task", script="print 'Hello!'") + Task.Exec.escript.py3(name="Pre Create Task", script="print ('Hello!')") # Custom service actions @action diff --git a/tests/tunnel_runbooks/escript_with_tunnel_runbook.json b/tests/tunnel_runbooks/escript_with_tunnel_runbook.json index 5a1179fb1..0ccbab1b9 100644 --- a/tests/tunnel_runbooks/escript_with_tunnel_runbook.json +++ b/tests/tunnel_runbooks/escript_with_tunnel_runbook.json @@ -72,13 +72,13 @@ "eval_variables": [ "var1" ], - "script_type": "static", + "script_type": "static_py3", "tunnel_reference": { "kind": "tunnel", "uuid": "eff3b014-cd71-44c3-80d0-6ab6f0a222cc", "name": "NewNetworkGroupTunnel2" }, - "script": "vmip = \"127.0.0.1\"\nvm_url=\"http://{0}:12345/health\".format(vmip)\ndef get_resource_list(url):\n headers = {'Content-Type': 'text/html', 'Accept':'text/html'}\n try:\n r=urlreq(url, verb='GET', headers=headers, auth=\"NONE\")\n except Exception as e:\n print e\n return r\n\nres=get_resource_list(vm_url)\nprint res\nprint \"var1=\" + vmip\n" + "script": "vmip = \"127.0.0.1\"\nvm_url=\"http://{0}:12345/health\".format(vmip)\ndef get_resource_list(url):\n headers = {'Content-Type': 'text/html', 'Accept':'text/html'}\n try:\n r=urlreq(url, verb='GET', headers=headers, auth=\"NONE\")\n except Exception as e:\n print (e)\n return r\n\nres=get_resource_list(vm_url)\nprint (res)\nprint (\"var1=\" + vmip)\n" }, "timeout_secs": "", "type": "SET_VARIABLE", @@ -91,13 +91,13 @@ "child_tasks_local_reference_list": [], "name": "tunnel_exec", "attrs": { - "script_type": "static", + "script_type": "static_py3", "tunnel_reference": { "kind": "tunnel", "uuid": "eff3b014-cd71-44c3-80d0-6ab6f0a222cc", "name": "NewNetworkGroupTunnel2" }, - "script": "vmip = \"127.0.0.1\"\nvm_url=\"http://{0}:12345/health\".format(vmip)\ndef get_resource_list(url):\n headers = {'Content-Type': 'text/html', 'Accept':'text/html'}\n try:\n r=urlreq(url, verb='GET', headers=headers, auth=\"NONE\")\n except Exception as e:\n print e\n return r\n\nres=get_resource_list(vm_url)\nprint res\nprint \"var1=\" + vmip\n" + "script": "vmip = \"127.0.0.1\"\nvm_url=\"http://{0}:12345/health\".format(vmip)\ndef get_resource_list(url):\n headers = {'Content-Type': 'text/html', 'Accept':'text/html'}\n try:\n r=urlreq(url, verb='GET', headers=headers, auth=\"NONE\")\n except Exception as e:\n print (e)\n return r\n\nres=get_resource_list(vm_url)\nprint (res)\nprint (\"var1=\" + vmip)\n" }, "timeout_secs": "", "type": "EXEC", @@ -110,8 +110,8 @@ "child_tasks_local_reference_list": [], "name": "check set variable", "attrs": { - "script_type": "static", - "script": "vmip=\"@@{var1}@@\"\nif vmip == \"127.0.0.1\":\n print \"variable was set\"\n\n \n" + "script_type": "static_py3", + "script": "vmip=\"@@{var1}@@\"\nif vmip == \"127.0.0.1\":\n print (\"variable was set\")\n\n \n" }, "timeout_secs": "", "type": "EXEC", diff --git a/tests/unit/jsons/escript_all_tasks.json b/tests/unit/jsons/escript_all_tasks.json index 49045107e..e50ec5be4 100644 --- a/tests/unit/jsons/escript_all_tasks.json +++ b/tests/unit/jsons/escript_all_tasks.json @@ -80,7 +80,7 @@ "description": "", "type": "EXEC", "attrs": { - "script_type": "static", + "script_type": "static_py3", "script": "print(\"just printing...\")\n" }, "child_tasks_local_reference_list": [], @@ -93,7 +93,7 @@ "description": "", "type": "SET_VARIABLE", "attrs": { - "script_type": "static", + "script_type": "static_py3", "script": "print(\"var1=abc\")\n", "eval_variables": [ "var1" @@ -124,8 +124,8 @@ "description": "", "type": "EXEC", "attrs": { - "script_type": "static", - "script": "print \"Decision else part\"" + "script_type": "static_py3", + "script": "print (\"Decision else part\")" }, "child_tasks_local_reference_list": [], "variable_list": [], @@ -137,7 +137,7 @@ "description": "", "type": "DECISION", "attrs": { - "script_type": "static", + "script_type": "static_py3", "script": "exit(0)\n", "success_child_reference": { "kind": "app_task", @@ -173,8 +173,8 @@ "description": "", "type": "EXEC", "attrs": { - "script_type": "static", - "script": "print \"Decision if part\"" + "script_type": "static_py3", + "script": "print (\"Decision if part\")" }, "child_tasks_local_reference_list": [], "variable_list": [], @@ -205,7 +205,7 @@ "description": "", "type": "EXEC", "attrs": { - "script_type": "static", + "script_type": "static_py3", "script": "print(\"just printing...\")\n" }, "child_tasks_local_reference_list": [], @@ -218,7 +218,7 @@ "description": "", "type": "SET_VARIABLE", "attrs": { - "script_type": "static", + "script_type": "static_py3", "script": "print(\"var1=abc\")\n", "eval_variables": [ "var1" @@ -234,7 +234,7 @@ "description": "", "type": "DECISION", "attrs": { - "script_type": "static", + "script_type": "static_py3", "script": "exit(1)\n", "success_child_reference": { "kind": "app_task", diff --git a/tests/unit/jsons/python_remote_all_tasks.json b/tests/unit/jsons/python_remote_all_tasks.json new file mode 100644 index 000000000..00dc95de4 --- /dev/null +++ b/tests/unit/jsons/python_remote_all_tasks.json @@ -0,0 +1,146 @@ +{ + "endpoint_definition_list": [], + "credential_definition_list": [], + "client_attrs": {}, + "runbook": { + "name": "DslAllPythonRemoteTasks_runbook", + "description": "", + "main_task_local_reference": { + "kind": "app_task", + "name": "DslAllPythonRemoteTasks_dag" + }, + "task_definition_list": [ + { + "name": "DslAllPythonRemoteTasks_dag", + "description": "", + "type": "DAG", + "attrs": { + "edges": [] + }, + "child_tasks_local_reference_list": [ + { + "kind": "app_task", + "name": "python_decision" + } + ], + "variable_list": [], + "retries": "", + "timeout_secs": "" + }, + { + "name": "python_decision_success_meta_task", + "description": "", + "type": "META", + "attrs": {}, + "child_tasks_local_reference_list": [ + { + "kind": "app_task", + "name": "python_exec" + }, + { + "kind": "app_task", + "name": "python_setvar" + } + ], + "variable_list": [], + "retries": "", + "timeout_secs": "" + }, + { + "name": "python_exec", + "description": "", + "type": "EXEC", + "target_any_local_reference": { + "kind": "app_endpoint", + "name": "IP_endpoint" + }, + "attrs": { + "script_type": "python_remote", + "script": "print(\"just printing...\")\n" + }, + "child_tasks_local_reference_list": [], + "variable_list": [], + "retries": "", + "timeout_secs": "" + }, + { + "name": "python_setvar", + "description": "", + "type": "SET_VARIABLE", + "target_any_local_reference": { + "kind": "app_endpoint", + "name": "IP_endpoint" + }, + "attrs": { + "script_type": "python_remote", + "script": "print(\"var1=abc\")\n", + "eval_variables": [ + "var1" + ] + }, + "child_tasks_local_reference_list": [], + "variable_list": [], + "retries": "", + "timeout_secs": "" + }, + { + "name": "python_decision_failure_meta_task", + "description": "", + "type": "META", + "attrs": {}, + "child_tasks_local_reference_list": [ + { + "kind": "app_task", + "name": "python_exec_print" + } + ], + "variable_list": [], + "retries": "", + "timeout_secs": "" + }, + { + "name": "python_exec_print", + "description": "", + "type": "EXEC", + "target_any_local_reference": { + "kind": "app_endpoint", + "name": "IP_endpoint" + }, + "attrs": { + "script_type": "python_remote", + "script": "print \"Decision else part\"" + }, + "child_tasks_local_reference_list": [], + "variable_list": [], + "retries": "", + "timeout_secs": "" + }, + { + "name": "python_decision", + "description": "", + "type": "DECISION", + "target_any_local_reference": { + "kind": "app_endpoint", + "name": "IP_endpoint" + }, + "attrs": { + "script_type": "python_remote", + "script": "exit(0)\n", + "success_child_reference": { + "kind": "app_task", + "name": "python_decision_success_meta_task" + }, + "failure_child_reference": { + "kind": "app_task", + "name": "python_decision_failure_meta_task" + } + }, + "child_tasks_local_reference_list": [], + "variable_list": [], + "retries": "", + "timeout_secs": "" + } + ], + "variable_list": [] + } +} diff --git a/tests/unit/test_action_with_endpoint_decompile.py b/tests/unit/test_action_with_endpoint_decompile.py index 97c14b932..41f8ba32f 100644 --- a/tests/unit/test_action_with_endpoint_decompile.py +++ b/tests/unit/test_action_with_endpoint_decompile.py @@ -12,7 +12,7 @@ def test_action_with_endpoint_decompile(): file_path = os.path.join(dir_path, "./jsons/action_with_endpoint.json") bp_dict = json.loads(open(file_path).read()) cls = ActionType.decompile(bp_dict) - assert "target=ref(ep2)" in render_action_template( + assert "target_endpoint=ref(ep2)" in render_action_template( cls ), "expected endpoint ep2 to be decompiled in task" shutil.rmtree(scripts_dir) diff --git a/tests/unit/test_escript_all_tasks.py b/tests/unit/test_escript_all_tasks.py index b6967b798..c36c6f985 100644 --- a/tests/unit/test_escript_all_tasks.py +++ b/tests/unit/test_escript_all_tasks.py @@ -13,38 +13,38 @@ def DslAllEscriptTasks(endpoints=[], default=False): "Runbook example with All Escript Type Tasks" - with CalmTask.Decision.escript( + with CalmTask.Decision.escript.py3( name="escript_decision", filename=os.path.join("scripts", "escript_decision_true.py"), ) as d: if d.ok: - CalmTask.Exec.escript( + CalmTask.Exec.escript.py3( name="escript_exec", filename=os.path.join("scripts", "escript_exec.py") ) - CalmTask.SetVariable.escript( + CalmTask.SetVariable.escript.py3( name="escript_setvar", filename=os.path.join("scripts", "escript_setvariable.py"), variables=["var1"], ) else: - CalmTask.Exec.escript( - name="escript_exec_print", script='''print "Decision else part"''' + CalmTask.Exec.escript.py3( + name="escript_exec_print", script="""print ("Decision else part")""" ) - with CalmTask.Decision.escript.py2( + with CalmTask.Decision.escript.py3( name="escript2_decision", filename=os.path.join("scripts", "escript_decision_false.py"), ) as d: if d.ok: - CalmTask.Exec.escript.py2( - name="escript3_exec_print", script='''print "Decision if part"''' + CalmTask.Exec.escript.py3( + name="escript3_exec_print", script="""print ("Decision if part")""" ) else: - CalmTask.Exec.escript.py2( + CalmTask.Exec.escript.py3( name="escript2_exec", filename=os.path.join("scripts", "escript_exec.py"), ) - CalmTask.SetVariable.escript.py2( + CalmTask.SetVariable.escript.py3( name="escript2_setvar", filename=os.path.join("scripts", "escript_setvariable.py"), variables=["var1"], diff --git a/tests/unit/test_python_remote_all_tasks.py b/tests/unit/test_python_remote_all_tasks.py new file mode 100644 index 000000000..afa68f858 --- /dev/null +++ b/tests/unit/test_python_remote_all_tasks.py @@ -0,0 +1,58 @@ +import os +import pytest + +from calm.dsl.runbooks import * +from calm.dsl.runbooks import RunbookTask as CalmTask, CalmEndpoint as Endpoint + +Cred = basic_cred(username="username", password="password", name="endpoint_cred") +IPEndpoint = Endpoint.Linux.ip(["10.10.10.10"], cred=Cred, name="IP_endpoint") + + +@runbook +def DslAllPythonRemoteTasks(endpoints=[], default=False): + "Runbook example with All python_remote Type Tasks" + + with CalmTask.Decision.python( + name="python_decision", + filename=os.path.join("scripts", "escript_decision_true.py"), + target=IPEndpoint, + ) as d: + if d.ok: + CalmTask.Exec.python( + name="python_exec", + filename=os.path.join("scripts", "escript_exec.py"), + target=IPEndpoint, + ) + CalmTask.SetVariable.python( + name="python_setvar", + filename=os.path.join("scripts", "escript_setvariable.py"), + variables=["var1"], + target=IPEndpoint, + ) + else: + CalmTask.Exec.python( + name="python_exec_print", + script='''print "Decision else part"''', + target=IPEndpoint, + ) + + +def _test_compare_compile_result(Runbook, json_file): + """compares the runbook compilation and known output""" + + print("JSON compilation test for {}".format(Runbook.action_name)) + dir_path = os.path.dirname(os.path.realpath(__file__)) + file_path = os.path.join(dir_path, json_file) + + generated_json = runbook_json(Runbook) + known_json = open(file_path).read() + assert generated_json == known_json + print("JSON compilation successful for {}".format(Runbook.action_name)) + + +@pytest.mark.runbook +@pytest.mark.escript +def test_all_python_remote_type_tasks(): + _test_compare_compile_result( + DslAllPythonRemoteTasks, "./jsons/python_remote_all_tasks.json" + ) diff --git a/tests/vm_blueprints/single_vm_blueprint/blueprint.py b/tests/vm_blueprints/single_vm_blueprint/blueprint.py index 0fd27439c..11aa517a5 100644 --- a/tests/vm_blueprints/single_vm_blueprint/blueprint.py +++ b/tests/vm_blueprints/single_vm_blueprint/blueprint.py @@ -78,7 +78,7 @@ def __install__(): @action def __pre_create__(): - Task.Exec.escript(name="Pre Create Task", script="print 'Hello!'") + Task.Exec.escript.py3(name="Pre Create Task", script="print ('Hello!')") @action def test_profile_action(): diff --git a/tests/vm_blueprints/single_vm_blueprint/single_vm_bp_output.json b/tests/vm_blueprints/single_vm_blueprint/single_vm_bp_output.json index c51d2b5b2..2a0db1d61 100644 --- a/tests/vm_blueprints/single_vm_blueprint/single_vm_bp_output.json +++ b/tests/vm_blueprints/single_vm_blueprint/single_vm_bp_output.json @@ -415,8 +415,8 @@ "name": "Profile1Substrate" }, "attrs": { - "script_type": "static", - "script": "print 'Hello!'" + "script_type": "static_py3", + "script": "print ('Hello!')" }, "child_tasks_local_reference_list": [], "variable_list": [], diff --git a/tests/vm_blueprints/single_vm_multi_profile_blueprint/blueprint.py b/tests/vm_blueprints/single_vm_multi_profile_blueprint/blueprint.py index 590f2de61..4e94b0fb7 100644 --- a/tests/vm_blueprints/single_vm_multi_profile_blueprint/blueprint.py +++ b/tests/vm_blueprints/single_vm_multi_profile_blueprint/blueprint.py @@ -79,7 +79,7 @@ def __install__(): @action def __pre_create__(): - Task.Exec.escript(name="Pre Create Task", script="print 'Hello!'") + Task.Exec.escript.py3(name="Pre Create Task", script="print ('Hello!')") @action def test_profile_action(): diff --git a/tests/vm_blueprints/single_vm_multi_profile_blueprint/single_vm_multi_profile_bp_output.json b/tests/vm_blueprints/single_vm_multi_profile_blueprint/single_vm_multi_profile_bp_output.json index e7ab53968..db0f1419b 100644 --- a/tests/vm_blueprints/single_vm_multi_profile_blueprint/single_vm_multi_profile_bp_output.json +++ b/tests/vm_blueprints/single_vm_multi_profile_blueprint/single_vm_multi_profile_bp_output.json @@ -506,8 +506,8 @@ "name": "AhvVmSmallProfileSubstrate" }, "attrs": { - "script_type": "static", - "script": "print 'Hello!'" + "script_type": "static_py3", + "script": "print ('Hello!')" }, "child_tasks_local_reference_list": [], "variable_list": [], @@ -643,8 +643,8 @@ "name": "AhvVmLargeProfileSubstrate" }, "attrs": { - "script_type": "static", - "script": "print 'Hello!'" + "script_type": "static_py3", + "script": "print ('Hello!')" }, "child_tasks_local_reference_list": [], "variable_list": [],