Assaf Muller has uploaded a new change for review. Change subject: New upgrade system ......................................................................
New upgrade system New simplistic upgrade system to support running code exactly once. Change-Id: Iba3c9c34f03134c192db1c2add31084824e195d9 Signed-off-by: Assaf Muller <[email protected]> --- M configure.ac M vdsm.spec.in M vdsm/Makefile.am A vdsm/upgrade/Makefile.am A vdsm/upgrade/upgrade.py 5 files changed, 81 insertions(+), 1 deletion(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/26/17726/1 diff --git a/configure.ac b/configure.ac index 0ccca95..0504a8a 100644 --- a/configure.ac +++ b/configure.ac @@ -217,6 +217,7 @@ vdsm/storage/Makefile vdsm/storage/imageRepository/Makefile vdsm/storage/protect/Makefile + vdsm/upgrade/Makefile vdsm_api/Makefile vdsm_hooks/Makefile vdsm_hooks/checkimages/Makefile diff --git a/vdsm.spec.in b/vdsm.spec.in index 87bc231..4389575 100644 --- a/vdsm.spec.in +++ b/vdsm.spec.in @@ -964,6 +964,8 @@ %{_datadir}/%{vdsm_name}/respawn %{_datadir}/%{vdsm_name}/sampling.py* %{_datadir}/%{vdsm_name}/set-conf-item +%dir %{_datadir}/%{vdsm_name}/upgrade +%{_datadir}/%{vdsm_name}/upgrade/upgrade.py* %if 0%{?with_gluster} %dir %{_datadir}/%{vdsm_name}/gluster %{_datadir}/%{vdsm_name}/gluster/__init__.py* @@ -997,6 +999,7 @@ %config(noreplace) %{_sysconfdir}/pki/%{vdsm_name}/keys/libvirt_password %dir %{_localstatedir}/lib/%{vdsm_name} %dir %{_localstatedir}/lib/%{vdsm_name}/netconfback +%dir %{_localstatedir}/lib/%{vdsm_name}/upgrade %dir %{_localstatedir}/run/%{vdsm_name} %dir %{_localstatedir}/run/%{vdsm_name}/sourceRoutes %dir %{_localstatedir}/run/%{vdsm_name}/trackedInterfaces diff --git a/vdsm/Makefile.am b/vdsm/Makefile.am index c30dcd9..33f91d6 100644 --- a/vdsm/Makefile.am +++ b/vdsm/Makefile.am @@ -18,7 +18,7 @@ # Refer to the README and COPYING files for full details of the license # -SUBDIRS = netconf sos storage gluster +SUBDIRS = netconf sos storage gluster upgrade include $(top_srcdir)/build-aux/Makefile.subs @@ -172,6 +172,7 @@ $(MKDIR_P) $(DESTDIR)$(vdsmrundir)/trackedInterfaces $(MKDIR_P) $(DESTDIR)$(vdsmrundir)/payload $(MKDIR_P) $(DESTDIR)$(vdsmlibdir)/netconfback + $(MKDIR_P) $(DESTDIR)$(vdsmlibdir)/upgrade $(MKDIR_P) $(DESTDIR)$(vdsmpoolsdir) $(MKDIR_P) $(DESTDIR)$(vdsmbackupdir) $(MKDIR_P) $(DESTDIR)$(localstatedir)/lib/libvirt/qemu/channels diff --git a/vdsm/upgrade/Makefile.am b/vdsm/upgrade/Makefile.am new file mode 100644 index 0000000..014864a --- /dev/null +++ b/vdsm/upgrade/Makefile.am @@ -0,0 +1,26 @@ +# +# Copyright 2013 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +# +# Refer to the README and COPYING files for full details of the license +# + +include $(top_srcdir)/build-aux/Makefile.subs + +upgradedir = $(vdsmdir)/upgrade + +dist_upgrade_PYTHON = \ + upgrade.py diff --git a/vdsm/upgrade/upgrade.py b/vdsm/upgrade/upgrade.py new file mode 100644 index 0000000..60913bc --- /dev/null +++ b/vdsm/upgrade/upgrade.py @@ -0,0 +1,49 @@ +# Copyright 2013 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +# +# Refer to the README and COPYING files for full details of the license +# + +import logging +import os + +import dsaversion +from vdsm import constants + + +class Upgrade(object): + def __init__(self): + self.upgradeName = self.__class__.__name__ + self.log = logging.getLogger('vds') + + def runIfNeeded(self): + if self.isNeeded(): + self.log.debug("Running upgrade %s" % self.upgradeName) + self.run() + self.done() + + def isNeeded(self): + return not os.path.exists(self._getUpgradeFilePath()) + + def run(self): + raise NotImplementedError + + def done(self): + with open(self._getUpgradeFilePath(), 'w') as upgradeFile: + upgradeFile.write(dsaversion.raw_version_revision) + + def _getUpgradeFilePath(self): + return constants.P_VDSM_LIB + "upgrade/%s" % self.upgradeName -- To view, visit http://gerrit.ovirt.org/17726 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iba3c9c34f03134c192db1c2add31084824e195d9 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Assaf Muller <[email protected]> _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
