Skip to content

test_cli_show_version.py not working on 751 release. #3

@dipankarshaw

Description

@dipankarshaw

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()

RP/0/RP0/CPU0:ar5.BLB#show script status
Thu Jan 20 05:36:33.049 UTC

Name | Type | Status | Last Action | Action Time

test_cli_show_version.py | exec | Ready | RESTORE | Thu Jan 20 05:26:59 2022

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions