Change in vdsm[master]: Unified network persistence [4.1/4.*] - Upgrade mechanism

amuller at redhat.com amuller at redhat.com
Mon Dec 2 12:30:16 UTC 2013


Assaf Muller has posted comments on this change.

Change subject: Unified network persistence [4.1/4.*] - Upgrade mechanism
......................................................................


Patch Set 15:

(6 comments)

....................................................
File lib/vdsm/tool/upgrade.py
Line 41: 
Line 42:         To get more functionality you may use this module's 'upgrade'
Line 43:         decorator. It removes all boilerplate code, makes sure to run
Line 44:         the upgrade only if needed and to automatically call 'seal'
Line 45:         if no exception was thrown.
Done
Line 46:     """
Line 47:     def __init__(self, upgradeName):
Line 48:         self.upgradeName = upgradeName
Line 49:         self.upgradeFilePath = os.path.join(constants.P_VDSM_LIB,


Line 45:         if no exception was thrown.
Line 46:     """
Line 47:     def __init__(self, upgradeName):
Line 48:         self.upgradeName = upgradeName
Line 49:         self.upgradeFilePath = os.path.join(constants.P_VDSM_LIB,
Done
Line 50:                                             "upgrade", self.upgradeName)
Line 51:         try:
Line 52:             logging.config.fileConfig(LOGGER_CONF_FILE)
Line 53:             self.log = logging.getLogger('upgrade')


Line 51:         try:
Line 52:             logging.config.fileConfig(LOGGER_CONF_FILE)
Line 53:             self.log = logging.getLogger('upgrade')
Line 54:         except Exception:
Line 55:             logging.basicConfig(filename='/dev/stdout', filemode='w+',
Done
Line 56:                                 level=logging.DEBUG)
Line 57:             logging.error("Could not init proper logging", exc_info=True)
Line 58:             self.log = logging
Line 59: 


Line 63:     def seal(self):
Line 64:         """
Line 65:             Mark the upgrade as a success
Line 66:         """
Line 67:         touchFile(self.upgradeFilePath)
Done
Line 68:         self.log.debug("Upgrade %s successfully performed" % self.upgradeName)
Line 69: 
Line 70:     def __enter__(self):
Line 71:         """


Line 73:         will still be output to that logger. However, logging done by accessing
Line 74:         logging directly (Thus using the root logger) will be 'hijacked'
Line 75:         to the Upgrade's log instead.
Line 76:         """
Line 77:         self.oldRoot = logging.root
New approach implemented in the following patch sets.
Line 78:         logging.root = self.log
Line 79:         return self
Line 80: 
Line 81:     def __exit__(self, type, value, traceback):


Line 91:                     upgrade.log.debug("Running upgrade %s" % upgradeName)
Line 92:                     try:
Line 93:                         f(*args, **kwargs)
Line 94:                     except Exception:
Line 95:                         upgrade.log.exception("Failed to run %s" %
Done
Line 96:                                               upgradeName)
Line 97:                         return 1
Line 98:                     else:
Line 99:                         upgrade.seal()


-- 
To view, visit http://gerrit.ovirt.org/17726
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Iba3c9c34f03134c192db1c2add31084824e195d9
Gerrit-PatchSet: 15
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Assaf Muller <amuller at redhat.com>
Gerrit-Reviewer: Alon Bar-Lev <alonbl at redhat.com>
Gerrit-Reviewer: Antoni Segura Puimedon <asegurap at redhat.com>
Gerrit-Reviewer: Assaf Muller <amuller at redhat.com>
Gerrit-Reviewer: Barak Azulay <bazulay at redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken at redhat.com>
Gerrit-Reviewer: Federico Simoncelli <fsimonce at redhat.com>
Gerrit-Reviewer: Giuseppe Vallarelli <gvallare at redhat.com>
Gerrit-Reviewer: Mark Wu <wudxw at linux.vnet.ibm.com>
Gerrit-Reviewer: Saggi Mizrahi <smizrahi at redhat.com>
Gerrit-Reviewer: Yaniv Bronhaim <ybronhei at redhat.com>
Gerrit-HasComments: Yes


More information about the vdsm-patches mailing list