HomeGuidesAPI ReferenceGuidesMRT APIConfiguration API
GitHubAirheads Developer Community
Guides

Profile Operations

How to use PyCentral to operate on Central library profiles

📘

Source Code

You can find the full source code and documentation for this workflow on GitHub: profile-operations

This workflow demonstrates how to use the PyCentral library to manage Central library profiles. It covers creating, reading, updating, and deleting configuration profiles through Central API handled by PyCentral. The workflow focuses on performing example operations for both individual and bulk library profiles.

Prerequisites

  • Python 3.8 or higher
  • API credentials for HPE Aruba Networking Central & GLP (JSON or YAML format)

Installation

  1. Clone the repository and navigate to this workflow folder
git clone -b "v2(pre-release)" https://github.com/aruba/central-python-workflows.git
cd central-python-workflows/profile-operations
  1. Create and activate a virtual environment, then install dependencies
  • On macOS/Linux: source venv/bin/activate
  • On Windows (PowerShell): venv\Scripts\Activate.ps1
python3 -m venv venv
source venv/bin/activate  # On Windows use: venv\Scripts\activate
pip install -r requirements.txt

This workflow is tested on the pycentral SDK (version: 2.0a7). Please check compatibility before executing on older/newer versions as there may be changes


Configuration

Credentials Configuration (central_token.json)

For API operations in new HPE Aruba Networking Central:

{
    "new_central": {
        "base_url": "",
        "client_id": "",
        "client_secret": "",
    }
}

Sample Input: See central_token.json in this repository for an example credential file.

📘

Where to find these:

Workflow Input Data

This workflow is preset with sample API data for script execution. The following instructions detail how to gather the information required to create your own configuration profiles with the PyCentral profile module.

  1. Locate the API endpoint:
    The API endpoint will be the last suffix appended to the full URL on the reference page.

    api endpoint
  2. Determine the bulk key:
    We refer to the bulk key in PyCentral as the key for the body object of the payload. Most often, the bulk key will simply be 'profile', however some APIs will use a unique identifier. In the example image for DNS we can see that the bulk key is 'profile'.

  3. Profile configurations:
    You can refer to the body object in the API reference to find valid configuration key/values to use for your own object with PyCentral. Here are some of the values for the DNS profile body object as an example.

Example profile configuration dictionary in python that we use to create a DNS library profile with PyCentral:

dns_profile = {
    "name": "example-dns",
    "description": "example-dns description",
    "resolver": [
        {"vrf": "default", "name-server": [{"ip": "8.8.8.8", "priority": 1}]}
    ],
}

👍

Pro Tip

An easy way to get example configurations for a profile you are unfamiliar with is to create the profile using the web UI in Central, and then run a GET request for the profile with PyCentral.


Execution

This workflow is executed by the profile_operations.py script and demonstrates the use
of the following PyCentral modules and Central APIs:

  1. Connecting to Central with the PyCentral base object
  2. Individual profile module operations
  3. Bulk Profile Operations

The workflow is executed by running the following command:

python profile_operations.py

Output

Output will be displayed in the terminal showing results of the profile module operations covered in the script:

Script Operations:

  • Individual Operations (DNS Profile):
    1. Create a DNS profile
    2. Read the created profile
    3. Update the profile description
    4. Delete the profile
  • Bulk Operations (VLAN Profiles):
    1. Create multiple VLAN profiles at once
    2. Read all VLAN profiles from Central library
    3. Update the description of all VLANS simultaneously
    4. Delete all profiles

If the script runs successfully, the terminal will show output similar to the following:

Troubleshooting

  • Authentication / tokens: Ensure your token file is complete and has valid credentials for Central.
  • SDK compatibility: If method calls fail unexpectedly, confirm the installed PyCentral version matches tested versions (v2.0a7) or update helpers accordingly.

Support