diff --git a/docs/Py2-Py3 Migration/index.md b/docs/Py2-Py3 Migration/index.md new file mode 100644 index 00000000..96eb8fa6 --- /dev/null +++ b/docs/Py2-Py3 Migration/index.md @@ -0,0 +1,109 @@ +## Updating eScript Tasks and Variables of Python 2 to Python 3 Using Self-Service DSL + +This article provides the necessary steps to update eScripts in the tasks of your deployed applications from Python 2 to Python 3. + +### Limitations + +- For multi-VM applications, use the following Self-Service DSL steps to update application scripts to Python 3. + +- For single-VM applications, use the app edit to update application scripts to Python 3. + +### Important Points : +• Single-VM applications with custom actions having dynamic variables with secrets can be updated using Self-Service DSL only.
+• Snapshot config tasks or variables can be updated using Self-Service DSL only.
+• Patch-config action updates are not currently supported in both Single-VM and Multi-VM applications. As a workaround, you can soft delete and brownfield import applications.
+ +### Procedure + +1. Describe the application that needs to be modified. For example: +``` +calm describe app-migratable-entities +``` +Where `` is the name of the deployed application in which you can update the script from Python 2 to Python 3. + +2. Decompile the application blueprint. For example: +``` +calm decompile app-migratable-bp --dir +``` +Where `` is an optional argument for the directory name in which you want to decompile the application blueprint. + +3. Edit the blueprint to update the task to use Python 3 scripts. + +4. Update the application. +``` +calm update app-migratable-bp -f +``` +Where `` is the location of the decompiled blueprint file (the blueprint file in which you updated tasks to use Python 3 scripts). + +### Example + +#### Update Custom Action Scripts of a Deployed Multi-VM Application + +Suppose you have a deployed Multi-VM app with a custom action with the following details: + +• Application name: azure-postgres-server
+• Custom action name: CustomAction1
+• An Execute task of type Python 2 eScript within the custom action: +``` +#py2 +text = "Sample Runbook with Escript Task" +encoded_text = base64.b64encode(text) +print "encoded string is: ", encoded_text +``` + +To update this script in the custom action to Python 3 using Self-Service DSL, do the following: + +1. Use the following command to display the eScript tasks or variables that you can migrate: + ``` + $ calm describe app-migratable-entities azure-postgres-server + ``` + + Where `azure-postgres-server` is the application name. + +2. Create a directory and decompile the application blueprint using the following command: + ``` + $ calm decompile app-migratable-bp azure-postgres- server --dir appeditescript + ``` + Where `appeditescript` is the directory in which the application blueprint is decompiled. The decompiled blueprint only contains eScript tasks and variables. + +3. Navigate to your working directory: + ``` + $ cd appeditescript/ + ``` + +4. To update the function reference, open the file and update the reference from `CalmTask.Exec.escript.py2` to `CalmTask.Exec.escript.py3`. + ``` + CalmTask.Exec.escript.py3( + name="B64 usage task", + filename=os.path.join("scripts", "Profile_Default_Action_CustomAction1_Task_B64usagetask.py"), + target=ref(Service1) + ) + ``` + +5. Navigate to the scripts file: + ``` + $ cd scripts/ + ``` +6. Open the file `Profile_Default_Action_CustomAction1_Task_B64usagetask.py` to update the existing Python 2 script to Python 3. + ``` + #py3 + text = "Updated Esctrip to Py3" + encoded_text = base64.b64encode(text.encode()) + print("encoded string is", encoded_text.decode()) + + ``` + +7. Run the following command to update the application: + ``` + $ calm update app-migratable-bp azure-postgres-server - f appeditescript/blueprint.py + ``` + The following output indicates that the task has been updated in the application: + ``` + Application update is successful. Got Action Runlog uuid: + 40ba0cd0-60cc-4d01-97ff-3ad3516e3b7b + Update messages: + [App_profile.Default.Action.Custom Action1] Task 'B64 + usage task' updated in Application + ``` + This command updates only the scripts of the tasks or variables in the application. Open the application and verify the updates. + \ No newline at end of file diff --git a/release-notes/3.7.2.1/index.md b/release-notes/3.7.2.1/index.md new file mode 100644 index 00000000..1ecf730f --- /dev/null +++ b/release-notes/3.7.2.1/index.md @@ -0,0 +1,6 @@ +# Major Feats + +## Python2 to Python3 Escript Migration +This release is majorly focussed on "FEAT 14256 eScript Update to Python 3". Based on the decision that the Python Software Foundation (PSF) took to discontinue support for Python 2, Nutanix has decided to end support for Python 2 on June 30, 2024. + +Customers can use Calm-DSL to update the escripts used in their application from python2 to python3. For detailed explanation refer [here](../../docs/Py2-Py3%20Migration/index.md) \ No newline at end of file