cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
963
Views
10
Helpful
2
Replies

device connect in python

robert.lee2
Level 1
Level 1

Tried several variation to perform the equivalent of cli command - "devices device xxxx connect" -

 

root.devices.device[dev].connect.request()

root.devices.device[dev].connect()

 

and then check the 'result' attribute of object returned.  However, I keep getting a timeout when doing this in python (even though the cli command to the same device returns true).

 

<ERR> 8-Nov-2020::21:15:23.622 nsov5-dev-01 ncs[197669]: devel-c service_pre_modification(create) error {external_timeout, ""} for callpoint.........

 

PS - I know that I should not be doing any external task in a service create (premod or otherwise), but am now curious to know why this is not working.

2 Replies 2

hniska
Cisco Employee
Cisco Employee

Works for me

 

10:24 $ ncs_pycli
Your maagic object 'root -> (root)' is now prepared... go have some fun!
trans.compare() to see your current transaction
trans.apply() to commit
trans.revert() to revert changes
Maapi object can be found at m
You can restart the transaction and create a fresh root object by invoking new_trans:


In [1]: new_trans
new transaction created

In [27]: output = root.devices.device['CE0'].connect()

In [28]: output.info
Out[28]: '(admin) Connected to CE0 - 127.0.0.1:10022'

In [29]: output.result
Out[29]: True

Thanks - Yes there was nothing wrong in the way I was composing the command in python - I made the mistake of a transaction in a transaction and created a lock condition so the clall never actually got resolved - hence the timeout.  Thanks for the reply confirming the syntax.  Much appreciated.

Polls
AI-powered tools for network troubleshooting are likely to be part of everyone’s workflow sooner or later. What is the single biggest challenge or concern you see with adopting these tools in your organization?