Skip to main content

Universal vManage API

Project description

vManage-client

Python3.8

vManage client is a package for creating simple and parallel automatic requests via official vManageAPI. It is intended to serve as a multiple session handler (provider, provider as a tenant, tenant). The library is not dependent on environment which is being run in, you just need a connection to any vManage.

Installation

pip install vmngclient

Session usage example

Our session is an extension to requests.Session designed to make it easier to communicate via API calls with vManage. We provide ready to use authenticetion, you have to simply provide the vmanage url, username and password as as if you were doing it through a GUI.

from vmngclient.session import create_vManageSession

url = "example.com"
username = "admin"
password = "password123"
session = create_vManageSession(url=url, username=username, password=password)

session.get("/dataservice/device")

API usage examples

Get devices (click to expand)
devices = session.api.devices.get()
Admin Tech (click to expand)
admin_tech_file = session.api.admin_tech.generate("172.16.255.11")
session.api.admin_tech.download(admin_tech_file)
session.api.admin_tech.delete(admin_tech_file)
Speed test (click to expand)
devices = session.api.devices.get()
speedtest = session.api.speedtest.speedtest(devices[0], devices[1])
Upgrade device (click to expand)
# Prepare devices list
vsmarts = session.api.devices.get().filter(personality=Personality.VSMART)
image = "viptela-20.7.2-x86_64.tar.gz"

# Upload image
session.api.repository.upload_image(image)

# Install software

install_task = session.api.software.install(devices=vsmarts, image=image)

# Check action status
install_task.wait_for_completed()
Get alarms (click to expand) To get all alarms:
alarms = session.api.alarms.get()

To get all not viewed alarms:

not_viewed_alarms = session.api.alarms.get().filter(viewed=False)

To get all alarms from past n hours:

n = 24
alarms_from_n_hours = session.api.alarms.get(from_time=n)

To get all critical alarms from past n hours:

n = 48
critical_alarms = session.api.alarms.get(from_time=n).filter(severity=Severity.CRITICAL)
User operations (click to expand)
from vmngclient.api.administration import User, UsersAPI

# Get all users
all_users = UsersAPI(session).get_all_users()

# Create a user
new_user = User(username="new_user", password="new_user", group=["netadmin"], description="new user")
status = UsersAPI(session).create_user(new_user)

# Delete a user
status = UsersAPI(session).delete_user(username="new_user")

Note:

To remove InsecureRequestWarning, you can include in your scripts (warning is suppressed when VMNGCLIENT_DEVEL environment variable is set):

import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

Catching Exceptions

try:
	session.api.users.delete_user("XYZ")
except vManageBadRequestError as error:
	# Process an error.
	logger.error(error.info.details)

# message = 'Delete users request failed' 
# details = 'No user with name XYZ was found' 
# code = 'USER0006'

Contributing, bug reporting and feature requests

Seeking support

You can contact us by submitting issues, or directly via mail on vmngclient@cisco.com.

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

vmngclient-0.9.4.tar.gz (98.8 kB view details)

Uploaded Source

Built Distribution

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

vmngclient-0.9.4-py3-none-any.whl (139.2 kB view details)

Uploaded Python 3

File details

Details for the file vmngclient-0.9.4.tar.gz.

File metadata

  • Download URL: vmngclient-0.9.4.tar.gz
  • Upload date:
  • Size: 98.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.1 CPython/3.8.16 Linux/5.15.0-1037-azure

File hashes

Hashes for vmngclient-0.9.4.tar.gz
Algorithm Hash digest
SHA256 20ea0df826cb33c31a366ddcf1aa94a9c02ea78b698246cb333668492d4d7eab
MD5 a4c750614a4bccae975f324420663e23
BLAKE2b-256 601e8fa022286e95c6d7b916fc4fa00fcef64cbcdf053911a9e7189fff6403b8

See more details on using hashes here.

File details

Details for the file vmngclient-0.9.4-py3-none-any.whl.

File metadata

  • Download URL: vmngclient-0.9.4-py3-none-any.whl
  • Upload date:
  • Size: 139.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.1 CPython/3.8.16 Linux/5.15.0-1037-azure

File hashes

Hashes for vmngclient-0.9.4-py3-none-any.whl
Algorithm Hash digest
SHA256 3467a9d92ebe1e35c9ef3f97acfbc449a2fe48bf9f16296cd11ad4589f9445ce
MD5 b2f388f1ce6b94fe6bbff484e67ae964
BLAKE2b-256 f5632afad3e6d9d6539086d78a2598688a284ac08b72ccaa449195b2f1336c39

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page