Skip to content

Commit

Permalink
Add option to save config to startup
Browse files Browse the repository at this point in the history
  • Loading branch information
jbemmel committed Oct 4, 2023
1 parent 32f2d77 commit 4e0140d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions napalm_srl/srl.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ def __init__(self, hostname, username, password, timeout=60, optional_args=None)
self.device = SRLAPI(hostname, username, password, timeout=60, optional_args=optional_args)

self.pending_commit = False
# Whether to save changes to startup config, default False
self.commit_mode = "save" if optional_args.get("commit_save",False) else "now"
self.cand_config_file_path = f"/tmp/{hostname}.json"
self.chkpoint_id = 0

Expand Down Expand Up @@ -2155,10 +2157,9 @@ def _cli_commit(self, message='', revert_in=None):
"""
try:
cmds = [
# "enter candidate private name {}".format(self.private_candidate_name),
"enter candidate private ",
"/",
'commit now comment "{}"'.format(message) if message else "commit now"
f'commit { self.commit_mode }' + (f'comment "{message}"' if message else '')
]
output = self.device._jsonrpcRunCli(cmds)
return self._return_result(output)
Expand Down Expand Up @@ -2339,7 +2340,7 @@ def rollback(self):
[
"enter candidate private",
f"load checkpoint name NAPALM-{self.chkpoint_id}", # Use named checkpoint to avoid parallel overwrite
"commit now"
f"commit {self.commit_mode}"
]
)
return output
Expand Down

0 comments on commit 4e0140d

Please sign in to comment.