Some of our customers may be managing multiple instances of Central. In such a scenario, they may sometimes have to move devices between instances of Central. Its possible to do this through the the GLCP & Central User Interface and via Central APIs. When multiple devices have to be moved between accounts, this can lead to the customer have to click through multiple lot of clicks has to be done for multiple devices, this workflow could result in multiple clicks. This makes the workflow prone to accidental clicks and human error.
The script in this workflow automates the above process by using Pycentral library to do the following steps - In the current Central Account -
- Unassign Central Subscriptions from Device(s)
- Archive Device(s)
- Unarchive Device(s) After the above steps are completed in the current Central account, then in the new Central account -
- Add Device(s)
- Assign Central Subscription to Device(s)
Note - Throughout this README & the script -
- current - This refers to the Central account from which devices have to be migrated from
- new - This refers to the Central account to which devices have to be migrated into
- Device(s) in the current Central account have Central Subscriptions associated with them
- The new Central account's subscription inventory has available seats in the same Central subscription tier that the devices are subscribed to in the current Central account.
In order to run the script, please complete the steps below:
-
Clone this repository and
cd
into the workflow directory:git clone https://github.hpe.com/hpe/central-python-workflows cd central-python-workflows/device_inventory_migration/
-
Install virtual environment (refer https://docs.python.org/3/library/venv.html). Make sure python version 3 is installed in system.
python -m venv env
-
Activate the virtual environment In Mac/Linux:
source env/bin/activate
In Windows:
env/Scripts/activate.bat
-
Install the packages required for the script
python -m pip install -r requirements.txt
-
Provide the Central API Gateway Base URL & Access Token in the current_central_token.json and new_central_token.json for both the Current & New Central Account Instances.
{ "central_info": { "base_url": "<api-gateway-domain-url>", "token": { "access_token": "<api-gateway-access-token>" } }, "ssl_verify": true }
Note
-
(Optional) You can skip this step if you are migrating all devices from the current Central account to the new Central account. Update the placeholder data of device details in device_list.json. Please provide the serial numbers of the devices you would like to migrate
{ "device_list": [ "<device-serial-1>", "<device-serial-2>" ] }
-
Once central_token.json & device_list.json are updated with the relevant information, you can execute the script.
- If you would like migrate all devices in the current Central account run this command:
python device_inventory_migration.py --all_devices
- If you would like to migrate some devices from the current Central account run this command:
python device_inventory_migration.py --device_list device_list.json
Note
- This script takes the following optional parameters to overide default filenames for the script
- current_central_auth - Path of Central Token File of Current Central Account
- new_central_auth - Path of Central Token File of New Central Account
- device_list - Path of Device List File
- Get devices from device inventory
- Unassign subscription to a device
- Archive devices using Serial list
- Unarchive devices using Serial list
- Add device using Mac and Serial number
- Assign subscription to a device
This Python script was tested on Central version 2.5.7