
8: Device Ports
SLB™ Branch Office Manager User Guide
158
Python Custom Script - SLB CLI Session
An example of a Python Custom Script that interacts with a CLI session:
#! python
# Script to set the RADIUS authentication settings of the SLB
# Sets the first RADIUS server and secret, and enables RADIUS
# Note: passing secret as a command line parameter is a security
vulnerability
# Usage:
# script_cli_radius.py <RADIUS server> <RADIUS secret>
#
import subprocess
import datetime
import sys
num_args = len(sys.argv) - 1
if num_args < 2:
print("Usage: script_cli_radius.py <RADIUS server> <RADIUS secret>")
sys.exit(1)
print("Settings RADIUS server on SLC at ", end="")
now = datetime.datetime.now()
print(now.strftime("%Y-%m-%d %H:%M"))
server = sys.argv[1]
secret = sys.argv[2]
proc = subprocess.Popen(['clisession', '-U', 'sysadmin'],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
# wait for prompt
while True:
output_str = proc.stdout.readline()
if b'list of commands' in output_str:
proc.stdin.write(b'\n')
proc.stdin.flush()
if b']> ' in output_str:
break
if b'Invalid local user' in output_str:
print("Invalid local user passed to clisession.")
proc.stdin.close()
proc.terminate()
proc.wait()
sys.exit(1)
# Run the RADIUS command
s = "set radius server 1 host " + " secret " + "\n"
b = bytearray(s.encode())
proc.stdin.write(b)
proc.stdin.flush()
Содержание 100-120 VAC SLB
Страница 114: ...8 Device Ports SLB Branch Office Manager User Guide 114 Figure 8 4 Device Ports Settings ...
Страница 131: ...8 Device Ports SLB Branch Office Manager User Guide 131 Figure 8 10 Devices Power Outlets ...
Страница 174: ...9 USB Port SLB Branch Office Manager User Guide 174 Figure 9 3 Devices USB Modem ...
Страница 227: ...12 Maintenance SLB Branch Office Manager User Guide 227 Figure 12 1 Maintenance Firmware Configurations ...