| 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 |
from cvprac.cvp_client_errors import CvpApiError |
| 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 |
from getpass import getpass |
| 12 |
|
| 13 |
# Create connection to CloudVision |
| 14 |
clnt = CvpClient() |
| 15 |
clnt.connect(['cvp1'],'username', 'password') |
| 16 |
|
| 17 |
username = "cvpuser2" |
| 18 |
password = getpass() |
| 19 |
role = "network-admin" |
| 20 |
status = "Enabled" |
| 21 |
first_name = "Cloud" |
| 22 |
last_name = "Vision" |
| 23 |
email = "[email protected]" |
| 24 |
utype = "TACACS" |
| 25 |
|
| 26 |
try: |
| 27 |
clnt.api.add_user(username,password,role,status,first_name,last_name,email,utype) |
| 28 |
except CvpApiError as e: |
| 29 |
print(e) |