From e482600790f068e9bab1c42bc37971397eb8ab13 Mon Sep 17 00:00:00 2001 From: Navtejpreet Singh Date: Thu, 28 Mar 2024 21:49:05 +0530 Subject: [PATCH 01/16] bug/m-calm-43703-makes-py3-escript-default (#400) changes the default flow of escript from python2 Escripts to python3 Escripts. (cherry picked from commit 697ea245ea309a597cf0889d196727873b1509c9) --- calm/dsl/builtins/models/task.py | 6 +++--- calm/dsl/cli/library_tasks.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/calm/dsl/builtins/models/task.py b/calm/dsl/builtins/models/task.py index 5595b14d..578c86ac 100644 --- a/calm/dsl/builtins/models/task.py +++ b/calm/dsl/builtins/models/task.py @@ -962,7 +962,7 @@ def __new__( tunnel=None, **kwargs, ): - return exec_task_escript( + return exec_task_escript_py3( script=script, filename=filename, name=name, @@ -986,7 +986,7 @@ def __new__( tunnel=None, **kwargs, ): - return decision_task_escript( + return decision_task_escript_py3( script=script, filename=filename, name=name, @@ -1011,7 +1011,7 @@ def __new__( tunnel=None, **kwargs, ): - return set_variable_task_escript( + return set_variable_task_escript_py3( script=script, filename=filename, name=name, diff --git a/calm/dsl/cli/library_tasks.py b/calm/dsl/cli/library_tasks.py index bb5f2f5d..f8fb64cb 100644 --- a/calm/dsl/cli/library_tasks.py +++ b/calm/dsl/cli/library_tasks.py @@ -507,9 +507,9 @@ def import_task(task_file, name, description, out_vars, force): ): 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 From 145ce13bcc444c218e61f979e92b95bfd84a3ea1 Mon Sep 17 00:00:00 2001 From: Gullapalli Akhil Sai Date: Tue, 2 Apr 2024 12:48:21 +0530 Subject: [PATCH 02/16] Task/python2 deprecation automation changes (#406) DSL Regression: http://rp.calm.nutanix.com/ui/#calm/launches/all%7Cpage.page=1&page.size=50&page.sort=start_time,number%2CDESC/660ad6f22ab79c0001e261d8 http://rp.calm.nutanix.com/ui/#calm/launches/all%7Cpage.page=1&page.size=50&page.sort=start_time,number%2CDESC/660ad9a82ab79c0001e28485 --------- Co-authored-by: Sumanbshollq Co-authored-by: Esha-Doda (cherry picked from commit 9785c5af9555940337e01f5efe1925ab852a51f3) --- .../AHV_CONFIG/snapshot_restore/blueprint.py | 8 +-- .../snapshot_restore/demo_blueprint.py | 8 +-- .../AHV_K8S_Discourse/AHV_K8S_Discourse.py | 2 +- examples/AHV_MACRO_BLUEPRINT/blueprint.py | 2 +- examples/AHV_MACRO_BLUEPRINT/blueprint_em.py | 2 +- .../AHV_MACRO_BLUEPRINT/sample_runbook.py | 2 +- .../AHV_MACRO_BLUEPRINT/sample_runbook_2.py | 4 +- .../scripts/pre_create_script.py | 2 +- .../scripts/set_variable_task1_script.py | 2 +- examples/Dev_Cpnhgn_Hybrid/devcpnhgnhybrd.py | 22 +++---- .../postdelete/3DeregisterDBServer.py | 6 +- .../webserver/updateapp/UpdateContainers.py | 6 +- examples/EraPostgres/erapostgres.py | 20 +++---- examples/Kubernetes/kubernetes.py | 16 ++--- examples/OscarApp/oscarapp.py | 34 +++++------ .../ndb_example/scripts/GetTimemachineID.py | 2 +- .../ndb_example/scripts/ReserveanIPAddress.py | 4 +- .../postgresDB_create_snapshot.py | 2 +- examples/Runbooks/entity_stats.py | 10 ++-- examples/Runbooks/logs_cleanup.py | 4 +- .../runbook_approval_policy_entity_stats.py | 10 ++-- examples/vpcBlueprint/Hello/blueprint.py | 4 +- ...trate_Action___post_delete___Task_Task1.py | 2 +- ...strate_Action___pre_create___Task_Task1.py | 2 +- examples/vpcBlueprint/blueprint.py | 8 +-- examples/vpcBlueprint/temp | 2 +- .../blueprints/vm_blueprints/blueprint.py | 2 +- .../testDSLDecompileBlueprint/blueprint.py | 4 +- .../test_overlay_subnet_blueprint.json | 8 +-- .../test_overlay_subnet_blueprint.py | 8 +-- .../entity_spec/existing_vm_bp.py | 10 ++-- .../test_blueprint_example.py | 4 +- tests/decompile/test_decompile.py | 10 ++-- tests/decompile/test_task_tree_bp.py | 20 +++---- tests/dynamic_creds/test_credential_bp.py | 4 +- tests/escript/scripts/escript1.py | 12 ---- tests/escript/scripts/escript1.py.out | 4 -- tests/escript/scripts/escript2.py | 8 --- tests/escript/scripts/escript2.py.out | 2 - tests/escript/scripts/escript3.py | 19 ------ tests/escript/scripts/escript3.py.out | 2 - tests/escript/scripts/escript_z6.py | 2 +- tests/escript/scripts/escript_z6.py.out | 2 +- tests/escript/scripts/parallel_escript_py2.py | 2 - .../scripts/parallel_escript_py2.py.out | 1 - tests/escript/test_parallel_escript.py | 5 +- .../test_existing_vm_bp.json | 52 ++++++++--------- .../test_existing_vm_bp.py | 32 +++++----- .../test_existing_vm_bp.json | 52 ++++++++--------- ...xisting_vm_bp_with_endpoint_target_task.py | 32 +++++----- .../test_bp_python2_tasks_at_all_levels.py | 58 +++++++++---------- tests/multivm_migrate/test_multivm_migrate.py | 1 + .../runbook_json/task_tree_runbook.json | 8 +-- tests/scheduler/decision_task.py | 6 +- tests/scheduler/example_blueprint.py | 4 +- .../test_simple_blueprint.json | 4 +- .../simple_blueprint/test_simple_blueprint.py | 2 +- .../escript_with_tunnel_runbook.json | 12 ++-- tests/unit/jsons/escript_all_tasks.json | 20 +++---- tests/unit/test_escript_all_tasks.py | 20 +++---- .../single_vm_blueprint/blueprint.py | 2 +- .../single_vm_bp_output.json | 4 +- .../blueprint.py | 2 +- .../single_vm_multi_profile_bp_output.json | 8 +-- 64 files changed, 291 insertions(+), 343 deletions(-) delete mode 100644 tests/escript/scripts/escript1.py delete mode 100644 tests/escript/scripts/escript1.py.out delete mode 100644 tests/escript/scripts/escript2.py delete mode 100644 tests/escript/scripts/escript2.py.out delete mode 100644 tests/escript/scripts/escript3.py delete mode 100644 tests/escript/scripts/escript3.py.out delete mode 100644 tests/escript/scripts/parallel_escript_py2.py delete mode 100644 tests/escript/scripts/parallel_escript_py2.py.out diff --git a/examples/AHV_CONFIG/snapshot_restore/blueprint.py b/examples/AHV_CONFIG/snapshot_restore/blueprint.py index 10285d0e..9efb2938 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 33cb3abb..088e1872 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 7e05c8a3..00c0a93c 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 744d2f78..22bcb45d 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 35eaf348..61e42e49 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 1adc5409..4513b056 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 b7eee3c2..2ca3149e 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 b26a8402..2d0d891e 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 c0543345..8a623fba 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 0971a8bd..1e958b33 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 b93939e9..7afc0663 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 c3fd5322..3b6c4045 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 21800750..0d3db9b8 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 1cf1c207..1e640ea4 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 9e9272f9..555efc85 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 c9921cac..2045318c 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 d054b264..518e402e 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 d44776e3..fb80715d 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 5e901f31..904048d5 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 ac74b29b..dd403e4d 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 b5faa3f9..50c242f5 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 6e8f7bf6..42cb33fd 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 b6c6ee3b..b71a056f 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 d457fd02..26d9ac9a 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 1a3c4d77..324763ba 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 1f4c3bb0..f371d1c9 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/tests/3_2_0/blueprints/vm_blueprints/blueprint.py b/tests/3_2_0/blueprints/vm_blueprints/blueprint.py index 06ce622e..9e4385ae 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 88ac0856..6f9a5530 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 eece0c0b..cc04b64e 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 c76c39a2..88f6523a 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 a72c74be..e3655c2c 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 44b989b5..efe4ff09 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 782a9bf4..e6859479 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 e007ab27..2cd28428 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 ff88de84..4867f03a 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 37fb0212..00000000 --- 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 87221d22..00000000 --- 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 971119ad..00000000 --- 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 713aa523..00000000 --- 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 a1b2f124..00000000 --- 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 b6edb0f8..00000000 --- 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 f0007d69..13757f0f 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 90eb8105..29b5e6bd 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 206d77e8..00000000 --- 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 2a12b6bf..00000000 --- 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 f400ea54..0d14cb08 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 a66b55d0..1006eb85 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 1813a756..336c05ef 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 324920ae..fe15d015 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 d4794a22..cf7f2fec 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 6f5531b6..d5aabd91 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 a17436e5..a5d49ca3 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 cc9322e6..f8acb959 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 09c6f7b0..6f53849f 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 d005a773..b1cc144e 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 1472e607..db36b7bd 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 39870262..9a6fee46 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 5a1179fb..0ccbab1b 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 49045107..e50ec5be 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/test_escript_all_tasks.py b/tests/unit/test_escript_all_tasks.py index b6967b79..c36c6f98 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/vm_blueprints/single_vm_blueprint/blueprint.py b/tests/vm_blueprints/single_vm_blueprint/blueprint.py index 0fd27439..11aa517a 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 c51d2b5b..2a0db1d6 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 590f2de6..4e94b0fb 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 e7ab5396..db0f1419 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": [], From babf5d4e784fc05dafa6bc9d21c1d4b7093abc6f Mon Sep 17 00:00:00 2001 From: Prabhat Dwivedi Date: Thu, 11 Apr 2024 01:24:48 -0700 Subject: [PATCH 03/16] CALM: DSL Examples and Help commands need to be updated according to Python3 default (#412) Issue Link: https://jira.nutanix.com/browse/CALM-44121 Description: 1. Help commands updated to use default python3 in escripts. (cherry picked from commit f77c8ac548019af236f46268575d257e63f5a324) --- calm/dsl/cli/library_tasks_commands.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/calm/dsl/cli/library_tasks_commands.py b/calm/dsl/cli/library_tasks_commands.py index 2c122fc0..ddbb3b17 100644 --- a/calm/dsl/cli/library_tasks_commands.py +++ b/calm/dsl/cli/library_tasks_commands.py @@ -109,7 +109,7 @@ 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 From 0a19ba831afbffccca586a41fca11c310e05a382 Mon Sep 17 00:00:00 2001 From: Navtejpreet Singh Date: Thu, 11 Apr 2024 13:56:18 +0530 Subject: [PATCH 04/16] (#CALM-43702) Adds new remote python task type (#401) Adds new task type that runs python script on remote machines, similar to ssh and powershell tasks. Will be EXEC, SET_VARIABLE and DECISION tasks. --------- Co-authored-by: Prabhat Dwivedi (cherry picked from commit 6b93a960162d4a859a739ac8271efcc9c2ca3073) --- calm/dsl/builtins/models/task.py | 120 ++++++++++++++ calm/dsl/cli/constants.py | 1 + calm/dsl/cli/library_tasks.py | 3 + calm/dsl/cli/library_tasks_commands.py | 3 +- .../schemas/task_decision_python.py.jinja2 | 13 ++ .../schemas/task_exec_python.py.jinja2 | 13 ++ .../schemas/task_setvariable_python.py.jinja2 | 15 ++ calm/dsl/decompile/task.py | 12 +- tests/unit/jsons/python_remote_all_tasks.json | 146 ++++++++++++++++++ tests/unit/test_python_remote_all_tasks.py | 58 +++++++ 10 files changed, 382 insertions(+), 2 deletions(-) create mode 100644 calm/dsl/decompile/schemas/task_decision_python.py.jinja2 create mode 100644 calm/dsl/decompile/schemas/task_exec_python.py.jinja2 create mode 100644 calm/dsl/decompile/schemas/task_setvariable_python.py.jinja2 create mode 100644 tests/unit/jsons/python_remote_all_tasks.json create mode 100644 tests/unit/test_python_remote_all_tasks.py diff --git a/calm/dsl/builtins/models/task.py b/calm/dsl/builtins/models/task.py index 578c86ac..2adfea3b 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__( @@ -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/constants.py b/calm/dsl/cli/constants.py index c319cc1d..64bf7700 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" diff --git a/calm/dsl/cli/library_tasks.py b/calm/dsl/cli/library_tasks.py index f8fb64cb..ece97d27 100644 --- a/calm/dsl/cli/library_tasks.py +++ b/calm/dsl/cli/library_tasks.py @@ -504,6 +504,7 @@ 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 @@ -513,6 +514,8 @@ def import_task(task_file, name, description, out_vars, force): 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 ddbb3b17..e77bf5bc 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( @@ -113,6 +113,7 @@ def _import_task(task_file, name, description, out_vars, force): \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/decompile/schemas/task_decision_python.py.jinja2 b/calm/dsl/decompile/schemas/task_decision_python.py.jinja2 new file mode 100644 index 00000000..13c4b7e5 --- /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 00000000..f2ef95f7 --- /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}}) +{%- elif obj.cred is not defined %} +CalmTask.Exec.python(name='{{obj.name}}', filename={{obj.attrs.script_file}}, target={{obj.target}}) +{%- elif obj.target is not defined %} +CalmTask.Exec.python(name='{{obj.name}}', filename={{obj.attrs.script_file}}, cred={{obj.cred}}) +{%- else %} +CalmTask.Exec.python(name='{{obj.name}}', filename={{obj.attrs.script_file}}, cred={{obj.cred}}, target={{obj.target}}) +{%- 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 00000000..021f664b --- /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}}) +{%- 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}}) +{%- elif obj.target is not defined %} +CalmTask.SetVariable.python(name='{{obj.name}}', filename={{obj.attrs.script_file}}, cred={{obj.cred}}, variables={{obj.variables}}) +{%- elif obj.variables is not defined %} +CalmTask.SetVariable.python(name='{{obj.name}}', filename={{obj.attrs.script_file}}, cred={{obj.cred}}, target={{obj.target}}) +{%- else %} +CalmTask.SetVariable.python(name='{{obj.name}}', filename={{obj.attrs.script_file}}, cred={{obj.cred}}, target={{obj.target}}, variables={{obj.variables}}) +{%- endif %} +{%- endmacro %} + +{{ setvariable_python_task(obj) }} diff --git a/calm/dsl/decompile/task.py b/calm/dsl/decompile/task.py index 61264cae..66f7a6e0 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/tests/unit/jsons/python_remote_all_tasks.json b/tests/unit/jsons/python_remote_all_tasks.json new file mode 100644 index 00000000..00dc95de --- /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_python_remote_all_tasks.py b/tests/unit/test_python_remote_all_tasks.py new file mode 100644 index 00000000..afa68f85 --- /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" + ) From bce555fbf1c5dac72842dedd0a4ba85442d3fe65 Mon Sep 17 00:00:00 2001 From: Prabhat Dwivedi Date: Tue, 23 Apr 2024 22:53:07 -0700 Subject: [PATCH 05/16] added new python task decompile for 380 release (#427) (cherry picked from commit 27cc4b1b4f67ff912b8dffa3f6e69e53ff99a79b) --- calm/dsl/decompile/schemas/task_exec_python.py.jinja2 | 8 ++++---- .../schemas/task_setvariable_python.py.jinja2 | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/calm/dsl/decompile/schemas/task_exec_python.py.jinja2 b/calm/dsl/decompile/schemas/task_exec_python.py.jinja2 index f2ef95f7..63e1a40a 100644 --- a/calm/dsl/decompile/schemas/task_exec_python.py.jinja2 +++ b/calm/dsl/decompile/schemas/task_exec_python.py.jinja2 @@ -1,12 +1,12 @@ {%- 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}}) +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}}) +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}}) +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}}) +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 %} diff --git a/calm/dsl/decompile/schemas/task_setvariable_python.py.jinja2 b/calm/dsl/decompile/schemas/task_setvariable_python.py.jinja2 index 021f664b..4125c0af 100644 --- a/calm/dsl/decompile/schemas/task_setvariable_python.py.jinja2 +++ b/calm/dsl/decompile/schemas/task_setvariable_python.py.jinja2 @@ -1,14 +1,14 @@ {%- 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}}) +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}}) +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}}) +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}}) +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}}) +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 %} From bb3504c80bf7398fc04935ec05297e0fa2e62d45 Mon Sep 17 00:00:00 2001 From: Prabhat Dwivedi Date: Fri, 3 May 2024 01:49:04 -0700 Subject: [PATCH 06/16] Fix for test_action_with_endpoint_decompile.py (#435) Before fix: ![image](https://github.com/ideadevice/calm-dsl/assets/123161845/ac411e92-6c07-4f80-afc1-f5f195064420) After fix: ![image](https://github.com/ideadevice/calm-dsl/assets/123161845/9db51796-7c43-4812-9bba-8c3edb413645) (cherry picked from commit e34f560546e30391a67e991b9ce479fc1bcf19cc) --- tests/unit/test_action_with_endpoint_decompile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/test_action_with_endpoint_decompile.py b/tests/unit/test_action_with_endpoint_decompile.py index 97c14b93..41f8ba32 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) From 58ac86cb562c9537cddd084eeb37c064ae77902d Mon Sep 17 00:00:00 2001 From: Prabhat Dwivedi Date: Wed, 15 May 2024 08:01:55 -0700 Subject: [PATCH 07/16] Fix config attr decompile (#440) RCA: Config attr class can be rendered before service class if it is present before in dependepent_entities this may fail decompile scenarios where config attr class has call_runbook action targeting a service action. And service class is not rendered to create RUNBOOK_ACTION_MAP. Fix: Config attr class should be rendered after all other classes are rendered. Additional small fix to remove system defined patch config tasks while decompiling bp from json file. This was present for bp decompile from server. Added for json file bp decompile. Regression: http://erdinger.eng.nutanix.com/blue/organizations/jenkins/QA%2FDSL_Regression/detail/DSL_Regression/619/pipeline/ Affect version: 3.7.2.2, Fix version: 3.8.0 (cherry picked from commit 2586f22978cd6b83d55458347680cabd2b18ff70) --- calm/dsl/cli/bps.py | 4 ++++ calm/dsl/decompile/bp_file_helper.py | 34 ++++++++++++++++++++++------ 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/calm/dsl/cli/bps.py b/calm/dsl/cli/bps.py index 1dd9c866..718b9a08 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/decompile/bp_file_helper.py b/calm/dsl/decompile/bp_file_helper.py index be770698..b8b7aea3 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", ""): From 2097eefa63ff7d43b96902a1bec9fe49631ea258 Mon Sep 17 00:00:00 2001 From: Prabhat Dwivedi Date: Wed, 15 May 2024 08:02:16 -0700 Subject: [PATCH 08/16] DSL-380 release notes (#441) (cherry picked from commit 71369a63f93bab6b4ac4ef5c10359b1348ca0fa4) --- release-notes/3.8.0/README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 release-notes/3.8.0/README.md diff --git a/release-notes/3.8.0/README.md b/release-notes/3.8.0/README.md new file mode 100644 index 00000000..bc3798e1 --- /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 + +- Deprecates python 2 escripts and changes the default flow of escript from python 2 to python 3. +- 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. +- Other small bug fixes. + + From 615f4e73db4d4c62a63919e949b447be0347c626 Mon Sep 17 00:00:00 2001 From: Utkarsh Bairolia Date: Tue, 7 Nov 2023 12:29:06 +0530 Subject: [PATCH 09/16] added permissions to project ACPs (#322) 1. Added distributed_virtual_switch, vm_recovery_point to all the ACPs. 2. Added report config for Project admin. 3. Added collab independent 3rd index ACP for global entities within the project scope. 4. Moved user and use group to project scope. [CALM-40511](https://jira.nutanix.com/browse/CALM-40511) --------- (cherry picked from commit 09e570a3f1bbc8763e9ee6f878287c270e3b42f3) --- calm/dsl/cli/acps.py | 24 ++++- calm/dsl/cli/constants.py | 209 +++++++++++++++++++++++++++++++++----- 2 files changed, 203 insertions(+), 30 deletions(-) diff --git a/calm/dsl/cli/acps.py b/calm/dsl/cli/acps.py index 98935d5d..2df19f3e 100644 --- a/calm/dsl/cli/acps.py +++ b/calm/dsl/cli/acps.py @@ -281,6 +281,12 @@ 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] # Setting project uuid in default context default_context["scope_filter_expression_list"][0]["right_hand_side"][ @@ -297,6 +303,11 @@ def create_acp(role, project, acp_users, acp_groups, name): project_uuid ] + # Adding vm filter for collab context. This is applicable only for project admin + project_collab_context["entity_filter_expression_list"].extend( + ACP.PROJECT_ADMIN_SPECIFIC_COLLAB_FILTER + ) + elif role == "Developer": entity_filter_expression_list = ACP.ENTITY_FILTER_EXPRESSION_LIST.DEVELOPER @@ -308,6 +319,11 @@ def create_acp(role, project, acp_users, acp_groups, name): else: entity_filter_expression_list = get_filters_custom_role(role_uuid, client) + project_collab_context[ + "entity_filter_expression_list" + ] = get_filters_custom_role( + role_uuid, client, ACP.CUSTOM_ROLE_SPECIFIC_COLLAB_FILTER + ) if cluster_uuids: entity_filter_expression_list.append( @@ -338,6 +354,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 +394,7 @@ 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, custom_role_filter_dict=None): role, err = client.role.read(id=role_uuid) if err: @@ -394,7 +411,10 @@ 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: + custom_role_filter_dict = ( + ACP.CUSTOM_ROLE_PERMISSIONS_FILTERS if not custom_role_filter_dict else None + ) + for perm_filter in custom_role_filter_dict: if perm_filter.get("permission") in permission_names: entity_filter_expression_list.append(perm_filter.get("filter")) return entity_filter_expression_list diff --git a/calm/dsl/cli/constants.py b/calm/dsl/cli/constants.py index 64bf7700..930c6550 100644 --- a/calm/dsl/cli/constants.py +++ b/calm/dsl/cli/constants.py @@ -293,6 +293,16 @@ class ENTITY_FILTER_EXPRESSION_LIST: "left_hand_side": {"entity_type": "custom_provider"}, "right_hand_side": {"collection": "ALL"}, }, + { + "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"}, + }, ] OPERATOR = [ @@ -316,6 +326,16 @@ class ENTITY_FILTER_EXPRESSION_LIST: "left_hand_side": {"entity_type": "custom_provider"}, "right_hand_side": {"collection": "ALL"}, }, + { + "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"}, + }, ] CONSUMER = [ @@ -364,6 +384,16 @@ class ENTITY_FILTER_EXPRESSION_LIST: "left_hand_side": {"entity_type": "custom_provider"}, "right_hand_side": {"collection": "ALL"}, }, + { + "operator": "IN", + "left_hand_side": {"entity_type": "vm_recovery_point"}, + "right_hand_side": {"collection": "ALL"}, + }, + { + "operator": "IN", + "left_hand_side": {"entity_type": "distributed_virtual_switch"}, + "right_hand_side": {"collection": "ALL"}, + }, ] PROJECT_ADMIN = [ @@ -392,16 +422,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"}, @@ -442,6 +462,21 @@ class ENTITY_FILTER_EXPRESSION_LIST: "left_hand_side": {"entity_type": "custom_provider"}, "right_hand_side": {"collection": "ALL"}, }, + { + "operator": "IN", + "left_hand_side": {"entity_type": "vm_recovery_point"}, + "right_hand_side": {"collection": "ALL"}, + }, + { + "operator": "IN", + "left_hand_side": {"entity_type": "distributed_virtual_switch"}, + "right_hand_side": {"collection": "ALL"}, + }, + { + "operator": "IN", + "left_hand_side": {"entity_type": "report_config"}, + "right_hand_side": {"collection": "SELF_OWNED"}, + }, ] CUSTOM_ROLE_PERMISSIONS_FILTERS = [ @@ -493,22 +528,6 @@ class ENTITY_FILTER_EXPRESSION_LIST: "right_hand_side": {"collection": "SELF_OWNED"}, }, }, - { - "permission": "view_user", - "filter": { - "operator": "IN", - "right_hand_side": {"collection": "ALL"}, - "left_hand_side": {"entity_type": "user"}, - }, - }, - { - "permission": "view_user_group", - "filter": { - "operator": "IN", - "right_hand_side": {"collection": "ALL"}, - "left_hand_side": {"entity_type": "user_group"}, - }, - }, { "permission": "view_role", "filter": { @@ -558,7 +577,7 @@ class ENTITY_FILTER_EXPRESSION_LIST: }, }, { - "permission": "view_image", + "permission": "view_resource_type", "filter": { "operator": "IN", "left_hand_side": {"entity_type": "resource_type"}, @@ -566,13 +585,96 @@ class ENTITY_FILTER_EXPRESSION_LIST: }, }, { - "permission": "view_image", + "permission": "view_custom_provider", "filter": { "operator": "IN", "left_hand_side": {"entity_type": "custom_provider"}, "right_hand_side": {"collection": "ALL"}, }, }, + { + "permission": "view_vm_recovery_point", + "filter": { + "operator": "IN", + "left_hand_side": {"entity_type": "vm_recovery_point"}, + "right_hand_side": {"collection": "ALL"}, + }, + }, + { + "permission": "view_virtual_switch", + "filter": { + "operator": "IN", + "left_hand_side": {"entity_type": "distributed_virtual_switch"}, + "right_hand_side": {"collection": "ALL"}, + }, + }, + { + "permission": "View_report_config", + "filter": { + "operator": "IN", + "left_hand_side": {"entity_type": "report_config"}, + "right_hand_side": {"collection": "SELF_OWNED"}, + }, + }, + ] + + CUSTOM_ROLE_SPECIFIC_COLLAB_FILTER = [ + { + "permission": "view_user", + "filter": { + "operator": "IN", + "right_hand_side": {"collection": "ALL"}, + "left_hand_side": {"entity_type": "user"}, + }, + }, + { + "permission": "view_virtual_machine", + "filter": { + "operator": "IN", + "left_hand_side": {"entity_type": "vm"}, + "right_hand_side": {"collection": "ALL"}, + }, + }, + { + "permission": "view_user_group", + "filter": { + "operator": "IN", + "right_hand_side": {"collection": "ALL"}, + "left_hand_side": {"entity_type": "user_group"}, + }, + }, + { + "permission": "view_blueprint", + "filter": { + "operator": "IN", + "left_hand_side": {"entity_type": "blueprint"}, + "right_hand_side": {"collection": "ALL"}, + }, + }, + { + "permission": "view_environment", + "filter": { + "operator": "IN", + "left_hand_side": {"entity_type": "environment"}, + "right_hand_side": {"collection": "ALL"}, + }, + }, + { + "permission": "view_marketplace_item", + "filter": { + "operator": "IN", + "left_hand_side": {"entity_type": "marketplace_item"}, + "right_hand_side": {"collection": "ALL"}, + }, + }, + { + "permission": "view_runbook", + "filter": { + "operator": "IN", + "left_hand_side": {"entity_type": "runbook"}, + "right_hand_side": {"collection": "ALL"}, + }, + }, ] DEFAULT_CONTEXT = { @@ -591,3 +693,54 @@ 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"}, + }, + { + "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"}, + }, + ] From 635565ecad2c65b76d3681522e2739cb1e300474 Mon Sep 17 00:00:00 2001 From: Utkarsh Bairolia Date: Wed, 6 Dec 2023 15:01:18 +0530 Subject: [PATCH 10/16] added fix for developer and custom role (#349) I added the project reference in developer ACP for global scope. I added code to check for view_project and then added project references for custom roles. I fixed the Custom Roles filter to add only once if found. E.g. -> Add directory service only once when view/ search directory service permission is present. https://jira.nutanix.com/browse/ENG-612517?focusedId=5605872&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-5605872 (cherry picked from commit 29e49a8dea2552ab1a083b67b513c739f233b57c) --- calm/dsl/cli/acps.py | 35 ++++++++++++++++----- calm/dsl/cli/constants.py | 65 ++++++++++++++++----------------------- 2 files changed, 54 insertions(+), 46 deletions(-) diff --git a/calm/dsl/cli/acps.py b/calm/dsl/cli/acps.py index 2df19f3e..5e511af4 100644 --- a/calm/dsl/cli/acps.py +++ b/calm/dsl/cli/acps.py @@ -310,6 +310,9 @@ def create_acp(role, project, acp_users, acp_groups, name): elif role == "Developer": entity_filter_expression_list = ACP.ENTITY_FILTER_EXPRESSION_LIST.DEVELOPER + entity_filter_expression_list[4]["right_hand_side"]["uuid_list"] = [ + project_uuid + ] elif role == "Consumer": entity_filter_expression_list = ACP.ENTITY_FILTER_EXPRESSION_LIST.CONSUMER @@ -318,11 +321,13 @@ def create_acp(role, project, acp_users, acp_groups, name): entity_filter_expression_list = ACP.ENTITY_FILTER_EXPRESSION_LIST.OPERATOR 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 + ) project_collab_context[ "entity_filter_expression_list" ] = get_filters_custom_role( - role_uuid, client, ACP.CUSTOM_ROLE_SPECIFIC_COLLAB_FILTER + role_uuid, client, None, ACP.CUSTOM_ROLE_SPECIFIC_COLLAB_FILTER ) if cluster_uuids: @@ -394,7 +399,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, custom_role_filter_dict=None): +def get_filters_custom_role( + role_uuid, client, project_id=None, custom_role_filter_dict=None +): role, err = client.role.read(id=role_uuid) if err: @@ -411,12 +418,24 @@ def get_filters_custom_role(role_uuid, client, custom_role_filter_dict=None): if perm_name: permission_names.add(perm_name.lower()) entity_filter_expression_list = [] - custom_role_filter_dict = ( - ACP.CUSTOM_ROLE_PERMISSIONS_FILTERS if not custom_role_filter_dict else None - ) + if not custom_role_filter_dict: + custom_role_filter_dict = ACP.CUSTOM_ROLE_PERMISSIONS_FILTERS + if project_id: + custom_role_filter_dict.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_dict: - if perm_filter.get("permission") in permission_names: - entity_filter_expression_list.append(perm_filter.get("filter")) + 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 diff --git a/calm/dsl/cli/constants.py b/calm/dsl/cli/constants.py index 930c6550..b00d7dfd 100644 --- a/calm/dsl/cli/constants.py +++ b/calm/dsl/cli/constants.py @@ -268,6 +268,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"}, @@ -481,7 +486,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"}, @@ -489,7 +494,7 @@ class ENTITY_FILTER_EXPRESSION_LIST: }, }, { - "permission": "view_app_icon", + "permissions": ["view_app_icon"], "filter": { "operator": "IN", "right_hand_side": {"collection": "ALL"}, @@ -497,7 +502,7 @@ class ENTITY_FILTER_EXPRESSION_LIST: }, }, { - "permission": "view_name_category", + "permissions": ["view_name_category", "create_or_update_name_category"], "filter": { "operator": "IN", "right_hand_side": {"collection": "ALL"}, @@ -505,15 +510,7 @@ class ENTITY_FILTER_EXPRESSION_LIST: }, }, { - "permission": "create_or_update_name_category", - "filter": { - "operator": "IN", - "right_hand_side": {"collection": "ALL"}, - "left_hand_side": {"entity_type": "category"}, - }, - }, - { - "permission": "view_environment", + "permissions": ["view_environment"], "filter": { "operator": "IN", "left_hand_side": {"entity_type": "environment"}, @@ -521,7 +518,7 @@ class ENTITY_FILTER_EXPRESSION_LIST: }, }, { - "permission": "view_marketplace_item", + "permissions": ["view_marketplace_item"], "filter": { "operator": "IN", "left_hand_side": {"entity_type": "marketplace_item"}, @@ -529,7 +526,7 @@ class ENTITY_FILTER_EXPRESSION_LIST: }, }, { - "permission": "view_role", + "permissions": ["view_role"], "filter": { "operator": "IN", "right_hand_side": {"collection": "ALL"}, @@ -537,15 +534,7 @@ class ENTITY_FILTER_EXPRESSION_LIST: }, }, { - "permission": "view_directory_service", - "filter": { - "operator": "IN", - "right_hand_side": {"collection": "ALL"}, - "left_hand_side": {"entity_type": "directory_service"}, - }, - }, - { - "permission": "search_directory_service", + "permissions": ["view_directory_service", "search_directory_service"], "filter": { "operator": "IN", "right_hand_side": {"collection": "ALL"}, @@ -553,7 +542,7 @@ class ENTITY_FILTER_EXPRESSION_LIST: }, }, { - "permission": "view_identity_provider", + "permissions": ["view_identity_provider"], "filter": { "operator": "IN", "right_hand_side": {"collection": "ALL"}, @@ -561,7 +550,7 @@ class ENTITY_FILTER_EXPRESSION_LIST: }, }, { - "permission": "view_app_task", + "permissions": ["view_app_task"], "filter": { "operator": "IN", "left_hand_side": {"entity_type": "app_task"}, @@ -569,7 +558,7 @@ class ENTITY_FILTER_EXPRESSION_LIST: }, }, { - "permission": "view_app_variable", + "permissions": ["view_app_variable"], "filter": { "operator": "IN", "left_hand_side": {"entity_type": "app_variable"}, @@ -577,7 +566,7 @@ class ENTITY_FILTER_EXPRESSION_LIST: }, }, { - "permission": "view_resource_type", + "permissions": ["view_resource_type"], "filter": { "operator": "IN", "left_hand_side": {"entity_type": "resource_type"}, @@ -585,7 +574,7 @@ class ENTITY_FILTER_EXPRESSION_LIST: }, }, { - "permission": "view_custom_provider", + "permissions": ["view_custom_provider"], "filter": { "operator": "IN", "left_hand_side": {"entity_type": "custom_provider"}, @@ -593,7 +582,7 @@ class ENTITY_FILTER_EXPRESSION_LIST: }, }, { - "permission": "view_vm_recovery_point", + "permissions": ["view_vm_recovery_point"], "filter": { "operator": "IN", "left_hand_side": {"entity_type": "vm_recovery_point"}, @@ -601,7 +590,7 @@ class ENTITY_FILTER_EXPRESSION_LIST: }, }, { - "permission": "view_virtual_switch", + "permissions": ["view_virtual_switch"], "filter": { "operator": "IN", "left_hand_side": {"entity_type": "distributed_virtual_switch"}, @@ -609,7 +598,7 @@ class ENTITY_FILTER_EXPRESSION_LIST: }, }, { - "permission": "View_report_config", + "permissions": ["view_report_config"], "filter": { "operator": "IN", "left_hand_side": {"entity_type": "report_config"}, @@ -620,7 +609,7 @@ class ENTITY_FILTER_EXPRESSION_LIST: CUSTOM_ROLE_SPECIFIC_COLLAB_FILTER = [ { - "permission": "view_user", + "permissions": ["view_user"], "filter": { "operator": "IN", "right_hand_side": {"collection": "ALL"}, @@ -628,7 +617,7 @@ class ENTITY_FILTER_EXPRESSION_LIST: }, }, { - "permission": "view_virtual_machine", + "permissions": ["view_virtual_machine"], "filter": { "operator": "IN", "left_hand_side": {"entity_type": "vm"}, @@ -636,7 +625,7 @@ class ENTITY_FILTER_EXPRESSION_LIST: }, }, { - "permission": "view_user_group", + "permissions": ["view_user_group"], "filter": { "operator": "IN", "right_hand_side": {"collection": "ALL"}, @@ -644,7 +633,7 @@ class ENTITY_FILTER_EXPRESSION_LIST: }, }, { - "permission": "view_blueprint", + "permissions": ["view_blueprint"], "filter": { "operator": "IN", "left_hand_side": {"entity_type": "blueprint"}, @@ -652,7 +641,7 @@ class ENTITY_FILTER_EXPRESSION_LIST: }, }, { - "permission": "view_environment", + "permissions": ["view_environment"], "filter": { "operator": "IN", "left_hand_side": {"entity_type": "environment"}, @@ -660,7 +649,7 @@ class ENTITY_FILTER_EXPRESSION_LIST: }, }, { - "permission": "view_marketplace_item", + "permissions": ["view_marketplace_item"], "filter": { "operator": "IN", "left_hand_side": {"entity_type": "marketplace_item"}, @@ -668,7 +657,7 @@ class ENTITY_FILTER_EXPRESSION_LIST: }, }, { - "permission": "view_runbook", + "permissions": ["view_runbook"], "filter": { "operator": "IN", "left_hand_side": {"entity_type": "runbook"}, From 265bcfcf923bfd2278625f4366c1ea0d73256a63 Mon Sep 17 00:00:00 2001 From: Utkarsh Bairolia Date: Tue, 30 Apr 2024 19:57:13 +0530 Subject: [PATCH 11/16] added version check acp update (#423) ### PR Description __Summary__: Added version check ACP update for system and custom roles. Added check to verify if version < 3.8.0 creates the existing ACPs else create an updated ACP. tkt for ACP update: [ENG-622363](https://jira.nutanix.com/browse/ENG-622363) CALM Version: 3.8.0 __Test Plan__: __Bugs__: [CALM-44401](https://jira.nutanix.com/browse/CALM-44401) __Associated Dependent PR__: __Reviewers__: __Related PRs__: (cherry picked from commit e9c1ed2af1ae5b25175d06c070bed90a326b5e07) --- calm/dsl/cli/acps.py | 167 ++++++++++++++++++++++++--- calm/dsl/cli/constants.py | 234 +++++++++++++++++++++----------------- 2 files changed, 283 insertions(+), 118 deletions(-) diff --git a/calm/dsl/cli/acps.py b/calm/dsl/cli/acps.py index 5e511af4..845c49cb 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): @@ -288,6 +291,12 @@ def create_acp(role, project, acp_users, acp_groups, name): "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"][ "uuid_list" @@ -295,39 +304,54 @@ 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 ] - - # Adding vm filter for collab context. This is applicable only for project admin - project_collab_context["entity_filter_expression_list"].extend( - ACP.PROJECT_ADMIN_SPECIFIC_COLLAB_FILTER + 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 ] - elif role == "Consumer": + entity_filter_expression_list = get_updated_acp_filter_list( + role, entity_filter_expression_list, "global" + ) + + 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, 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, ACP.CUSTOM_ROLE_SPECIFIC_COLLAB_FILTER + role_uuid, client, None, collab_entity_filter_expression_list ) if cluster_uuids: @@ -400,7 +424,7 @@ def create_acp(role, project, acp_users, acp_groups, name): def get_filters_custom_role( - role_uuid, client, project_id=None, custom_role_filter_dict=None + role_uuid, client, project_id=None, custom_role_filter_list=None ): role, err = client.role.read(id=role_uuid) @@ -418,10 +442,12 @@ def get_filters_custom_role( if perm_name: permission_names.add(perm_name.lower()) entity_filter_expression_list = [] - if not custom_role_filter_dict: - custom_role_filter_dict = ACP.CUSTOM_ROLE_PERMISSIONS_FILTERS + 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_dict.append( + custom_role_filter_list.append( { "permissions": ["view_project"], "filter": { @@ -431,7 +457,7 @@ def get_filters_custom_role( }, } ) - for perm_filter in custom_role_filter_dict: + 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")) @@ -729,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.append(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.append(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/constants.py b/calm/dsl/cli/constants.py index b00d7dfd..635ec2d8 100644 --- a/calm/dsl/cli/constants.py +++ b/calm/dsl/cli/constants.py @@ -245,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 = [ @@ -298,16 +305,6 @@ class ENTITY_FILTER_EXPRESSION_LIST: "left_hand_side": {"entity_type": "custom_provider"}, "right_hand_side": {"collection": "ALL"}, }, - { - "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"}, - }, ] OPERATOR = [ @@ -331,16 +328,6 @@ class ENTITY_FILTER_EXPRESSION_LIST: "left_hand_side": {"entity_type": "custom_provider"}, "right_hand_side": {"collection": "ALL"}, }, - { - "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"}, - }, ] CONSUMER = [ @@ -389,16 +376,6 @@ class ENTITY_FILTER_EXPRESSION_LIST: "left_hand_side": {"entity_type": "custom_provider"}, "right_hand_side": {"collection": "ALL"}, }, - { - "operator": "IN", - "left_hand_side": {"entity_type": "vm_recovery_point"}, - "right_hand_side": {"collection": "ALL"}, - }, - { - "operator": "IN", - "left_hand_side": {"entity_type": "distributed_virtual_switch"}, - "right_hand_side": {"collection": "ALL"}, - }, ] PROJECT_ADMIN = [ @@ -467,21 +444,6 @@ class ENTITY_FILTER_EXPRESSION_LIST: "left_hand_side": {"entity_type": "custom_provider"}, "right_hand_side": {"collection": "ALL"}, }, - { - "operator": "IN", - "left_hand_side": {"entity_type": "vm_recovery_point"}, - "right_hand_side": {"collection": "ALL"}, - }, - { - "operator": "IN", - "left_hand_side": {"entity_type": "distributed_virtual_switch"}, - "right_hand_side": {"collection": "ALL"}, - }, - { - "operator": "IN", - "left_hand_side": {"entity_type": "report_config"}, - "right_hand_side": {"collection": "SELF_OWNED"}, - }, ] CUSTOM_ROLE_PERMISSIONS_FILTERS = [ @@ -581,57 +543,9 @@ class ENTITY_FILTER_EXPRESSION_LIST: "right_hand_side": {"collection": "ALL"}, }, }, - { - "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_blueprint"], "filter": { @@ -656,14 +570,6 @@ class ENTITY_FILTER_EXPRESSION_LIST: "right_hand_side": {"collection": "ALL"}, }, }, - { - "permissions": ["view_runbook"], - "filter": { - "operator": "IN", - "left_hand_side": {"entity_type": "runbook"}, - "right_hand_side": {"collection": "ALL"}, - }, - }, ] DEFAULT_CONTEXT = { @@ -708,13 +614,100 @@ class ENTITY_FILTER_EXPRESSION_LIST: "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 = [ { @@ -733,3 +726,38 @@ class ENTITY_FILTER_EXPRESSION_LIST: "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"}, + }, + }, + ] From c30caa3b4ab878457a2148be6e2c17866a86a3fa Mon Sep 17 00:00:00 2001 From: Utkarsh Bairolia Date: Fri, 3 May 2024 13:59:32 +0530 Subject: [PATCH 12/16] Minor fix for https://github.com/ideadevice/calm-dsl/commit/e9c1ed2af1ae5b25175d06c070bed90a326b5e07 (#434) Minor fix for https://github.com/ideadevice/calm-dsl/commit/e9c1ed2af1ae5b25175d06c070bed90a326b5e07 (cherry picked from commit 9cd6e61b7754ef290ea60d5997adcb2b9e49cc42) --- calm/dsl/cli/acps.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/calm/dsl/cli/acps.py b/calm/dsl/cli/acps.py index 845c49cb..876d04de 100644 --- a/calm/dsl/cli/acps.py +++ b/calm/dsl/cli/acps.py @@ -816,7 +816,7 @@ def get_updated_acp_filter_list_for_3_8_0_global_scope( else: filter_list.extend(ACP_3_8_0.ENTITY_FILTER_EXPRESSION_LIST.COMMON) if role == ROLE.PROJECT_ADMIN: - filter_list.append(ACP_3_8_0.ENTITY_FILTER_EXPRESSION_LIST.PROJECT_ADMIN) + filter_list.extend(ACP_3_8_0.ENTITY_FILTER_EXPRESSION_LIST.PROJECT_ADMIN) return filter_list @@ -839,7 +839,7 @@ def get_updated_acp_filter_list_for_3_8_0_collab_scope( if is_custom_role: filter_list.extend(ACP_3_8_0.CUSTOM_ROLE_SPECIFIC_COLLAB_FILTER) else: - filter_list.append(ACP_3_8_0.PROJECT_COLLAB_FILTER) + 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) From 9db1c9fe13bb2ab7b8f3e95cac5aa4add12541a2 Mon Sep 17 00:00:00 2001 From: Prabhat Dwivedi Date: Mon, 20 May 2024 11:46:05 +0530 Subject: [PATCH 13/16] Main Readme updated (#442) (cherry picked from commit 8a94a66dc8f056f580b178be6b19199a6d5f18d6) --- README.md | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index bb34e314..f9271810 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) From 7858a97a156b952ce80b612c9dd57e890d36f40b Mon Sep 17 00:00:00 2001 From: Prabhat Dwivedi Date: Mon, 20 May 2024 12:03:09 +0530 Subject: [PATCH 14/16] Bump version to 380 (#451) (cherry picked from commit a663b2ffad5b97487d936a4536d9bb8123ea4b48) --- CalmVersion | 2 +- calm/dsl/cli/main.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CalmVersion b/CalmVersion index eaf967fb..19811903 100644 --- a/CalmVersion +++ b/CalmVersion @@ -1 +1 @@ -3.7.2.2 +3.8.0 diff --git a/calm/dsl/cli/main.py b/calm/dsl/cli/main.py index ac124a51..e3315573 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 From 91506b439de7ff02923de223df1152cdcd5d33f7 Mon Sep 17 00:00:00 2001 From: Prabhat Dwivedi Date: Mon, 20 May 2024 14:30:15 +0530 Subject: [PATCH 15/16] Updated 380 release notes (#453) (cherry picked from commit bf2bc46608956f73d92514292c79e28bacdbdbaf) --- release-notes/3.8.0/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/release-notes/3.8.0/README.md b/release-notes/3.8.0/README.md index bc3798e1..03f0a447 100644 --- a/release-notes/3.8.0/README.md +++ b/release-notes/3.8.0/README.md @@ -10,11 +10,11 @@ # Bug Fixes/Improvements -- Deprecates python 2 escripts and changes the default flow of escript from python 2 to python 3. +- **`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. -- Other small bug fixes. From 5243e9fcb63c0e777d3ecdd0e932638069ef7832 Mon Sep 17 00:00:00 2001 From: Prabhat Dwivedi Date: Mon, 20 May 2024 10:35:01 +0000 Subject: [PATCH 16/16] updated release metadata to 380 --- metadata.json | 2 +- release_config.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/metadata.json b/metadata.json index 27cee2fb..222461b9 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_config.json b/release_config.json index 50e37ac8..719fc514 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": [ "" ],