Device Inventory to Excel
Workflow tutorial for exporting Central device inventory details to Excel
This guide presupposes general knowledge of how to use HPE Aruba Networking's Central APIs, and how to execute workflow scripts. Please see here for detailed information on installing pycentral and getting setup to execute workflow scripts.
Inventory to excel workflows are used to create excel files populated with device details from devices currently in inventory.
Workflow Overview
-
This workflow should be used to collect all device details from devices in an account's inventory and export this data to an excel workbook.
-
Device details included are: Part Number, Customer ID, Customer Name, Device Type, IMEI, Mac Address, Model, Serial, Services, Subscription Key, and Tier type.
-
Device types received from inventory can be filtered using the sku_type CLI argument described in section 2 of executing the workflow.
-
Additional CLI options are available including: config file path, Excel filename, limit, offset, and CSV output.
Currently the workflow only supports filtering by one SKU type per execution.
Setup
For step-by-step installation guide please navigate to the Github and follow the readme.
-
Clone this repository and
cd
into the workflow directory:git clone https://github.hpe.com/hpe/central-python-workflows.git cd central-python-workflows/inventory_to_excel
-
A config file containing credential information for your Central account is required to run this workflow. This guide will help setup configuration files for Central authorization. One common method is to use a token only approach for your credential file which can be found here. The config filename should be passed as a CLI argument during execution.
The Central authorization filename is set as a CLI argument to the workflow as shown below:
--central_auth <"filepath">
-
Install the requirements.
Installation Best Practices
Setting up a virtual environment can be a great way to compartmentalize installations and keep your work isolated form the rest of your working configurations. This guide is a helpful resource for setting up workflow execution in a virtual environment with python!
Executing The Workflow
-
The workflow can be ran as is with a config file named central_token.yaml in the working directory.
$ python inventory_excel_workflow.py
This will create a new .xlsx document named inventory.xlsx in the working directory.
The .xlsx file will contain the details for all devices in inventory as documented in the API. -
Providing input variables to the workflow is optional. One or multiple of the following options can be used through CLI arguments.
-
Flags
Output format:
By default the workflow outputs an excel file in the .xlsx filetype. Output format can be changed optionally with the -c flag to output as .csv instead. If the -c flag is set the workflow will output the new file as a .csv.$ python inventory_excel_workflow.py -c
-
Provide variables to script upon execution
central_auth:
Sets the file path to central credential file.$ python inventory_excel_workflow.py --central_auth <path/to/file>
filename:
Sets the name of the output file.$ python inventory_excel_workflow.py --filename <filename>
sku_type parameters:
Sets the specific device type to pull device details for. Only one option at a time is currently supported.
Valid inputs: all, iap, switch, controller, gateway, **vgw, cap, boc, all_ap, all_controller, others.$ python inventory_excel_workflow.py --sku_type <sku>
limit and offset parameters:
Sets pagination for API calls. Should be used together.$ python inventory_excel_workflow.py --limit <int> --offset <int>
-
Limit and Offset parameters should be used with caution as mistakes can lead to pulling incorrect data. These parameters are generally only used if you need a specific subset of device data
Documentation
You can find the complete script & installation instructions for this workflow here.
Please check out other Central workflows utilizing PyCentral in central-python-workflows GitHub repository.
- Python package documentation: pycentral module documentation
- Use-Cases and Workflows: HPE Aruba Networking Developer Hub
- API Reference: New Device Inventory
Troubleshooting Issues
If you encounter module import errors, make sure that the package has been installed correctly.
Known Bugs
- sku_type 'vgw' currently does not work. It should exit with a bad request error and a response code of 500.
Updated 5 months ago