Hi there, I'm having problems with the genie parser library in robot framework. I'm basically copying the approach from the example in https://pubhub.devnetcloud.com/media/genie-docs/docs/userguide/robot/index.html
If I try this .robot file to parse the output of show version, store it in a variable, then query it with dq:
*** Settings ***
Library unicon.robot.UniconRobot
Library ats.robot.pyATSRobot
Library genie.libs.robot.GenieRobot
*** Variables ***
${testbed} testbed.yaml
*** Test Cases ***
Connect
use genie testbed "${testbed}"
connect to devices "leaf1"
parser show version
${output}= parse "show version" on device "leaf1"
Verify version
dq query data=${output} filters=contains('9.3(8)').get_values('system_version') on device "leaf1"
Disconnect from device
disconnect from device "leaf1"
The parser passes, but the verify fails because the variable is not found:
------------------------------------------------------------------------------
parser show version | PASS |
------------------------------------------------------------------------------
Verify version | FAIL |
Variable '${version}' not found.
------------------------------------------------------------------------------If I do the same thing directly in python it does what I expect, e.g:
from pyats.async_ import pcall
from genie.testbed import load
from genie.utils import Dq
from rich import print as rprint
def get_version(hostname, dev):
parsed = dev.parse("show version")
get_version = (Dq(parsed).contains('9.3(8)').get_values('system_version'))
rprint(get_version)
testbed = load("leaf1.yaml")
testbed.connect(log_stdout=False)
results = pcall(get_version, hostname=testbed.devices.keys(), dev=testbed.devices.values())Results in:
gdaly@pop-os:~/PycharmProjects/evpn/tests$ python3 verify_version.py
['9.3(8)']
Can anyone see where I'm going wrong here?