Closed kevinyohe closed 3 years ago
I asked the pyats support at cisco, they think the testbed object wasnt being populated by the virl libaries.
I found a round about way to do this If i instantiate a CLPyats manually, then sync_testbed it'll allow me to run a command but not directly on the node model
Hey, @kevinyohe . Sorry that this took so long to respond... here's how it should work... I think we should auto-sync the testbed if it hasn't been synced when running a pyats_command()
. Same goes for the username and password which should be re-used from the CL initialization... However, for that to work we'd need to store the credentials -- which might be or might not be a good idea...
Until then, the below works for me:
from virl2_client import ClientLibrary
cl = ClientLibrary("https://1.2.3.4", "admin", "password", ssl_verify=False)
lab = cl.join_existing_lab("d2ebca")
node=lab.get_node_by_id("n2")
lab.pyats.sync_testbed("admin", "password")
node.run_pyats_command("show ver")
note that the test username/password must be the one that you use for the client library itself and it's the one that is used to log into the UI or the SSH terminal server.
Another thing that is important to realize is the fact that the actual / configured node name of the device must match the node name that is in the testbed. That's a requirement from pyATS, not CML/VIRL.
I'm closing this -- if this persists or if you have further questions then feel free to open a new issue.
Hello, I am trying to run a command 'Show run' on a node, here's the sample code. Code is very basic using the virl2_client module: client = ClientLibary(server, username, password, ssl_verify=False) client.wait_for_lld_connected() lab = client.create_lab(‘testlab’) r1 = lab.create_node(‘r1’, ‘iosv’, 50, 100) r1.config = ‘hostname testing’ lab.start() lab.wait_until_lab_converged() cmd = r1.run_pyats_command(‘show run’)
then I get an AttributeError: ‘NoneType’ object has no attribute ‘devices’ on the cmd line above