Import Script

This script allows you to import a single JSON configuration file to multiple Edge ACM systems.

For more information on how to execute scripts in different environments, view the “Client Scripts” page.

Contents of Package

This scripts is composed of 2 python files:

  • ApiClient.py: ApiClient can be used to interface with the Edge Node’s API but will do nothing if run directly.

  • ImportScript.py: ImportScript must be run in the same folder with ApiClient.

The Examples folder contains example CSV and JSON exports with matching file names, as expected by the script.

Usage

This script will apply a node or app level configuration JSON to all of the devices specified in a csv file. To execute this command from the command line, navigate to its folder and use:

python ImportScript.py

Or, on a system with both Python 2 and 3 installed:

python3 ImportScript.py

When first run, the script will create every folder required. To apply the configuration, place properly formatted CSV and JSON files with matching file names (eg. example123.json, example123.csv) in the Imports folder and execute the command again. It will connect to each device in order, import the provided configuration JSON, and restart all currently running apps.

This process may take several minutes per device.

MQTT and eACM will be started at the end of the process if they weren’t previously running.

JSON Formatting

The import script expects JSON files as generated by the Export process, either of the full device (node level export) or an individual app (app level export). At this time, folder level exports and CSV exports are not recognized by the Import script.

CSV Formatting

The CSV file’s top row must include the following headers:

Site Name,Edge Device IP,reachable,eACM username,eACM password,OS username,OS password,MQTT GroupID,MQTT NodeID,Broker IP

Each column's meaning is detailed below:

Site Name

The unique name for the site, this will be assigned to the to level Node of the edge device. Each Site Name must be unique within the CSV.

Site Name

The unique name for the site, this will be assigned to the to level Node of the edge device. Each Site Name must be unique within the CSV.

Edge Device IP

The IP address or URL of the Edge device; this is the IP we will attempt to contact. By default, the IP address will be preceded with “http://” and the port used will be 8080, e.g. “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, e.g. “https://192.168.0.10:8181”. Each Edge Device IP must be unique within the CSV.

reachable

Enter the lower case letter x in this field to signify the script should attempt to connect to and configure the device. If any other value is entered, or it is left blank, this row will be skipped.

eACM username

The web interface username used to connect to the Edge Manager website and API. Default: admin

eACM password

The web interface password used to connect to the Edge Manager website and API. Default: admin

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

MQTT GroupID

The Group ID to be used by the Sparkplug B publisher. It will only be changed if the JSON is a node level export or an export of the MQTT app. Note: it will be applied to all Sparkplug B publishers.

MQTT NodeID

The Node ID to be used by the Sparkplug B publisher. It will only be changed if the JSON is a node level export or an export of the MQTT app. Note: it will be applied to all Sparkplug B publishers. Each MQTT Node ID must be unique within the CSV.

Broker IP

The IP of the broker used by the top level node. If the JSON is a node export or an MQTT app export then this will also overwrite the Host Address of broker objects.

Output

While the script is running, files will be collected from the Import folder and moved into the Process folder. After running the script, the files will be moved into one of these:

  • Complete - The script has run successfully on at least one of the devices in the CSV file. A report.txt file is also generated in this folder to detail which sites are updated, which are not, and what prevented the update.

If it took longer than the specified timeout, a site may report the apps failed to restart despite the updates being applied successfully.

  • 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.

  • Unrecognized - Files that are not CSV or JSON, as well as CSV and JSON files without matching file names, will be moved here.

Logs

This script will generate its logs in ImportScript.log. It can be checked for further details if an error appears in the Complete report.

 

For assistance, please submit a ticket via our Support Portal, email autosol.support@autosoln.com or call 281.286.6017 to speak to a support team member.