Skip to content

Commit 8af98b2

Browse files
authored
Merge pull request #55 from lucasalvatore/dev
open tmp_cfgfil with w+ and fix seek
2 parents 5cf6abd + 4259ef8 commit 8af98b2

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

napalm_srl/srl.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2264,7 +2264,7 @@ def _load_candidate(self,filename,config,is_replace):
22642264
else:
22652265
cfg = { 'replaces' if is_replace else 'updates': [ { 'path': '/', 'value': cfg } ] }
22662266

2267-
self.tmp_cfgfile = tempfile.TemporaryFile(mode='w')
2267+
self.tmp_cfgfile = tempfile.TemporaryFile(mode='w+')
22682268
json.dump(cfg, self.tmp_cfgfile, sort_keys=True)
22692269
self.tmp_cfgfile.seek(0) # Prepare for reading back
22702270
return "JSON candidate config loaded for " + ("replace" if is_replace else "merge")
@@ -2296,6 +2296,7 @@ def commit_config(self, message='', revert_in=None):
22962296

22972297
if self._is_commit_pending():
22982298
try:
2299+
self.tmp_cfgfile.seek(0)
22992300
json_config = json.load(self.tmp_cfgfile)
23002301
if message:
23012302
raise NotImplementedError("'message' not supported with JSON config")
@@ -2884,3 +2885,4 @@ def _dictToList(self, aDict):
28842885
if isinstance(aDict[key], dict):
28852886
aDict[key] = self._dictToList(aDict[key])
28862887
return aDict
2888+

0 commit comments

Comments
 (0)