-
Notifications
You must be signed in to change notification settings - Fork 9
Description
Hi,
I was trying out show version py file, but i see its not working as expected. seems the command is not working.
RP/0/RP0/CPU0:ar5.BLB#show ver
Thu Jan 20 05:33:00.906 UTC
Cisco IOS XR Software, Version 7.5.1
Copyright (c) 2013-2021 by Cisco Systems, Inc.
Build Information:
Built By : ingunawa
Built On : Sun Nov 28 11:12:48 PST 2021
Built Host : iox-ucs-101
Workspace : /auto/srcarchive15/prod/7.5.1/ncs5500/ws
Version : 7.5.1
Location : /opt/cisco/XR/packages/
Label : 7.5.1-Base_v1
cisco NCS-5500 () processor
System uptime is 1 week 1 day 46 minutes
RP/0/RP0/CPU0:ar5.BLB#script run test_cli_show_version.py
Thu Jan 20 05:29:17.772 UTC
Script run scheduled: test_cli_show_version.py. Request ID: 1642652384
{'status': 'error', 'output': 'Failed to get command output'}
Script test_cli_show_version.py (exec) Execution complete: (Req. ID 1642652384) : Return Value: 0 (Executed)
Code : that i am running
colt123@colt123:~/Dipankar/xr-python-scripts/exec$ cat test_cli_show_version.py
Copyright (c) 2021 by Cisco Systems, Inc.
All rights reserved.
"""
This script executes show version on the router and prints the result.
Verify:
check for syslog: 'Show version successful'
"""
import re
from iosxr.xrcli.xrcli_helper import *
from cisco.script_mgmt import xrlog
syslog = xrlog.getSysLogger('test_cli_show_version')
helper = XrcliHelper(debug = True)
def test_execute():
cmd = "show version"
result = helper.xrcli_exec(cmd)
print(result)
if result['status'] == 'success':
syslog.info('SCRIPT : Show version successful')
m = re.search(r'[^Version ]*$',result['output'])
syslog.info("Script found " + m.group(0))
else:
syslog.error('SCRIPT : Show version failed')
if name == 'main':
test_execute()