Debian Codegraph @

docs/labs/lab03-configlet-management/backup_configlets.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 # Get configlets and save them to individual files
6 from cvprac.cvp_client import CvpClient
7 import ssl
8 ssl._create_default_https_context = ssl._create_unverified_context
9 import requests.packages.urllib3
10 requests.packages.urllib3.disable_warnings()
11
12 # Create connection to CloudVision
13 clnt = CvpClient()
14 clnt.connect(['cvp1'],'username', 'password')
15
16 configlets = clnt.api.get_configlets(start=0,end=0)
17
18 for configlet in configlets['data']:
19 with open(configlet['name'],'w') as f:
20 f.write(configlet['config'])