Change in vdsm[master]: Add --force option to upgrades

amuller at redhat.com amuller at redhat.com
Thu Dec 26 08:36:37 UTC 2013


Assaf Muller has uploaded a new change for review.

Change subject: Add --force option to upgrades
......................................................................

Add --force option to upgrades

The --force option will ignore the existance of upgrade files
in /var/lib/vdsm/upgrade/

Each upgrade will still only run if it thinks it should run.

Change-Id: I2e6b84bdd14b9cd3921cea187b2654be22989334
Signed-off-by: Assaf Muller <amuller at redhat.com>
---
M lib/vdsm/tool/unified_persistence.py
M lib/vdsm/tool/upgrade.py
M lib/vdsm/tool/upgrade_300_networks.py
3 files changed, 17 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/50/22750/1

diff --git a/lib/vdsm/tool/unified_persistence.py b/lib/vdsm/tool/unified_persistence.py
index d1b3d0a..a2d92cf 100644
--- a/lib/vdsm/tool/unified_persistence.py
+++ b/lib/vdsm/tool/unified_persistence.py
@@ -137,7 +137,7 @@
 
 
 @expose('upgrade-to-unified-persistence')
-def unified_persistence():
+def unified_persistence(*args):
     """
     Upgrade host networking persistence from ifcfg to unified if the
     persistence model is set as unified in /usr/lib64/python2.X/site-packages/
diff --git a/lib/vdsm/tool/upgrade.py b/lib/vdsm/tool/upgrade.py
index c3e92bc..8c9f57b 100644
--- a/lib/vdsm/tool/upgrade.py
+++ b/lib/vdsm/tool/upgrade.py
@@ -17,6 +17,7 @@
 # Refer to the README and COPYING files for full details of the license
 #
 
+import argparse
 from functools import wraps
 import logging
 import logging.config
@@ -116,6 +117,18 @@
         self._detachUpgradeLog()
 
 
+def _parse_args():
+    parser = argparse.ArgumentParser('vdsm-tool')
+    parser.add_argument(
+        '--force',
+        dest='force',
+        default=False,
+        action='store_true',
+        help='Run the upgrade again, even if it was ran before',
+    )
+    return parser.parse_args(sys.argv[2:])
+
+
 def upgrade(upgradeName):
     """
     Used as a decorator for upgrades. Runs the upgrade with an Upgrade
@@ -126,7 +139,8 @@
         @wraps(f)
         def wrapper(*args, **kwargs):
             with Upgrade(upgradeName) as upgrade:
-                if upgrade.isNeeded():
+                cliArguments = _parse_args()
+                if cliArguments.force or upgrade.isNeeded():
                     upgrade.log.debug("Running upgrade %s", upgradeName)
                     try:
                         f(*args, **kwargs)
diff --git a/lib/vdsm/tool/upgrade_300_networks.py b/lib/vdsm/tool/upgrade_300_networks.py
index 0f754fd..41a49b5 100644
--- a/lib/vdsm/tool/upgrade_300_networks.py
+++ b/lib/vdsm/tool/upgrade_300_networks.py
@@ -55,7 +55,7 @@
 
 
 @expose('upgrade-3.0.0-networks')
-def upgrade_networks():
+def upgrade_networks(*args):
     """
     Since ovirt-3.0, Vdsm uses libvirt networks (with names vdsm-*) to store
     its own networks. Older Vdsms did not have those defined, and used only


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2e6b84bdd14b9cd3921cea187b2654be22989334
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Assaf Muller <amuller at redhat.com>


More information about the vdsm-patches mailing list