Applications
Develop Python applications
LR54 User Guide
727
<device id="00000000-00000000-0000FFFF-A83CF6A3"/>
<requests>
<device_request target_name="myTarget"
status="0">OK</device_request>
</requests>
</device>
</data_service>
</sci_request>
Example: Use digidevice.cli with digidevice.device_request
In this example, we will use the
digidevice.cli
module in conjunction with the
digidevice.device_
request
module to return information about multiple devices to Remote Manager.
1. Create a Python application, called showsystem.py, that uses the
digidevice.cli
module to
create a response containing information about device and the
device_request
module to
respond with this information to a request from Remote Manager:
from digidevice import device_request
from digidevice import cli
import time
def handler(target, request):
return cli.execute("show system verbose")
def status_cb(error_code, error_description):
if error_code != 0:
print("error handling showSystem device request: %s" % error_
description)
device_request.register("showSystem", handler, status_callback = status_
cb)
# Do not let the process finish so that it handles device requests
while True:
time.sleep(10)
2. Upload the showsystem.py application to the /etc/config/scripts directory on two or more Digi
devices. In this example, we will upload it to two devices, and use the same request in Remote
Manager to query both devices.
See
Configure scripts to run automatically
for information about uploading Python
applications to your device. You can also create the script on the device by using the
vi
command when logged in with shell access.
3. For both devices:
a. Configure the device to automatically run the showsystem.py application on reboot, and
to restart the application if it crashes. This can be done from either the WebUI or the
command line:
Web
i. Log into Digi Remote Manager, or log into the local Web UI as a user with full Admin
access rights.
Содержание TransPort LR54
Страница 1: ...LR54 User Guide Firmware version 22 8 ...
Страница 506: ...Virtual Private Networks VPN OpenVPN LR54 User Guide 506 5 Click Apply to save the configuration and apply the change ...
Страница 628: ...Services Simple Network Management Protocol SNMP LR54 User Guide 628 The SNMP page is displayed 4 Click Download ...
Страница 1050: ...Command line interface Execute a command from the web interface LR54 User Guide 1050 The Admin CLI prompt appears ...
Страница 1095: ...Command line interface Command line reference LR54 User Guide 1095 reboot Reboot the system Parameters None ...