Skip to content
This repository has been archived by the owner on Jan 16, 2019. It is now read-only.

Commit

Permalink
Schedule reverting before modifying the running-config
Browse files Browse the repository at this point in the history
  • Loading branch information
mirceaulinic committed Mar 15, 2017
1 parent 2e58ecf commit 7920b53
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions napalm_ios/ios.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,17 +371,18 @@ def commit_config(self, confirmed=0):
cfg_file = self._gen_full_path(filename)
if not self._check_file_exists(cfg_file):
raise MergeConfigException("Merge source config file does not exist")
cmd = 'copy {} running-config'.format(cfg_file)
self._disable_confirm()
output = self._commit_hostname_handler(cmd)
if confirmed:
# Create the candidate config file
cmd = 'copy running-config {}'.format(self.candidate_cfg)
output += self.device.send_command_expect(cmd)
# Replace with the candidate and force rollback if not confirmed
cmd = 'configure replace bootflash:{} force time {}'.format(self.candidate_cfg,
# Replace running config with the rollback config
# And schedule the revert time
# If not confirmed, it will go back to the current running-config state
cmd = 'configure replace bootflash:{} force time {}'.format(self.rollback_cfg,
confirmed)
output += self.device.send_command_expect(cmd)
output = self.device.send_command_expect(cmd)
# The rest of the commands will be loaded directly through the normal
# merge into the running-config
cmd = 'copy {} running-config'.format(cfg_file)
output = self._commit_hostname_handler(cmd)
self._enable_confirm()
if 'Invalid input detected' in output:
self.rollback()
Expand All @@ -393,7 +394,7 @@ def commit_config(self, confirmed=0):
output += self.device.send_command_expect("write mem")

def commit_confirm(self):
# Confirm replacement of running-config with a new config file
# Confirm replacement of running-config
output = self.device.send_command_expect('configure confirm')
# Save config to startup (both replace and merge)
output += self.device.send_command_expect("write mem")
Expand Down

0 comments on commit 7920b53

Please sign in to comment.