This workflow uses the PyCentral SDK to automate configuring hostname profiles of devices in Central. The workflow first checks the device serial numbers against Central to verify devices are ready to be provisioned. Then, device hostname profiles are either created or updated determined by their current hostname status. The workflow will also create a CSV output file containing the status of hostname configuration operations.
- Python 3.8 or higher
- API credentials for HPE Aruba Networking Central(YAML format)
- All target devices are ready for provisioning in Central
- 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/rename-hostnames- 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.txtThis workflow is tested on the PyCentral SDK (version: 2.0a16). Please check compatibility before executing on older/newer versions as there may be changes
For API operations in new HPE Aruba Networking Central:
new_central:
cluster_name: <cluster-name> # or base_url: <central-api-base-url>
client_id: <central-client-id>
client_secret: <central-client-secret>Sample Input: See account_credentials.yaml in this repository for an example credential file.
This workflow requires an input CSV file containing the serial number of the devices to
have their hostname changed, in addition to the new hostname. By default the workflow
will use the variables_sample.csv file if none is provided.
Update the variables_sample.csv with device serial numbers and new hostnames, or create a custom CSV with the same format to be used as an argument when executing the script.
serial,new_hostname
{device1_serial},{device1_new_hostname}
{device2_serial},{device2_new_hostname}Note
Sample Input: See variables_sample.csv in this repository for an example input file structure.
python rename_hostnames.pyWith arguments:
python rename_hostnames.py -c <credentials_file> --hostnames_csv <input_file>| Name | Type | Description | Required | Default |
|---|---|---|---|---|
| credential_file | string | Path to file with Central credentials | No | account_credentials.yaml |
| hostnames_csv | string | Path to input CSV file | No | variables_sample.csv |
If the script runs successfully, the terminal will show output similar to the following:
A CSV file with the results of the script execution will be saved as output.csv. The
results include the serial number of the devices, their new hostnames, and the outcome
of the operation.
Example output.csv file:
serial_number,new_name,status
serial1,hostname1,success
seria2,hostname2,failure- Authentication / tokens: Ensure your credentials file is complete and has valid credentials for Central.
- Ensure all target devices have been assigned a device function and are ready for provisioning
- Ensure hostnames are a valid format for the device type they are attempting to be assigned to
- SDK compatibility: If API calls fail unexpectedly, confirm the installed pycentral version matches tested versions (v2.0a16) or update helpers accordingly.
- Automation Team: [email protected]
- Workflow Issues: GitHub Issues
- PyCentral Library: PyCentral Issues
/rename-hostnames/rename-hostnames.gif)