ktbyers / netmiko

Multi-vendor library to simplify Paramiko SSH connections to network devices
MIT License
3.55k stars 1.3k forks source link

Problem ending IOX XR config mode without commit command #34

Closed ravenblue12 closed 9 years ago

ravenblue12 commented 9 years ago

The following question will occur when you end the config mode at IOS XR without commit:

RP/0/0/CPU0:ios-xrv(config)#end Uncommitted changes found, commit them before exiting(yes/no/cancel)? [cancel]:

ravenblue12 commented 9 years ago

send_config_set(<commands, commit=True) is working, but without commit is not wokring!

ktbyers commented 9 years ago

I want to look at this behavior on Juniper too.

ktbyers commented 9 years ago

This change was merged in...need to decide if this is best way to handle this.

diff cisco_xr_ssh.py ~/netmiko_old/netmiko/netmiko/cisco/cisco_xr_ssh.py 30,48d29 < def exit_config_mode(self, exit_config='end'): < ''' < First check whether in configuration mode. < < If so, exit config mode < ''' < DEBUG = False < output = '' <
< if self.check_config_mode(): < output = self.send_command(exit_config, strip_prompt=False, strip_command=False) < if "Uncommitted changes found" in output: < output += self.send_command('yes\n', strip_prompt=False, strip_command=False) < if DEBUG: < print output < if self.check_config_mode(): < raise ValueError("Failed to exit configuration mode") <
< return output

supertylerc commented 9 years ago

Wouldn't this commit the changes and then exit? It seems that the Principle of Least Surprise would suggest abandoning the change. If I wanted to commit the change, I would have a line that says "commit" in it, right?

ktbyers commented 9 years ago

Yes, I agree this is a mistake. It should do "no" and probably print a warning.

I will just change the action for now to 'no'.

ktbyers commented 9 years ago

Okay, I have changed this action to no.

supertylerc commented 9 years ago

I'm not sure if you have access to Juniper devices, but the opposite behavior is necessary with Juniper, which should be easy to handle. Only mentioning this because you noted you wanted to look into the Juniper side as well.

root@bananas> edit
Entering configuration mode
The configuration has been changed but not committed

[edit]
root@bananas# set system host-name apple

[edit]
root@bananas# quit
The configuration has been changed but not committed
Exit with uncommitted changes? [yes,no] (yes) yes

Exiting configuration mode

root@bananas>
ktbyers commented 9 years ago

Okay, there is a Juniper specific method so we can change the behavior in this class.

I want to address the commit/confirm/rollback in a more systematic way for Juniper and IOS-XR. Hopefully, this week.

Kirk

On Sat, Mar 7, 2015 at 9:18 AM, Tyler Christiansen <notifications@github.com

wrote:

I'm not sure if you have access to Juniper devices, but the opposite behavior is necessary with Juniper, which should be easy to handle.

root@bananas> edit Entering configuration mode The configuration has been changed but not committed

[edit] root@bananas# set system host-name apple

[edit] root@bananas# quit The configuration has been changed but not committed Exit with uncommitted changes? yes,no yes

Exiting configuration mode

root@bananas>

— Reply to this email directly or view it on GitHub https://github.com/ktbyers/netmiko/issues/34#issuecomment-77699092.

Kirk Byers CCIE #6243 emeritus ktbyers@twb-tech.com http://pynet.twb-tech.com http://pynet.twb-tech.com/blog (415) 264-6270 Simplify your network management through automation

ktbyers commented 9 years ago

Referencing from master issue #60 (design spec). Leaving this open separately as the current behavior is a bug.

supertylerc commented 9 years ago

The Juniper issue was resolved by recent commits.

ktbyers commented 9 years ago

Duplicate with issue #88 also see master issue #89 for IOS-XR commit