-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #107 from controlm/run-on-demand-documentation
support run on-demand Automation-API #89
- Loading branch information
Showing
33 changed files
with
903 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Run On Demand" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from ctm_python_client.core.comm import Environment\n", | ||
"from aapi import *" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"[AutomationAPI Documentation](https://documents.bmc.com/supportu/API/Monthly/en-US/Documentation/API_Services_RunService.htm#run2)\n", | ||
"\n", | ||
"The `run_on_demand()` method in the Control-M Python Client allows you to execute individual jobs, folders, or subfolders dynamically without using Workflow. You do not need to deploy the jobs to the Control-M/EM database and the User Daily job does not need to trigger them. This is useful for event-driven job executions.\n", | ||
"\n", | ||
"This guide demonstrates how to use `run_on_demand()` with the `Job`, `Folder`, and `SubFolder` classes.\n", | ||
"\n", | ||
"***Requires Control-M/EM version 9.0.21.200***" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"### Code Example:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"+ echo Hello\n", | ||
"Hello\n", | ||
"\n", | ||
"Run Status\n", | ||
"--------------------------------------------------\n", | ||
" run_on_demand928 .................. Ended OK\n", | ||
" HelloJob ...................... Ended OK\n", | ||
"\n", | ||
"Run Status\n", | ||
"--------------------------------------------------\n", | ||
" TestFolder ........................ Ended OK\n", | ||
" HelloJob .......................... Ended OK\n", | ||
"\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"import time\n", | ||
"# Step 1: Define the Job, Folder, Sub-Folder\n", | ||
"demand_job = JobCommand('HelloJob', command='echo Hello')\n", | ||
"demand_sub_folder = SubFolder(\"TestSubFolder\", job_list=[demand_job])\n", | ||
"demand_folder = Folder(\"TestFolder\", job_list=[demand_job])\n", | ||
"\n", | ||
"# Step 2: Define an Environment\n", | ||
"env = Environment.create_onprem(host='controlm', username='***', password='****')\n", | ||
"# Step 3: Run the Job On Demand\n", | ||
"run_demand_job = demand_job.run_on_demand(\n", | ||
" environment=env,\n", | ||
" run_as='user',\n", | ||
" controlm_server='ControlM'\n", | ||
" )\n", | ||
"time.sleep(4)\n", | ||
"run_demand_job.print_output('HelloJob')\n", | ||
"\n", | ||
"# Step 4: Run the SubFolder On Demand\n", | ||
"run_demand_sub_folder = demand_sub_folder.run_on_demand(\n", | ||
" environment=env,\n", | ||
" run_as='user',\n", | ||
" controlm_server='ControlM'\n", | ||
" )\n", | ||
"time.sleep(4)\n", | ||
"run_demand_sub_folder.print_statuses()\n", | ||
"\n", | ||
"# Step 5: Run the Folder On Demand\n", | ||
"run_demand_folder = demand_folder.run_on_demand(\n", | ||
" environment=env,\n", | ||
" run_as='user',\n", | ||
" controlm_server='ControlM'\n", | ||
" )\n", | ||
"time.sleep(4)\n", | ||
"run_demand_folder.print_statuses()\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"### Additional Notes:\n", | ||
"\n", | ||
"- Ensure that the *Control-M/EM version is 9.0.21.200* or higher. Older versions not support the `run_on_demand()` method.\n", | ||
"- `Folder`s and `Subfolder`s must include at least one `Job`. If a `Folder` or `SubFolder` does not contain any jobs, an exception will be raised with the error:\n", | ||
"`\"Run is not allowed for JSON without jobs\"`\n", | ||
"- The `run_as` user must have the necessary permissions in Control-M.\n", | ||
"- The `controlm_server` parameter specifies the Control-M server responsible for execution." | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "venv", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.8.9" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.