Debian Codegraph @

docs/labs/lab02-inventory-operations/remove_devices_legacy.py

raw
1 # Copyright (c) 2021 Arista Networks, Inc.
2 # Use of this source code is governed by the Apache License 2.0
3 # that can be found in the COPYING file.
4
5 from cvprac.cvp_client import CvpClient
6 import ssl
7 ssl._create_default_https_context = ssl._create_unverified_context
8 import requests.packages.urllib3
9 requests.packages.urllib3.disable_warnings()
10
11 # Create connection to CloudVision using Service account token
12 with open("token.tok") as f:
13 token = f.read().strip('\n')
14
15 clnt = CvpClient()
16 clnt.connect(nodes=['cvp1'], username='', password='', api_token=token)
17
18 devices = ["50:08:00:a7:ca:c3","50:08:00:b1:5b:0b","50:08:00:60:c6:76",
19 "50:08:00:25:9d:36","50:08:00:8b:ee:b1","50:08:00:8c:22:49"]
20
21 # Remove devices from provisioning
22 # This is a legacy API call that removes the devices from Network Provisioning
23 # in CVP versions older than 2021.3.0, however it does not remove them from
24 # the Device Inventory as that requires the streaming agent (TerminAttr) to be shutdown,
25 # which this API does not support.
26 # To fully decommission a device the device_decommissioning() API can be used, which is
27 # supported from 2021.3.0+.
28 # Note that using the delete_devices() function post CVP 2021.3.0 the device will be
29 # automatically added back to the Undefined container.
30 clnt.api.delete_devices(devices)