This script allows you to reboot multiple remote Linux systems.
Contents of Package
This scripts is composed of 2 python files:
ApiClient.py
RebootScript.py
ApiClient can be used to interface with the Edge Node’s API but will do nothing if run directly.
RebootScript must be run in the same folder with ApiClient.
Usage
This script will reboot all listed devices if the provided credentials have sudo permission and the linux distro recognizes teh “reboot” command.
python RebootScript.py
Or, on a system with both Python 2 and 3 installed:
python3 RebootScript.py
It will connect to each device in order, issuing a reboot command. Note that this process may take several minutes per device.
As with any software based power cycling of a remote device, there is a chance physical intervention will be required to restore communications. Proceed with caution.
For further details on running scripts in different environments, see Client Scripts
CSV Formatting
The CSV file’s top row must include the following headers:
Edge Device IP,OS username,OS password
Each column's meaning is detailed below
Edge Device IP | The IP address or url the edge device; this is the IP we will attempt to contact. Unless otherwise specified, it will be assumped an IP or url is of the format, Eg “192.168.0.10” will be read as “http://192.168.0.10:8080”. If a different port is expected, or the node is configured for https, that must be included, eg “https://192.168.0.10:8181”. Each Edge Device IP must be unique within the CSV. |
OS username | The operating system username, not currently used by the script; it can be left blank. |
OS password | The operating system password, not currently used by the script; it can be left blank |
Output
Depending on the results of running the script, the files will be moved as follows. The files will end up in one of four subfolders of Imports:
Complete - The script has run succesfully on at least one of the devices in the csv. Details of the operation can be found in the log.
Error - Either the script did not recognize the formatting of the csv or one of the devices in the csv did not recognize the formatting of the json file. Check log for details.
Process - Files should only be here while the script is running; they will be collected from Import, moved to Process, then sent to Error or Complete. Any files that remain here when the program is done indicate an unexpected exception. Check log for further details and contact support if necessary.
Unrecognized - Files that are not csv or json, as well as csv and json files without matching names, will be moved here.
Logs
This script will generate its logs in RebootScript.log. It can be checked for further details if an error appears in the Complete report.