12: Scripts
EMG™ Edge Management Gateway User Guide
274
Python Custom Script - EMG CLI Session
An example of a Python Custom Script that uses the Pexpect module to interact with the CLI
session and the device ports to detect the prompt on any devices connected to the EMG, and set
the device port name to be the same as the device prompt:
#! python
# Script to detect the prompt on a device connected to an EMG device
port,
# and set the device port name to the prompt. Punctuation characters are
# removed and the device port number is appended to the name. Prompts
ending
# in '>' are detected. For example, for a Cisco device attached to device
# port 3 and displays this prompt:
# engcisco_cat3560>
# the name for device port 3 will be set to "engcisco_cat3560-3"
import pexpect
import datetime
import time
import sys
import re
now = datetime.datetime.now()
print("Detecting devices on EMG at ", end="")
print(now.strftime("%Y-%m-%d %H:%M"))
# start the CLI session to get number of device ports
p=pexpect.spawn('clisession -U sysadmin')
emgPrompt = ""
numPorts = 0
loggedIn = False
while not loggedIn:
i = p.expect([pexpect.TIMEOUT, pexpect.EOF,
'Model Number: SLC80(\d*)\r\n', 'Model Number:
SLB882\r\n',
'(\[.*>)'], timeout=10)
if i == 0: # Timeout
print("Timeout waiting to login.")
p.terminate(True)
sys.exit(1)
elif i == 1: # EOF
print("Session unexpectedly terminated.")
p.terminate(True)
sys.exit(1)
elif i == 2: # SLC8000 model number
model = p.match.group(1)
numPorts = int(model)
elif i == 3: # SLB882 model number
numPorts = 8
elif i == 4: # prompt
Содержание EMG 7500
Страница 1: ...Part Number PMD 00008 Revision C April 2020 EMG Edge Management Gateway User Guide EMG 8500 EMG 7500 ...
Страница 82: ...7 Networking EMG Edge Management Gateway User Guide 82 Figure 7 2 Network Network Settings 2 of 2 ...
Страница 100: ...7 Networking EMG Edge Management Gateway User Guide 100 Figure 7 5 Network Wireless Settings ...
Страница 353: ...15 Maintenance EMG Edge Management Gateway User Guide 353 Figure 15 12 About EMG ...
Страница 474: ...EMG Edge Management Gateway User Guide 474 Figure E 3 EU Declaration of Conformity ...
Страница 475: ...EMG Edge Management Gateway User Guide 475 Figure E 4 EU Declaration of Conformity continued ...