diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-05-11 09:04:53 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-05-13 09:34:21 +0000 |
commit | 47553c43d71b7b1144f912ab9679f5b60e858fa2 (patch) | |
tree | 08378beaeeea8f9bb2686d3037c7b6f5062bb948 /docs/labs/lab06-provisioning/change_control_workflow_rapi.py | |
parent | Initial commit. (diff) | |
download | cvprac-47553c43d71b7b1144f912ab9679f5b60e858fa2.tar.xz cvprac-47553c43d71b7b1144f912ab9679f5b60e858fa2.zip |
Adding upstream version 1.3.1+dfsg.upstream/1.3.1+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'docs/labs/lab06-provisioning/change_control_workflow_rapi.py')
-rw-r--r-- | docs/labs/lab06-provisioning/change_control_workflow_rapi.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/docs/labs/lab06-provisioning/change_control_workflow_rapi.py b/docs/labs/lab06-provisioning/change_control_workflow_rapi.py new file mode 100644 index 0000000..299d16a --- /dev/null +++ b/docs/labs/lab06-provisioning/change_control_workflow_rapi.py @@ -0,0 +1,40 @@ +# Copyright (c) 2021 Arista Networks, Inc. +# Use of this source code is governed by the Apache License 2.0 +# that can be found in the COPYING file. +# +# NOTE: The following example is using the new Change Control Resource APIs supported in 2021.2.0 or newer and in CVaaS. +# For CVaaS service-account token based auth has to be used. + +from cvprac.cvp_client import CvpClient +import ssl +import uuid +from datetime import datetime +ssl._create_default_https_context = ssl._create_unverified_context +import requests.packages.urllib3 +requests.packages.urllib3.disable_warnings() + +# Create connection to CloudVision +clnt = CvpClient() +clnt.connect(['cvp1'],'username', 'password') + +# Generate change control id and change control name +cc_id = str(uuid.uuid4()) +name = f"Change_{datetime.now().strftime('%Y%m%d_%H%M%S')}" + +# Select the tasks and create a CC where all tasks will be run in parallel +tasks = ["1249","1250","1251","1252"] +clnt.api.change_control_create_for_tasks(cc_id, name, tasks, series=False) + +# Approve the change control +approve_note = "Approving CC via cvprac" +clnt.api.change_control_approve(cc_id, notes=approve_note) + +# # Schedule the change control +# # Executing scheduled CCs might only work post 2021.3.0+ +# schedule_note = "Scheduling CC via cvprac" +# schedule_time = "2021-12-23T03:17:00Z" +# clnt.api.change_control_schedule(cc_id,schedule_time,notes=schedule_note) + +# Start the change control +start_note = "Start the CC via cvprac" +clnt.api.change_control_start(cc_id, notes=start_note)
\ No newline at end of file |