Hello Nir Soffer, Dan Kenigsberg, Francesco Romani,
I'd like you to do a code review. Please visit
http://gerrit.ovirt.org/32053
to review the following change.
Change subject: tool: Raise UsageError when used incorrectly
......................................................................
tool: Raise UsageError when used incorrectly
Commit e5e80540e8 added a new type of error, when user try to configure
non existing module. The test for this feature expect a SystemExit
exception, but the code was actualy raising a KeyError.
Seems that both the test and the code are wrong, so now a UsageError is
raised in this case.
Change-Id: I8e0528c84b41eee56c141d725c837cf48df5d186
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
Reviewed-on:
http://gerrit.ovirt.org/31735
Reviewed-by: mooli tayer <mtayer(a)redhat.com>
Reviewed-by: Francesco Romani <fromani(a)redhat.com>
Reviewed-by: Dan Kenigsberg <danken(a)redhat.com>
---
M lib/vdsm/tool/configurator.py
M tests/toolTests.py
2 files changed, 4 insertions(+), 3 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/53/32053/1
diff --git a/lib/vdsm/tool/configurator.py b/lib/vdsm/tool/configurator.py
index 2f71075..7f4dc1a 100644
--- a/lib/vdsm/tool/configurator.py
+++ b/lib/vdsm/tool/configurator.py
@@ -22,7 +22,7 @@
import sys
import traceback
-from . import service, expose
+from . import service, expose, UsageError
from .configurators import \
certificates, \
CONFIGURED, \
@@ -180,7 +180,7 @@
try:
requiredNames = _getConfigurers()[next_].getRequires()
except KeyError:
- raise KeyError(
+ raise UsageError(
"error: argument --module: "
"invalid choice: %s (choose from %s)\n" % (next_,
modulesNames)
)
diff --git a/tests/toolTests.py b/tests/toolTests.py
index bdd8a5d..b41ae50 100644
--- a/tests/toolTests.py
+++ b/tests/toolTests.py
@@ -24,6 +24,7 @@
NOT_SURE
from vdsm.tool.configurators.configfile import ConfigFile, ParserWrapper
from vdsm.tool.configurators.libvirt import Libvirt
+from vdsm.tool import UsageError
from vdsm.tool import upgrade
from vdsm import utils
import monkeypatch
@@ -151,7 +152,7 @@
def testNonExistentModule(self):
self.assertRaises(
- SystemExit,
+ UsageError,
configurator._parse_args,
'validate-config',
'--module=b'
--
To view, visit
http://gerrit.ovirt.org/32053
To unsubscribe, visit
http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8e0528c84b41eee56c141d725c837cf48df5d186
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.5
Gerrit-Owner: mooli tayer <mtayer(a)redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken(a)redhat.com>
Gerrit-Reviewer: Francesco Romani <fromani(a)redhat.com>
Gerrit-Reviewer: Nir Soffer <nsoffer(a)redhat.com>