1
0
Fork 0

Adding upstream version 1.3.1+dfsg.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-05 14:15:47 +01:00
parent 455a3d9fdb
commit d2e39936a0
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
95 changed files with 10747 additions and 0 deletions

View file

@ -0,0 +1,5 @@
username,first_name,last_name,email,user_type,role,status
alice,,,alice@abc.xyz,SSO,network-admin,Enabled
bob,,,bob@abc.xyz,SSO,network-admin,Enabled
jane,Jane,Smith,jane@abc.xyz,SSO,network-admin,Enabled
john,John,Smith,john@abc.xyz,SSO,network-admin,Enabled
1 username first_name last_name email user_type role status
2 alice alice@abc.xyz SSO network-admin Enabled
3 bob bob@abc.xyz SSO network-admin Enabled
4 jane Jane Smith jane@abc.xyz SSO network-admin Enabled
5 john John Smith john@abc.xyz SSO network-admin Enabled

View file

@ -0,0 +1,32 @@
# Copyright (c) 2021 Arista Networks, Inc.
# Use of this source code is governed by the Apache License 2.0
# that can be found in the COPYING file.
from cvprac.cvp_client import CvpClient
from cvprac.cvp_client_errors import CvpApiError
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
import requests.packages.urllib3
requests.packages.urllib3.disable_warnings()
from cvprac.cvp_client import CvpClient
# Create connection to CloudVision using Service Account token
with open("cvaas.tok") as f:
token = f.read().strip('\n')
clnt = CvpClient()
clnt.connect(nodes=['www.arista.io'], username='', password='', is_cvaas=True, api_token=token)
username = "john"
password = ""
role = "network-admin"
status = "Enabled"
first_name = "John"
last_name = "Smith"
email = "john.smith@abc.xyz"
utype = "SSO"
try:
clnt.api.add_user(username,password,role,status,first_name,last_name,email,utype)
except CvpApiError as e:
print(e)

View file

@ -0,0 +1,29 @@
# Copyright (c) 2021 Arista Networks, Inc.
# Use of this source code is governed by the Apache License 2.0
# that can be found in the COPYING file.
from cvprac.cvp_client import CvpClient
from cvprac.cvp_client_errors import CvpApiError
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
import requests.packages.urllib3
requests.packages.urllib3.disable_warnings()
from getpass import getpass
# Create connection to CloudVision
clnt = CvpClient()
clnt.connect(['cvp1'],'username', 'password')
username = "cvpuser2"
password = getpass()
role = "network-admin"
status = "Enabled"
first_name = "Cloud"
last_name = "Vision"
email = "cvp@arista.com"
utype = "TACACS"
try:
clnt.api.add_user(username,password,role,status,first_name,last_name,email,utype)
except CvpApiError as e:
print(e)

View file

@ -0,0 +1,29 @@
# Copyright (c) 2021 Arista Networks, Inc.
# Use of this source code is governed by the Apache License 2.0
# that can be found in the COPYING file.
from cvprac.cvp_client import CvpClient
from cvprac.cvp_client_errors import CvpApiError
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
import requests.packages.urllib3
requests.packages.urllib3.disable_warnings()
from cvprac.cvp_client import CvpClient
import csv
# Create connection to CloudVision using Service Account token
with open("cvaas.tok") as f:
token = f.read().strip('\n')
clnt = CvpClient()
clnt.connect(nodes=['www.arista.io'], username='', password='', is_cvaas=True, api_token=token)
with open("aaa_users.csv") as csvfile:
for i in csv.DictReader(csvfile):
data = dict(i)
try:
clnt.api.add_user(data['username'], "", data['role'], data['status'], data['first_name'], data['last_name'], data['email'], data['user_type'])
except CvpApiError as e:
print(e)
print ("Adding user {} to CVaaS".format(data['username']))

View file

@ -0,0 +1,20 @@
# Copyright (c) 2021 Arista Networks, Inc.
# Use of this source code is governed by the Apache License 2.0
# that can be found in the COPYING file.
from cvprac.cvp_client import CvpClient
from cvprac.cvp_client_errors import CvpApiError
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
import requests.packages.urllib3
requests.packages.urllib3.disable_warnings()
# Create connection to CloudVision using user/password (on-prem only)
clnt = CvpClient()
clnt.connect(['cvp1'],'username', 'password')
username = "cvprac2"
description = "test cvprac"
roles = ["network-admin", "clouddeploy"] # both role names and role IDs are supported
status = 1 # 1 is equivalent to "ACCOUNT_STATUS_ENABLED"
clnt.api.svc_account_set(username, description, roles, status)

View file

@ -0,0 +1,23 @@
# Copyright (c) 2021 Arista Networks, Inc.
# Use of this source code is governed by the Apache License 2.0
# that can be found in the COPYING file.
from cvprac.cvp_client import CvpClient
from cvprac.cvp_client_errors import CvpApiError
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
import requests.packages.urllib3
requests.packages.urllib3.disable_warnings()
# Create connection to CloudVision using user/password (on-prem only)
clnt = CvpClient()
clnt.connect(['cvp1'],'username', 'password')
username = "cvprac2"
duration = "31536000s" # 1 year validity
description = "test cvprac"
svc_token = clnt.api.svc_account_token_set(username, duration, description)
# Write the token to file in <username>.tok format
with open(svc_token[0]['value']['user'] + ".tok", "w") as f:
f.write(svc_token[0]['value']['token'])

