Antoni Segura Puimedon has posted comments on this change. Change subject: Unified network persistence [1/3] - Save running config ......................................................................
Patch Set 22: (7 comments) .................................................... File lib/vdsm/unifiedpersistence.py Line 14: # You should have received a copy of the GNU General Public License Line 15: # along with this program; if not, write to the Free Software Line 16: # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Line 17: # Line 18: # Refer to the README and COPYING files for full details of the license Done Line 19: # Line 20: Line 21: import errno Line 22: import json Line 34: def __init__(self, savePath): Line 35: self.networksPath = savePath + 'nets/' Line 36: self.bondingsPath = savePath + 'bonds/' Line 37: self.networks = self._getConfigs(self.networksPath) Line 38: self.bonds = self._getConfigs(self.bondingsPath) The model I aim for is to have a runningConfig instance A (created on instantiation) and an instance B( created upon transaction beginning). If the transaction is successful, commit will make B take the place of A, otherwise, the changes to revert will be described by A-B. This will be done in a later patch. Line 39: Line 40: def __eq__(self, other): Line 41: return self.networks == other.networks and self.bonds == other.bonds Line 42: Line 39: Line 40: def __eq__(self, other): Line 41: return self.networks == other.networks and self.bonds == other.bonds Line 42: Line 43: def __repr(self): Done Line 44: return '%s(%s, %s)' % (self.__class__.__name__, self.networks, Line 45: self.bonds) Line 46: Line 47: def _networkPath(self, network): Line 70: fullPath = path + fileName Line 71: networkEntities[fileName] = self._getConfigDict(fullPath) Line 72: except OSError as ose: Line 73: if ose.errno == errno.ENOENT: Line 74: logging.debug('Unified persistence: No existent config set.') Done Line 75: else: Line 76: raise Line 77: Line 78: return networkEntities Line 78: return networkEntities Line 79: Line 80: def _setConfig(self, config, path): Line 81: dirPath = os.path.dirname(path) Line 82: if not os.path.exists(dirPath): Done Line 83: os.makedirs(dirPath) Line 84: with open(path, 'w') as configurationFile: Line 85: json.dump(config, configurationFile) Line 86: Line 85: json.dump(config, configurationFile) Line 86: Line 87: def _removeConfig(self, path): Line 88: try: Line 89: os.unlink(path) Done Line 90: except OSError as ose: Line 91: if ose.errno == errno.ENOENT: Line 92: logging.debug('Unified persistence: Network entity at %s not ' Line 93: 'found for removal' % path) Line 100: if value is not None and key not in Line 101: ('configurator', '_netinfo', 'force', Line 102: 'implicitBonding')) Line 103: self.networks[network] = cleanAttrs Line 104: logging.info('Unified persistence: Adding network %s(%s)' % Done Line 105: (network, cleanAttrs)) Line 106: Line 107: def removeNetwork(self, network): Line 108: try: -- To view, visit http://gerrit.ovirt.org/16699 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I7137a96f84abd2c5e532c6c37737e36ef17567a9 Gerrit-PatchSet: 22 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Antoni Segura Puimedon <asegu...@redhat.com> Gerrit-Reviewer: Antoni Segura Puimedon <asegu...@redhat.com> Gerrit-Reviewer: Assaf Muller <amul...@redhat.com> Gerrit-Reviewer: Dan Kenigsberg <dan...@redhat.com> Gerrit-Reviewer: Giuseppe Vallarelli <gvall...@redhat.com> Gerrit-Reviewer: Livnat Peer <lp...@redhat.com> Gerrit-Reviewer: Mark Wu <wu...@linux.vnet.ibm.com> Gerrit-Reviewer: Petr Ĺ ebek <pse...@redhat.com> Gerrit-Reviewer: oVirt Jenkins CI Server Gerrit-HasComments: Yes _______________________________________________ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches