Upgrade to 1.5.2, tooling for VPN API requests
This commit is contained in:
@@ -1,48 +1,48 @@
|
||||
import pandas as pd
|
||||
import subprocess
|
||||
import argparse
|
||||
import sys
|
||||
import json
|
||||
|
||||
# This Python script will create an IoT Edge device according to the provided parameters
|
||||
# It will create the device with the name DIGIT-*serial number* (using --serial *serial number*)
|
||||
# The user need to precise the number of the gateway on the site (using --number *number*)
|
||||
# The user need to precise which IoT Hub is used (using --env *PROD or DEV*)
|
||||
# The user need provide the site name, which will be added as a tag (using --site *site name*)
|
||||
# The user need to precise which configuration of the modules should be used, according to the running firmware on the device (using --version *version number*)
|
||||
# Example:
|
||||
# python create_moxa.py --serial TBBHB1044382 --number 5 --env PROD --site DANISH --version 1.5_patch
|
||||
# will create the IoT Edge device using the serial number provided (TBBHB1044382)
|
||||
# on the PROD IoT Hub
|
||||
# tag the device with number = 5
|
||||
# tag the device with site = DANISH
|
||||
# configure the modules for the device with the corresponding version found in moxa_ac_template_1.5_patch.json
|
||||
|
||||
def generate_commands(serial, number, env, site, version):
|
||||
|
||||
device_id = f"DIGIT-{serial}"
|
||||
tags = f'{{"deviceId":"{device_id}","site":"{site}","number":"{number}"}}'
|
||||
content = f"moxa_ac_template_{version}.json"
|
||||
create_device_command = f"az iot hub device-identity create --device-id {device_id} --hub-name IotHub-CUBE-{env} --edge-enabled"
|
||||
twin_update_command = f"az iot hub device-twin update --device-id {device_id} --hub-name IotHub-CUBE-{env} --set tags='{tags}'"
|
||||
set_modules_command = f"az iot edge set-modules --device-id {device_id} --hub-name IotHub-CUBE-{env} --content {content}"
|
||||
subprocess.run(create_device_command, shell=True)
|
||||
subprocess.run(twin_update_command, shell=True)
|
||||
subprocess.run(set_modules_command, shell=True)
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Parse command line arguments
|
||||
parser = argparse.ArgumentParser(description='Create devices list')
|
||||
parser.add_argument('--serial', required=True, help='Serial number of the gateway')
|
||||
parser.add_argument('--number', required=True, help='Gateway on-site number')
|
||||
parser.add_argument('--env', required=True, help='Environment (PROD or DEV)')
|
||||
parser.add_argument('--site', required=True, help='Site name')
|
||||
parser.add_argument('--version', required=True, help='Version number')
|
||||
args = parser.parse_args()
|
||||
|
||||
if len(sys.argv) == 1:
|
||||
parser.print_help()
|
||||
sys.exit(1)
|
||||
|
||||
# Generate commands
|
||||
generate_commands(args.serial, args.number, args.env, args.site, args.version)
|
||||
import pandas as pd
|
||||
import subprocess
|
||||
import argparse
|
||||
import sys
|
||||
import json
|
||||
|
||||
# This Python script will create an IoT Edge device according to the provided parameters
|
||||
# It will create the device with the name DIGIT-*serial number* (using --serial *serial number*)
|
||||
# The user need to precise the number of the gateway on the site (using --number *number*)
|
||||
# The user need to precise which IoT Hub is used (using --env *PROD or DEV*)
|
||||
# The user need provide the site name, which will be added as a tag (using --site *site name*)
|
||||
# The user need to precise which configuration of the modules should be used, according to the running firmware on the device (using --version *version number*)
|
||||
# Example:
|
||||
# python create_moxa.py --serial TBBHB1044382 --number 5 --env PROD --site DANISH --version 1.5_patch
|
||||
# will create the IoT Edge device using the serial number provided (TBBHB1044382)
|
||||
# on the PROD IoT Hub
|
||||
# tag the device with number = 5
|
||||
# tag the device with site = DANISH
|
||||
# configure the modules for the device with the corresponding version found in moxa_ac_template_1.5_patch.json
|
||||
|
||||
def generate_commands(serial, number, env, site, version):
|
||||
|
||||
device_id = f"DIGIT-{serial}"
|
||||
tags = f'{{"deviceId":"{device_id}","site":"{site}","number":"{number}"}}'
|
||||
content = f"moxa_ac_template_{version}.json"
|
||||
create_device_command = f"az iot hub device-identity create --device-id {device_id} --hub-name IotHub-CUBE-{env} --edge-enabled"
|
||||
twin_update_command = f"az iot hub device-twin update --device-id {device_id} --hub-name IotHub-CUBE-{env} --set tags='{tags}'"
|
||||
set_modules_command = f"az iot edge set-modules --device-id {device_id} --hub-name IotHub-CUBE-{env} --content {content}"
|
||||
subprocess.run(create_device_command, shell=True)
|
||||
subprocess.run(twin_update_command, shell=True)
|
||||
subprocess.run(set_modules_command, shell=True)
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Parse command line arguments
|
||||
parser = argparse.ArgumentParser(description='Create devices list')
|
||||
parser.add_argument('--serial', required=True, help='Serial number of the gateway')
|
||||
parser.add_argument('--number', required=True, help='Gateway on-site number')
|
||||
parser.add_argument('--env', required=True, help='Environment (PROD or DEV)')
|
||||
parser.add_argument('--site', required=True, help='Site name')
|
||||
parser.add_argument('--version', required=True, help='Version number')
|
||||
args = parser.parse_args()
|
||||
|
||||
if len(sys.argv) == 1:
|
||||
parser.print_help()
|
||||
sys.exit(1)
|
||||
|
||||
# Generate commands
|
||||
generate_commands(args.serial, args.number, args.env, args.site, args.version)
|
||||
|
||||
Reference in New Issue
Block a user