View file

@ -0,0 +1,32 @@
# Copyright (c) 2021 Arista Networks, Inc.
# Use of this source code is governed by the Apache License 2.0
# that can be found in the COPYING file.
#
# Example script to generate the TerminAttr token via REST API from CVaaS and CV on-prem
# and save them to a file
from cvprac.cvp_client import CvpClient
from pprint import pprint as pp
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
import requests.packages.urllib3
requests.packages.urllib3.disable_warnings()
# Reading the service account token from a file
with open("cvaas.tok") as f:
token = f.read().strip('\n')
clnt = CvpClient()
clnt.connect(nodes=['www.arista.io'], username='',password='',is_cvaas=True, api_token=token)
terminattr_token = clnt.api.create_enroll_token('720h')
with open('cv-onboarding-token', 'w') as f:
f.write(terminattr_token[0]['enrollmentToken']['token'])
primary = CvpClient()
primary.connect(nodes=['cvp1'], username='username',password='password')
terminattr_token = primary.api.create_enroll_token('720h')
with open('token', 'w') as f:
f.write(terminattr_token['data'])

View file

@ -0,0 +1 @@
<copy service account token here>

View file

@ -0,0 +1,16 @@
# Copyright (c) 2021 Arista Networks, Inc.
# Use of this source code is governed by the Apache License 2.0
# that can be found in the COPYING file.
from cvprac.cvp_client import CvpClient
from cvprac.cvp_client_errors import CvpApiError
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
import requests.packages.urllib3
requests.packages.urllib3.disable_warnings()
# Create connection to CloudVision using user/password (on-prem only)
clnt = CvpClient()
clnt.connect(['cvp1'],'username', 'password')
clnt.api.svc_account_delete_expired_tokens()

View file

@ -0,0 +1,17 @@
# Copyright (c) 2021 Arista Networks, Inc.
# Use of this source code is governed by the Apache License 2.0
# that can be found in the COPYING file.
from cvprac.cvp_client import CvpClient
from cvprac.cvp_client_errors import CvpApiError
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
import requests.packages.urllib3
requests.packages.urllib3.disable_warnings()
# Create connection to CloudVision using user/password (on-prem only)
clnt = CvpClient()
clnt.connect(['cvp1'],'username', 'password')
username = "cvprac2"
clnt.api.svc_account_delete(username)

View file

@ -0,0 +1,22 @@
# Copyright (c) 2021 Arista Networks, Inc.
# Use of this source code is governed by the Apache License 2.0
# that can be found in the COPYING file.
from cvprac.cvp_client import CvpClient
from cvprac.cvp_client_errors import CvpApiError
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
import requests.packages.urllib3
requests.packages.urllib3.disable_warnings()
# Create connection to CloudVision using user/password (on-prem only)
clnt = CvpClient()
clnt.connect(['cvp1'],'username', 'password')
svc_accounts = clnt.api.svc_account_get_all()
created_by = 'john.smith'
# Delete service accounts created by user john.smith
for account in svc_accounts:
if account['value']['created_by'] == created_by:
clnt.api.svc_account_delete(account['value']['key']['name'])

View file

@ -0,0 +1,20 @@
# Copyright (c) 2021 Arista Networks, Inc.
# Use of this source code is governed by the Apache License 2.0
# that can be found in the COPYING file.
from cvprac.cvp_client import CvpClient
from cvprac.cvp_client_errors import CvpApiError
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
import requests.packages.urllib3
requests.packages.urllib3.disable_warnings()
from cvprac.cvp_client import CvpClient
with open("cvaas.tok") as f:
token = f.read().strip('\n')
clnt = CvpClient()
clnt.connect(nodes=['www.arista.io'], username='', password='', is_cvaas=True, api_token=token)
user_info = clnt.api.get_user('kishore')
print (user_info)

View file

@ -0,0 +1,34 @@
# Copyright (c) 2021 Arista Networks, Inc.
# Use of this source code is governed by the Apache License 2.0
# that can be found in the COPYING file.
from cvprac.cvp_client import CvpClient
from cvprac.cvp_client_errors import CvpApiError
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
import requests.packages.urllib3
requests.packages.urllib3.disable_warnings()
# Create connection to CloudVision using user/password (on-prem only)
clnt = CvpClient()
clnt.connect(['cvp1'],'username', 'password')
# Get all service accounts states
accounts = clnt.api.svc_account_get_all()
# Get specific service account state
account = clnt.api.svc_account_get_one("cvprac2")
# Get all service account token states
tokens = clnt.api.svc_account_token_get_all()
# Get specific token state
token = clnt.api.svc_account_token_get_one("9bfb39ff892c81d6ac9f25ff95d0389719595feb")
# Delete a service account token
clnt.api.svc_account_token_delete("9bfb39ff892c81d6ac9f25ff95d0389719595feb")