Registry / http-networking / cvprac

cvprac

JSON →
library2.1.0pypypi✓ verified 90d ago

cvprac is a Python client library designed to interact with the Arista CloudVision Portal (CVP) RESTful API. It simplifies API calls, handles session management, error retries, and abstracts CVP version-specific API changes, enabling easier automation and integration with CVP. The library is actively maintained, with a typical release cadence of several updates per year, and is currently at version 1.4.2.

pip install cvprac
INSTALL
IMPORT
SIG · CVPRAC
C
cvprac
http-networkingpythonv2.1.0
Install
2.5s avg
Import
607ms
Disk
21MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v2.1.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.915 runs
installs and imports cleanly · install 0.0s · import 0.641s · 22.5MB
glibc
py 3.10–3.915 runs
installs and imports cleanly · install 2.5s · import 0.573s · 23MB
21MB installed
● package 21MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

CvpClient
✓ from cvprac.cvp_client import CvpClient

This quickstart demonstrates how to establish a connection to an Arista CloudVision Portal (CVP) instance using `cvprac.CvpClient`. It prioritizes API token authentication, suitable for both CloudVision as-a-Service (CVaaS) and on-prem deployments, falling back to username/password for older on-prem setups. It then fetches and prints basic CVP information. Ensure `CVP_HOST` and either `CVP_API_TOKEN` or `CVP_USERNAME`/`CVP_PASSWORD` environment variables are set.

import os from cvprac.cvp_client import CvpClient # Environment variables for CVP connection CVP_HOST = os.environ.get('CVP_HOST', 'your_cvp_ip_or_hostname') CVP_API_TOKEN = os.environ.get('CVP_API_TOKEN', 'your_api_token') # For CVaaS or On-prem token-based auth CVP_USERNAME = os.environ.get('CVP_USERNAME', '') # For On-prem username/password auth (deprecated for CVaaS) CVP_PASSWORD = os.environ.get('CVP_PASSWORD', '') # For On-prem username/password auth (deprecated for CVaaS) def main(): client = CvpClient() try: # Connect using API Token (recommended for CVaaS and newer on-prem) if CVP_API_TOKEN and CVP_HOST != 'your_cvp_ip_or_hostname': print(f"Attempting connection to {CVP_HOST} using API Token...") client.connect( nodes=[CVP_HOST], username=CVP_USERNAME, # Can be empty if only using api_token password=CVP_PASSWORD, # Can be empty if only using api_token api_token=CVP_API_TOKEN, is_cvaas=CVP_HOST.endswith('.arista.io') # Set based on hostname ) # Fallback to username/password if no token provided (primarily for older on-prem) elif CVP_USERNAME and CVP_PASSWORD and CVP_HOST != 'your_cvp_ip_or_hostname': print(f"Attempting connection to {CVP_HOST} using username/password...") client.connect( nodes=[CVP_HOST], username=CVP_USERNAME, password=CVP_PASSWORD ) else: print("Please set CVP_HOST and either CVP_API_TOKEN or CVP_USERNAME/CVP_PASSWORD environment variables or replace placeholders.") return print("Successfully connected to CVP.") cvp_info = client.api.get_cvp_info() print(f"CVP Version: {cvp_info.get('version')}") print(f"CVP Build: {cvp_info.get('build')}") except Exception as e: print(f"Error connecting or fetching info: {e}") finally: # It's good practice to logout to close the session try: if client and client.is_connected: client.logout() print("Logged out successfully.") except Exception as e: print(f"Error during logout: {e}") if __name__ == '__main__': main()
Debug
Known issues
breakingFor CloudVision as-a-Service (CVaaS) deployments, username/password authentication was removed in `cvprac` v1.0.6/v1.2.0. Only API tokens are supported for CVaaS connections now.
fix
Migrate to API token-based authentication. Ensure `api_token` parameter is used with `client.connect()`.
affects: >=1.0.6
deprecatedThe `cvaas_token` parameter in `CvpClient.connect()` has been deprecated in favor of the more generic `api_token` parameter. While `cvaas_token` might still work for now, it will be removed in future versions.
fix
Update all calls to `client.connect()` to use `api_token` instead of `cvaas_token`.
affects: >=1.4.0
gotcha`cvprac` v1.4.0 explicitly updated `setup.py` to reference Python 3 only, and later versions list specific Python 3 classifiers. While it may have worked on Python 2 in very old versions, current versions are Python 3 exclusive.
fix
Ensure your environment is running Python 3.7 or newer. Old Python 2 scripts will likely fail.
affects: >=1.4.0
gotchaThe library attempts to abstract CVP API changes across different CVP versions. However, specific API endpoints or behaviors can still change, requiring awareness of your CVP version. For example, exception handling for network provisioning APIs was added for CVP 2025.2.X+ in v1.4.2, implying older versions might not have robust error handling for these operations.
fix
Always refer to the Arista CVP API documentation for your specific CVP version. Test automation against CVP upgrades. Consult `cvprac` release notes for CVP version validations.
affects: All versions, specific CVP versions affect behavior.
Errors
Common errors & fixes
from pkg_resources import parse_version ModuleNotFoundError: No module named 'pkg_resources'
The `pkg_resources` module was removed from setuptools and is no longer the recommended way to parse versions. `cvprac` v1.4.0 migrated to `packaging`.
fix
Ensure `cvprac` version is 1.4.0 or newer. If you are using an older `cvprac` and cannot upgrade, you might need to ensure `setuptools` is installed in a version that still provides `pkg_resources` (though this is not recommended). Prefer upgrading `cvprac`.
cvprac.cvp_client_errors.CvpLoginError: A CvpLoginError is raised if a connection could not be established to any of the nodes.
Incorrect CVP hostname/IP, wrong username/password/API token, protocol mismatch (e.g., trying HTTP on an HTTPS-only CVP), or network connectivity issues to the CVP instance.
fix
Verify CVP `nodes` list, `username`, `password`, `api_token`, and `protocol` parameters in `client.connect()`. Ensure CVP is reachable from the client machine and that API token has correct permissions. For CVaaS, confirm `is_cvaas=True` and use an API token.
cvprac.cvp_client_errors.CvpRequestError: POST: https://.../api/v3/... : Request Error: Gateway Timeout - rpc error: code = DeadlineExceeded desc = failed to connect to service...
This often occurs during complex operations like Change Control execution on CVaaS, indicating network latency, CVP backend service issues, or insufficient permissions for the service account/user performing the action.
fix
Check network connectivity and latency to the CVP API endpoint. Verify the assigned roles/permissions for the API token or user account being used, especially for executing tasks or change controls. For CVaaS, ensure any necessary firewall rules for egress traffic from the CVP instance are configured to reach target devices.
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
A generic network connection error, often caused by CVP server instability, incorrect CVP URL, or a network device (firewall, load balancer) terminating the connection prematurely.
fix
Double-check the CVP hostname/IP. Monitor CVP health. Increase connection `timeout` in `client.connect()`. `cvprac` has internal retry mechanisms, but persistent errors suggest a fundamental network or server issue.
Upgrade
Version history
2.1.0latest on PyPI · released May 26, 2026
Audit
Dependencies
requestsrequiredRequired for making HTTP requests to the CVP API.
packagingrequiredUsed internally for parsing and comparing version numbers, particularly for CVP version handling.
Agent activity
18 hits · last 30 days
node
16
OpenAI (training)
1
Resources
cvprac — pip install cvprac · libregistry