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(software_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)
alarms = session.api.alarms.get()
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.2.tar.gz (92.1 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.2-py3-none-any.whl (131.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: vmngclient-0.9.2.tar.gz
  • Upload date:
  • Size: 92.1 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.2.tar.gz
Algorithm Hash digest
SHA256 d54a4182919309df40d29ac2368989be6f60a802c0d685daab831d5dd49761f4
MD5 baf29ae580b28e5c38cb297323efa59c
BLAKE2b-256 82ef5c3d6b78876a39da6ac2f0bf0d04dbfbb383aa46f0c8257a2198aef15906

See more details on using hashes here.

File details

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

File metadata

  • Download URL: vmngclient-0.9.2-py3-none-any.whl
  • Upload date:
  • Size: 131.9 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d97c04c5b2f6c49849550cdaaf5461a975020e0eba8a84d3cdc772999975481e
MD5 07af23c586d2db82ab787aeaf82062c0
BLAKE2b-256 80f0e2e6ddef410089c2c07987159712499200bf0f08e5b73fd5a956cf72a0a5

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