Universal vManage API
Project description
vManage-client
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file vmngclient-0.9.1.tar.gz.
File metadata
- Download URL: vmngclient-0.9.1.tar.gz
- Upload date:
- Size: 92.0 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b6e70da61b72cfa884f878444343017892bebebea69856500138e0dad40d5d9
|
|
| MD5 |
782e5db615b4ce86670f1586cea99017
|
|
| BLAKE2b-256 |
c8bf5700625ea47682a39ec9ac906acc203f09890248db54f9cddb35a695866f
|
File details
Details for the file vmngclient-0.9.1-py3-none-any.whl.
File metadata
- Download URL: vmngclient-0.9.1-py3-none-any.whl
- Upload date:
- Size: 131.8 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c2ebc7b83be14aff70196a9e7470a6e191f5e5c17875c3b60611f6841fb88c56
|
|
| MD5 |
6b9b22ac84f94871d32a5db0fd99833d
|
|
| BLAKE2b-256 |
f2a684ffba7e9fcd7ef88739451bf97ae767ba13327c079ab077271c5b65d1ac
|