Skip to main content

Arista CloudVision Python Library

The Arista CloudVision Python library provides access to Arista's CloudVision APIs for use in Python applications.

Documentation

API Documentation for this library can be found here.

Documentation for CloudVision's Resource APIs can be found here.

Documentation for generic access to CloudVision can be found at CloudVision Connector.

Installation

Install via pip:

pip install --upgrade cloudvision

Or from source:

python setup.py install

Requirements

  • CloudVision Resource APIs: Python 3.7+
  • CloudVision Connector: Python 3.7+
  • Examples: Python 3.7+

Resource APIs

Cloudvision APIs are state based, resource-oriented APIs modeled in Protobuf and accessed over gRPC using a standardized set of RPC verbs.

CloudVision is a powerful platform that processes and stores tremendous amounts of network data. It knows the topology of the network, device configuration, interface activity and other network events. These APIs allow access to fleet-wide data access and control, forming a management-plane with consistent usage.

For example, consider the following script that gets all existing and then watches for new CloudVision events of critical severity and notifies an administrator when raised and notes it on the event:

import time
import google.protobuf.wrappers_pb2
import grpc
from arista.event.v1 import models, services

# setup credentials as channelCredentials

with grpc.secure_channel("www.arista.io:443", channelCredentials) as channel:
    event_stub = services.EventServiceStub(channel)
    event_annotation_stub = services.EventAnnotationConfigServiceStub(channel)

    event_watch_request = services.EventStreamRequest(
        partial_eq_filter=[models.Event(severity=models.EVENT_SEVERITY_CRITICAL)],
    )
    for resp in event_stub.Subscribe(event_watch_request):
        print(f"Critical event {resp.title.value} raised at {resp.key.timestamp}")
        # send alert here via email, webhook, or incident reporting tool

        # then make a note on the event indicating an alert has been sent
        now_ms = int(time.time() * 1000)
        notes_to_set = {
            now_ms: models.EventNoteConfig(
                note=google.protobuf.wrappers_pb2.StringValue(
                    value="Administrator alerted",
                ),
            ),
        }
        annotation_config = models.EventAnnotationConfig(
            key=resp.key,
            notes=models.EventNotesConfig(
                notes=notes_to_set,
            ),
        )
        event_note_update = services.EventAnnotationConfigSetRequest(value=annotation_config)
        event_annotation_stub.Set(event_note_update)

Async support

Starting from version 1.26.1+ it is possible to use alternative GRPC client based on grpclib,that supports pure-python async stubs. This stubs could be found in cloudvision.api.arista module. More specific information and specifications are provided in the API documentation While two types of stubs are supported, it is recommended to use ones from cloudvision.api.arista, as they use more idiomatic structure, naming conventions and leverage standard python library to describe data model.

Example below shows how to retrieve a list of devices:

import asyncio
from cloudvision.api.client import AsyncCVClient
from cloudvision.api.arista.inventory.v1 import DeviceServiceStub, DeviceStreamRequest

async def get_devices():
    client = AsyncCVClient.from_token('<your service account token>', 'your-cvp.io')

    # get channel
    with client as channel:

        # pass it to the stub
        service = DeviceServiceStub(channel)

        # execute one of stub's methods
        async for item in service.get_all(DeviceStreamRequest()):
            print(item)

asyncio.run(get_devices())

CloudVision Connector

CloudVision Connector is a Python implementation of a GRPC client for CloudVision. It takes care of getting and publishing data and datasets, and also provides utilities for data representation.

Getting started

This is a small example advertising a few of the GRPC client capabilities. This example prints info from all devices streaming into CloudVision.

targetDataset = "analytics"
path = ["DatasetInfo", "Devices"]
# No filtering done on keys, accept all
keys = []
ProtoBufQuery = CreateQuery([(path, keys)], targetDataset)
with GRPCClient("my-cv-host:9900") as client:
     for notifBatch in client.Get([query]):
         for notif in notifBatch["notifications"]:
             # Get timestamp for all update here with notif.Timestamp
             PrettyPrint(notif["updates"])

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cloudvision-1.32.1.tar.gz (847.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cloudvision-1.32.1-py3-none-any.whl (955.9 kB view details)

Uploaded Python 3

File details

Details for the file cloudvision-1.32.1.tar.gz.

File metadata

  • Download URL: cloudvision-1.32.1.tar.gz
  • Upload date:
  • Size: 847.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for cloudvision-1.32.1.tar.gz
Algorithm Hash digest
SHA256 674870b6b5c21a7120f5e77f9ea6a8563525629b50f53bb7775b08284291dc69
MD5 bbe6a9ab49cf461efe5f5422f7a8fdad
BLAKE2b-256 dc8ac61cbcaf3af409c71555a28c1d50da32d74d401f229e99951ed695c37dc4

See more details on using hashes here.

File details

Details for the file cloudvision-1.32.1-py3-none-any.whl.

File metadata

  • Download URL: cloudvision-1.32.1-py3-none-any.whl
  • Upload date:
  • Size: 955.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for cloudvision-1.32.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b68f20b72ecdd1ecb142d478942e9e02e92bdec363d80a6af51902fde11e220d
MD5 1151f1d6d865d15d414fe782fc9cbc9b
BLAKE2b-256 166e0a4f0c93f3f6a91df5025eef75d98bbc1ac2bb1d0550beac5fb00bbcd97c

See more details on using hashes here.

Release history Release notifications | RSS feed

1.33.0

2 files

This release

1.32.1 This release

2 files

1.32.0

2 files

1.31.0

2 files

1.30.6

2 files

1.30.5

2 files

1.30.4

2 files

1.30.3

2 files

1.30.2

2 files

1.30.1

2 files

1.30.0

2 files

1.29.1

2 files

1.29.0

2 files

1.28.0

2 files

1.27.1

2 files

1.27.0

2 files

1.26.4

2 files

1.26.3

2 files

1.26.2

2 files

1.26.1

2 files

1.25.3

2 files

1.25.2

2 files

1.25.1

2 files

1.25.0

2 files

1.24.1

2 files

1.24.0

2 files

1.23.4

2 files

1.23.3

2 files

1.23.2

2 files

1.23.1

2 files

1.23.0

2 files

1.22.0

2 files

1.21.1

2 files

1.21.0

2 files

1.20.0

2 files

1.19.1

2 files

1.19.0

2 files

1.18.0

2 files

1.17.0

2 files

1.16.0

2 files

1.15.0

2 files

1.14.2

2 files

1.14.1

2 files

1.14.0

2 files

1.13.0

2 files

1.12.0

2 files

1.11.2

2 files

1.11.1

2 files

1.11.0

2 files

1.10.0

2 files

1.9.1

2 files

1.9.0

2 files

1.8.0

2 files

1.7.2

2 files

1.7.0

2 files

1.6.0

2 files

1.5.0.post3

2 files

1.5.0

2 files

1.4.6

2 files

1.4.5

2 files

1.4.4

2 files

1.4.3

2 files

1.4.2

2 files

1.4.1

2 files

1.4.0

2 files

1.3.0

2 files

1.2.0

2 files

1.1.0

2 files

1.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page