Debian Codegraph @

docs/labs/lab04-container-management/rename_container.py

raw
1 from cvprac.cvp_client import CvpClient
2 import ssl
3 ssl._create_default_https_context = ssl._create_unverified_context
4 import requests.packages.urllib3
5 requests.packages.urllib3.disable_warnings()
6
7 # Create connection to CloudVision
8 clnt = CvpClient()
9 clnt.connect(['cvp1'],'username', 'password')
10 oldName = "test"
11 newName = "test121"
12
13 container_id = clnt.api.get_container_by_name(oldName)['key']
14
15 data = {"data":[{"info": "Container {} renamed from {}".format(newName, oldName),
16 "infoPreview": "Container {} renamed from {}".format(newName, oldName),
17 "action": "update",
18 "nodeType": "container",
19 "nodeId": container_id,
20 "toId":"",
21 "fromId":"",
22 "nodeName": newName,
23 "fromName": "",
24 "toName": "",
25 "toIdType": "container",
26 "oldNodeName": oldName
27 }
28 ]
29 }
30
31 clnt.api._add_temp_action(data)
32 clnt.api._save_topology_v2([])