diff --git a/napalm_srl/srl.py b/napalm_srl/srl.py index b9e92e2..d13eb0a 100644 --- a/napalm_srl/srl.py +++ b/napalm_srl/srl.py @@ -2264,7 +2264,7 @@ def _load_candidate(self,filename,config,is_replace): else: cfg = { 'replaces' if is_replace else 'updates': [ { 'path': '/', 'value': cfg } ] } - self.tmp_cfgfile = tempfile.TemporaryFile(mode='w') + self.tmp_cfgfile = tempfile.TemporaryFile(mode='w+') json.dump(cfg, self.tmp_cfgfile, sort_keys=True) self.tmp_cfgfile.seek(0) # Prepare for reading back return "JSON candidate config loaded for " + ("replace" if is_replace else "merge") @@ -2296,6 +2296,7 @@ def commit_config(self, message='', revert_in=None): if self._is_commit_pending(): try: + self.tmp_cfgfile.seek(0) json_config = json.load(self.tmp_cfgfile) if message: raise NotImplementedError("'message' not supported with JSON config") @@ -2884,3 +2885,4 @@ def _dictToList(self, aDict): if isinstance(aDict[key], dict): aDict[key] = self._dictToList(aDict[key]) return aDict +