robot framework and PyEz

625 views
Skip to first unread message

Pablo Sagrera Garcia

unread,
Jul 31, 2015, 4:44:28 AM7/31/15
to robotframework-users
Hi Experts,

I'm trying to get PyEz library (Python library to remotely manage/automate Junos devices) working in robotframework

Here's my test.robot 

*** Settings ***

Documentation     PyEz test

Library jnpr.junos.Device host=10.0.0.1 user=xxxxx password=xxxx WITH NAME router

TEST Testing Basic Connectivity
[Documentation] Check if pyez is working
[Tags] pyez
router.Open <-----works fine 
router.Close <-----works fine

TEST Testing RPC
[Documentation] Check if pyez is working
[Tags] pyez
router.Open
router.Rpc.Cli show route summary <----It's not working
router.Close

The error I'm getting is : 

No keyword with name 'router.Rpc.Cli' found.



Entering in python console I do the following :



>>> from jnpr.junos import Device

>>> jdev=Device(host='10.0.0.1',user='xxxx',password='xxxxx')

>>> jdev.open()

Device(10.0.0.1)

>>> dir(jdev)

['ON_JUNOS', 'Template', '__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_auth_password', '_auth_user', '_auto_probe', '_conf_auth_user', '_conn', '_facts', '_gather_facts', '_hostname', '_j2ldr', '_manages', '_nc_transform', '_norm_transform', '_normalize', '_port', '_ssh_config', '_ssh_private_key_file', '_sshconf_lkup', '_sshconf_path', 'auto_probe', 'bind', 'cli', 'close', 'connected', 'display_xml_rpc', 'execute', 'facts', 'facts_refresh', 'hostname', 'logfile', 'manages', 'open', 'password', 'probe', 'rpc', 'timeout', 'transform', 'user']



>>> jdev.rpc.cli

<bound method _RpcMetaExec.cli of <jnpr.junos.rpcmeta._RpcMetaExec object at 0x24708d0>>

>>> jdev.rpc.cli('show route summary')

<Element output at 0x7fca7c009a00>


Are bound methods supported in RF ? If so, What am I doing wrong ? 


PD: Creating a custom Library that contains PyEz Library is working :)


Regards


Pablo






Pekka Klärck

unread,
Jul 31, 2015, 5:59:31 PM7/31/15
to psag...@gmail.com, robotframework-users
2015-07-31 11:39 GMT+03:00 Pablo Sagrera Garcia <psag...@gmail.com>:
>
> I'm trying to get PyEz library (Python library to remotely manage/automate
> Junos devices) working in robotframework
>
> Here's my test.robot
>
> *** Settings ***
>
> Documentation PyEz test
>
> Library jnpr.junos.Device host=10.0.0.1 user=xxxxx password=xxxx WITH NAME
> router
>
> TEST Testing Basic Connectivity
> [Documentation] Check if pyez is working
> [Tags] pyez
> router.Open <-----works fine
> router.Close <-----works fine
>
> TEST Testing RPC
> [Documentation] Check if pyez is working
> [Tags] pyez
> router.Open
> router.Rpc.Cli show route summary <----It's not working
> router.Close
>
> The error I'm getting is :
>
> No keyword with name 'router.Rpc.Cli' found.

That jnpr.junos.Device is just a normal Python class, not a class
designed to be a Robot library, right? It's way cool that it works
this well! The reason `Rpc.Cli` doesn't work is that Robot's library
API expects keywords to be implemented as methods directly in the
library class. In this case the method is apparently in an object that
is an attribute of the class. I think calling the method like this
would work (but I don't really recommend it):

$[router} = Get Library Instance router
Call Method ${router.rpc} cli show route summary

> PD: Creating a custom Library that contains PyEz Library is working :)

Yeah, it's easy to create a custom library that has all methods in the
class directly. I would assume that's the best approach here too. It
would make usage much more convenient compared to the Call Method hack
above.

Cheers,
.peke
--
Agile Tester/Developer/Consultant :: http://eliga.fi
Lead Developer of Robot Framework :: http://robotframework.org

Pablo Sagrera Garcia

unread,
Aug 3, 2015, 5:55:56 AM8/3/15
to robotframework-users, psag...@gmail.com, pe...@iki.fi
Thanks a lot Peke,

As you said, The Call method hack works fine ! but the approach of using custom library suits much better here

Regards 

Pablo

Pekka Klärck

unread,
Aug 3, 2015, 6:24:31 PM8/3/15
to psag...@gmail.com, robotframework-users
2015-08-03 12:55 GMT+03:00 Pablo Sagrera Garcia <psag...@gmail.com>:
> Thanks a lot Peke,
>
> As you said, The Call method hack works fine ! but the approach of using
> custom library suits much better here

Have you considered creating a generic library wrapping PyEz and
releasing as open source yourself?

Billy B

unread,
Feb 23, 2017, 1:52:32 PM2/23/17
to robotframework-users
Hi,

I don't suppose you could send me you finished file of this example test, as I want to build a robert framework to test show alarms on juniper devices, also I want to create a basic one to just ping interfaces.

Thank's

Billy 

Jeff Silverman

unread,
Feb 24, 2017, 6:44:13 PM2/24/17
to robotframework-users
Me too!

Shall we collaborate?


Jeff Silverman
Reply all
Reply to author
Forward
0 new messages