<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Robot genie variable handling in Controllers</title>
    <link>https://community.cisco.com/t5/controllers/robot-genie-variable-handling/m-p/4527990#M2379</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.cisco.com/t5/user/viewprofilepage/user-id/257677"&gt;@george_daly&lt;/a&gt;,&lt;BR /&gt;&lt;BR /&gt;I'm not a Robot Genie expert but I found this:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"Variables can also be given from the command line which is useful if the tests need to be executed in different environments. For example this demo can be executed like:&lt;/P&gt;
&lt;PRE&gt;robot --variable USERNAME:johndoe --variable PASSWORD:J0hnD0e QuickStart.rst&lt;/PRE&gt;
&lt;P&gt;"&lt;/P&gt;
&lt;P&gt;This could be useful in debugging, i.e. see if it passes with variable given through CLI.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another thought, could you rename the 'data' variable as 'version'? Maybe that's what it's looking for.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps!&lt;/P&gt;</description>
    <pubDate>Fri, 07 Jan 2022 15:44:25 GMT</pubDate>
    <dc:creator>Alexander Stevenson</dc:creator>
    <dc:date>2022-01-07T15:44:25Z</dc:date>
    <item>
      <title>Robot genie variable handling</title>
      <link>https://community.cisco.com/t5/controllers/robot-genie-variable-handling/m-p/4521558#M2378</link>
      <description>&lt;P&gt;Hi there, I'm having problems with the genie parser library in robot framework.&amp;nbsp; I'm basically copying the approach from the example in&amp;nbsp;&lt;A href="https://pubhub.devnetcloud.com/media/genie-docs/docs/userguide/robot/index.html" target="_blank" rel="noopener"&gt;https://pubhub.devnetcloud.com/media/genie-docs/docs/userguide/robot/index.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I try this .robot file to parse the output of show version, store it in a variable, then query it with dq:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;*** 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"&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The parser passes, but the verify fails because the variable is not found:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;------------------------------------------------------------------------------
parser show version                                                   | PASS |
------------------------------------------------------------------------------
Verify version                                                        | FAIL |
Variable '${version}' not found.
------------------------------------------------------------------------------&lt;/PRE&gt;&lt;P&gt;If I do the same thing directly in python it does what I expect, e.g:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;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())&lt;/PRE&gt;&lt;P&gt;Results in:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;gdaly@pop-os:~/PycharmProjects/evpn/tests$ python3 verify_version.py 
['9.3(8)']&lt;/PRE&gt;&lt;P&gt;Can anyone see where I'm going wrong here?&lt;/P&gt;</description>
      <pubDate>Mon, 20 Dec 2021 12:14:14 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/robot-genie-variable-handling/m-p/4521558#M2378</guid>
      <dc:creator>george_daly</dc:creator>
      <dc:date>2021-12-20T12:14:14Z</dc:date>
    </item>
    <item>
      <title>Re: Robot genie variable handling</title>
      <link>https://community.cisco.com/t5/controllers/robot-genie-variable-handling/m-p/4527990#M2379</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.cisco.com/t5/user/viewprofilepage/user-id/257677"&gt;@george_daly&lt;/a&gt;,&lt;BR /&gt;&lt;BR /&gt;I'm not a Robot Genie expert but I found this:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"Variables can also be given from the command line which is useful if the tests need to be executed in different environments. For example this demo can be executed like:&lt;/P&gt;
&lt;PRE&gt;robot --variable USERNAME:johndoe --variable PASSWORD:J0hnD0e QuickStart.rst&lt;/PRE&gt;
&lt;P&gt;"&lt;/P&gt;
&lt;P&gt;This could be useful in debugging, i.e. see if it passes with variable given through CLI.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another thought, could you rename the 'data' variable as 'version'? Maybe that's what it's looking for.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps!&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jan 2022 15:44:25 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/robot-genie-variable-handling/m-p/4527990#M2379</guid>
      <dc:creator>Alexander Stevenson</dc:creator>
      <dc:date>2022-01-07T15:44:25Z</dc:date>
    </item>
  </channel>
</rss>

