Skip to main content

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:

  1. 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
    
  2. Activate the virtual env

    $ source centralenv/bin/activate
    in Windows:
    $ centralenv/Scripts/activate.bat
    
  3. Install the pycentral package

    (centralenv)$ pip3 install pycentral
    

    To install package with extras colorLog which 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

  1. Gathering variables required for the package base class ArubaCentralBase.

    • base_url OR cluster_name: You can find the base URL or cluster name of the Central account's API Gateway from the table here. The base URL or cluster name is based on the geographical Central cluster in which the account is registered.

    • access_token: You can create an API access token for Aruba Central from -

    • Optional variables - You need to provide the below variables if you want to use PyCentral's ability to generate access tokens from Aruba Central with the help of OAuth APIs.

      • 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.

      • 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.

      • customer_id: Obtain the customer_id by clicking on the figure icon on top right corner of Aruba Central WebUI.

    Customer ID

  2. 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>"
          }
      

      Alternatively, you can use cluster_name instead of base_url in the above mentioned dictionaries. You can find the list of clusters that are supported in the constants.py file. If you would like to add support for other Central clusters, you can do so by adding it in the constants.py. Refer the sample scripts in step3 and step4 for examples.

    • OR Provide the required variables using JSON/YAML file. Refer to the sample input files to understand how the files have to be structured -

  3. 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.

  4. 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

  5. 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. Check out the central-python-workflows repository to check out workflows that utilize the Pycentral library.

Documentation:

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() and ArubaCentralBase.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.

Release files for pycentral 1.4.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pycentral 1.4.3
File Size Uploaded
pycentral-1.4.3.tar.gz 46.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pycentral 1.4.3
File Interpreter ABI Platform
pycentral-1.4.3-py3-none-any.whl Python 3 none any Details

Total release size: 107.3 kB

Release files / pycentral-1.4.3.tar.gz

Download URL pycentral-1.4.3.tar.gz
Size 46.7 kB
Tags Source
SHA-256 checksum
How to use checksums
299004f6af79a12714b5a7b572803b945a7b96596d0b384bd74c2518251a91b6
BLAKE2b-256 checksum
How to use checksums
81b3fe423a3d207f153015a6d7842819b59a619f9245e15546fb8e5ff3c48fb8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release files / pycentral-1.4.3-py3-none-any.whl

Download URL pycentral-1.4.3-py3-none-any.whl
Size 60.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c159fd13b408e494e69cc38cc0f6380f6fca514c5f31590382f1eb010085753d
BLAKE2b-256 checksum
How to use checksums
0c21859f5d7f7d9b6281b0460b396c7bcc5321a7571de2eefada8816a75c5825
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release history Release notifications | RSS feed

This release

1.4.3 This release

2 release files

1.4.1

2 release files

1.4

2 release files

1.3

2 release files

1.2.1

2 release files

1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

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