Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

Not finding prompt when connecting to multiple devices #2

Closed
dhanakane opened this issue Nov 3, 2017 · 3 comments
Closed

Not finding prompt when connecting to multiple devices #2

dhanakane opened this issue Nov 3, 2017 · 3 comments

Comments

@dhanakane
Copy link

dhanakane commented Nov 3, 2017

I'm running the following code on an IOS-XR device:

 11     async with netdev.create(**param) as ios:
 12         # Testing sending simple command
 13         print("starting task\n {} {}".format(80 * '#', ios))
 14         out = await ios.send_command("show run interface loopback0")
 15         print(out)
 16         # Testing sending configuration set
 17         out += await ios.send_command("exit", strip_command=False, strip_prompt=False)
 18         print(out)
 19         print("task: {} done\n".format(ios))

Looking at the logs, it looks like the prompt is never received from the device, so the connection is never terminated. Any advice?

@selfuryon
Copy link
Owner

selfuryon commented Nov 3, 2017

I think that the problem is in IOS-XR prompt because it doesn't like "hostname<delimeter>". I never tested netdev on IOS-XR, but it's not difficult for me. I will try to add IOS-XR support this weekend :) I will add information about it here

@selfuryon
Copy link
Owner

selfuryon commented Nov 4, 2017

@dhanakane I have tested IOS XR with IOS class - it works fine (but I mention about send_config_set - it doesn't make commit so you need to make it by hand. I will implement it in new IOS XR Class soon). In your case you made this:

RP/0/0/CPU0:ios#show run interface loopback0
Sat Nov  4 12:22:41.504 YEKAT
% No such configuration item(s)

RP/0/0/CPU0:ios#exit
<--- No more information (and prompt too) in buffer here because of you close session. 
Connection to 10.1.64.100 closed by remote host.
Connection to 10.1.64.100 closed.

As you see you made exit and close connection by hand but you don't need it - netdev make it himself: your session automatically will be closed after exiting async context manager (async with *** as ***). The reason of problem is that nedev doesn't check that session alive or not in reading. It only reads buffer from the connection. But asyncssh allows to reading it without any exception (don't know why I will research it)

And the other thing: if you want to test exactly applying configuration you should use send_config_set instead of send_command (but you can use and send_command too but in this case, you need manually enter and exit to configuration mode). It will be like this:

# Testing sending configuration set
commands = ["line console 0", "exit"]
out = await ios.send_config_set(commands)
RP/0/0/CPU0:ios#show run interface loopback0
Sat Nov  4 12:32:45.852 YEKAT
% No such configuration item(s)

RP/0/0/CPU0:ios#conf t   <------ automatically enter to config mode
Sat Nov  4 12:32:55.662 YEKAT
RP/0/0/CPU0:ios(config)#line console 0
RP/0/0/CPU0:ios(config-line)#exit
RP/0/0/CPU0:ios(config)#end    <------- automatically exit from config mode
RP/0/0/CPU0:ios#

Command send_config_set automatically enters to configuration mode and after applying command exits from it (but without commiting right now).

@selfuryon
Copy link
Owner

I added some support for IOS XR (adding with_commit parameter for IOX XR send_config_set. We can see example for IOS XR in example folder) at 2d413d0. You can use now device_type "cisco_xr" for IOS XR.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants