def save(self):
"""Persist the interfaces to disk"""
try:
logger.debug("Backing up interfaces")
if os.path.exists(self._db):
shutil.copyfile(self._db, "{}.bak".format(self._db))
except Exception as e:
logger.exception("Failed to backup interfaces")
return
try:
logger.debug("Saving interfaces")
with open(self._db, 'w') as f:
f.write(yaml.safe_dump(dict(((k, v) for (k, v) in self._interfaces.iteritems(
) if k not in self.reserved_interfaces)), default_flow_style=False, explicit_start=True))
except Exception as e:
logger.exception("Failed to save interfaces")
评论列表
文章目录