| 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 cvprac.cvp_client import CvpClient |
| 12 |
|
| 13 |
# Create connection to CloudVision using Service Account token |
| 14 |
with open("cvaas.tok") as f: |
| 15 |
token = f.read().strip('\n') |
| 16 |
|
| 17 |
clnt = CvpClient() |
| 18 |
clnt.connect(nodes=['www.arista.io'], username='', password='', is_cvaas=True, api_token=token) |
| 19 |
|
| 20 |
username = "john" |
| 21 |
password = "" |
| 22 |
role = "network-admin" |
| 23 |
status = "Enabled" |
| 24 |
first_name = "John" |
| 25 |
last_name = "Smith" |
| 26 |
email = "[email protected]" |
| 27 |
utype = "SSO" |
| 28 |
|
| 29 |
try: |
| 30 |
clnt.api.add_user(username,password,role,status,first_name,last_name,email,utype) |
| 31 |
except CvpApiError as e: |
| 32 |
print(e) |