pycentral
Aruba Central Python Package Index SDK
Aruba Central is an unified cloud-based network management and configuration platform for campus, branch, remote and data center networks. There are various needs for automation and programmability like automating repetitive tasks, configuring multiple devices, monitoring and more. This python package is to programmatically interact with Aruba Central via REST APIs.
How To Install
In order to run the workflow scripts, please complete the steps below:
-
install virtual env (refer https://docs.python.org/3/library/venv.html). Make sure python version 3 is installed in system.
$ python3 -m venv centralenv -
Activate the virtual env
$ source centralenv/bin/activate in Windows: $ centralenv/Scripts/activate.bat -
Install the pycentral package
(centralenv)$ pip3 install pycentralTo install package with extras
colorLogwhich will display log in color(centralenv)$ pip3 install pycentral[colorLog]
Now you can start making your script based on modules in pycentral or use different workflows from the subpackage workflows.
Executing Scripts
-
Gathering variables required for the package base class
ArubaCentralBase.-
base_url: Go to
Account Home -> API Gateway -> APIs. All Published APs Table will show URL under DOCUMENTATION column. Truncate this to end with '.com' E.G. 'https://apigw-prod2.central.arubanetworks.com/swagger/central/' must be truncated to 'https://apigw-prod2.central.arubanetworks.com'. -
client_id and client_secret: Obtain client_id and client_secret variables by creating an API Gateway client in Aruba Central. Refer the following documentation for more details.
At this point, create an API access token from the API Gateway WebUI as described in the above documentation or go further to collect other variables for the Python base class to create/manage access_token via OAUTH APIs.
-
customer_id: Obtain the customer_id by clicking on the figure icon on top right corner of Aruba Central WebUI.
- username and password: Aruba Central user's username and password. The access token generated by the OAUTH APIs will have the same role/privileges as the provided Aruba Central user.
-
-
Providing input variables to the Python scripts. One of the following options can be used.
-
Provide variables directly to Aruba Central Base class in dictionary format.
Access token approach:
central_info = { "base_url": "<api-gateway-domain-url>", "token": { "access_token": "<api-gateway-access-token>" } }
OAUTH APIs approach with capability to generate new access token:
central_info = { "username": "<aruba-central-account-username>", "password": "<aruba-central-account-password>", "client_id": "<api-gateway-client-id>", "client_secret": "<api-gateway-client-secret>", "customer_id": "<aruba-central-customer-id>", "base_url": "<api-gateway-domain-url>" }
Refer the sample scripts in step3 and step4 for examples.
-
OR Provide the required variables using JSON/YAML file. Refer input files sample_scripts/input_token_only.yaml and sample_scripts/input_credentials.yaml for information.
Use
pycentral.workflows_utils.get_conn_from_file()function which accepts name of the file and returns theArubaCentralBaseinstance object. Refer the sample script in step5 for example.
-
-
Making API call using pycentral base: Using the base class
ArubaCentralBase, any Aruba Central supported REST API calls can be made. Refer the following sample script sample_scripts/pycentral_base_sample.py.Obtain the HTTP Request related information from Aruba Central Swagger documentation or API references page in Aruba Developer Hub.
-
Making API call using pycentral modules: Some API endpoints supported by Aruba Central are implemented as modules in the Python package. Refer the following sample script using modules sample_scripts/pycentral_module_sample.py.
To obtain a list of implemented modules and its documentation refer the pycentral module documentation.
-
Using pycentral workflows: Workflows are used to achieve an automation use-case which generally involves multiple API calls or dealing with scale and repetitive tasks with ease. Refer the sample script using workflows sample_scripts/pycentral_workflow_sample.py.
Refer the workflows directory to know the supported workflows.
Documentation:
- Python package documentation: pycentral module documentation
- Use-Cases and Workflows: Aruba Developer Hub
Note:
The package takes one of the two approaches to gain access to Aruba Central APIs.
-
OAUTH APIs: By taking OAUTH approach to generate new access_token, the python package will cache the tokens locally for re-use. Caching tokens locally, helps preventing creation of new access_token every time the script is run. In addition, when the access_token is expired the script will attempt to use the supplied credentials and attempt to refresh the expired token.
Override the
ArubaCentralBase.storeToken()andArubaCentralBase.loadToken()function definitions to change this behavior of caching in local file(JSON) and manage tokens more securely. -
Access Token: This process is more secure. By providing only the access_token instead of credentials, the package will not cache the tokens. But loses the ability to handle expired token and to generate new access tokens.
How to contribute
Please see the accompanying CONTRIBUTIONS.md file for guidelines on how to contribute to this repository.
Troubleshooting Issues
If you encounter module import errors, make sure that the package has been installed correctly.
Additionally, please read the RELEASE-NOTES.md file for the current release information and known issues.
Metadata
Release files for opsdis-pycentral 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| opsdis-pycentral-0.0.4.tar.gz | 34.3 kB | Without provenance | Details for opsdis-pycentral-0.0.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| opsdis_pycentral-0.0.4-py3-none-any.whl | Python 3 | none | any | Details for opsdis_pycentral-0.0.4-py3-none-any.whl |
Total release size: 84.4 kB
Release files / opsdis-pycentral-0.0.4.tar.gz
| Download URL | opsdis-pycentral-0.0.4.tar.gz |
|---|---|
| Size | 34.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
88c9ed6946619e82f4476b0190f27181d389ed3b01b82e5090279887d5536a5a
|
|
BLAKE2b-256 checksum How to use checksums |
ef09afa188088fe4257acbc64ff92fec3ccc7830caacb9fa75dda3295ce74c83
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.8.13
|
Release files / opsdis_pycentral-0.0.4-py3-none-any.whl
| Download URL | opsdis_pycentral-0.0.4-py3-none-any.whl |
|---|---|
| Size | 50.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
76e8c62b315add0ddd38cc872697f9bfdbd459b06129de50c65fb22ca3ef8f1b
|
|
BLAKE2b-256 checksum How to use checksums |
8feff2ea6bfa3fcc25e16fed9bae129deaea4379a748675db28066076f7d4eb2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.8.13
|
Security for opsdis-pycentral 0.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.