Skip to content

Commit

Permalink
Automatic rollback on invalid replace config
Browse files Browse the repository at this point in the history
  • Loading branch information
ktbyers committed Jan 8, 2016
1 parent ae5d9cd commit e520822
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion napalm/ios.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def __init__(self, hostname, username, password, timeout=60, optional_args=None)
self.dest_file_system = optional_args.get('dest_file_system', 'flash:')
self.global_delay_factor = optional_args.get('global_delay_factor', .5)
self.port = optional_args.get('port', 22)
self.auto_rollback_on_error = optional_args.get('auto_rollback_on_error', True)
self.device = None
self.config_replace = False

Expand Down Expand Up @@ -142,7 +143,10 @@ def commit_config(self, filename=None):
cfg_file = self.gen_full_path(filename)
if not self._check_file_exists(cfg_file):
raise ReplaceConfigException("Candidate config file does not exist")
cmd = 'configure replace {} force'.format(cfg_file)
if self.auto_rollback_on_error:
cmd = 'configure replace {} force revert trigger error'.format(cfg_file)
else:
cmd = 'configure replace {} force'.format(cfg_file)
self.device.send_command(cmd, delay_factor=1)
# Merge operation
else:
Expand Down

0 comments on commit e520822

Please sign in to comment.