diff --git a/watcher/applier/primitives/change_nova_service_state.py b/watcher/applier/primitives/change_nova_service_state.py index c82a828f6..ec8e673e1 100644 --- a/watcher/applier/primitives/change_nova_service_state.py +++ b/watcher/applier/primitives/change_nova_service_state.py @@ -63,7 +63,7 @@ class ChangeNovaServiceState(base.BasePrimitive): def nova_manage_service(self, state): if state is None: raise exception.IllegalArgumentException( - _("The target state is not defined")) + message=_("The target state is not defined")) keystone = kclient.KeystoneClient() wrapper = nclient.NovaClient(keystone.get_credentials(), diff --git a/watcher/common/exception.py b/watcher/common/exception.py index b31fe5b67..6df955a3c 100644 --- a/watcher/common/exception.py +++ b/watcher/common/exception.py @@ -220,51 +220,16 @@ class PatchError(Invalid): # decision engine -class BaseException(Exception): - - def __init__(self, desc=""): - if (not isinstance(desc, six.string_types)): - raise ValueError(_("Description must be an instance of str")) - - desc = desc.strip() - - self._desc = desc - - def get_description(self): - return self._desc - - def get_message(self): - return _("An exception occurred without a description") - - def __str__(self): - return self.get_message() +class IllegalArgumentException(WatcherException): + msg_fmt = _('Illegal argument') -class IllegalArgumentException(BaseException): - def __init__(self, desc): - desc = desc or _("Description cannot be empty") - super(IllegalArgumentException, self).__init__(desc) - - def get_message(self): - return self._desc +class NoSuchMetric(WatcherException): + msg_fmt = _('No such metric') -class NoSuchMetric(BaseException): - def __init__(self, desc): - desc = desc or _("No such metric") - super(NoSuchMetric, self).__init__(desc) - - def get_message(self): - return self._desc - - -class NoDataFound(BaseException): - def __init__(self, desc): - desc = desc or _("No rows were returned") - super(NoDataFound, self).__init__(desc) - - def get_message(self): - return self._desc +class NoDataFound(WatcherException): + msg_fmt = _('No rows were returned') class KeystoneFailure(WatcherException): diff --git a/watcher/decision_engine/model/model_root.py b/watcher/decision_engine/model/model_root.py index 7ae764328..eb5cda841 100644 --- a/watcher/decision_engine/model/model_root.py +++ b/watcher/decision_engine/model/model_root.py @@ -34,12 +34,12 @@ class ModelRoot(object): def assert_hypervisor(self, obj): if not isinstance(obj, hypervisor.Hypervisor): raise exception.IllegalArgumentException( - _("'obj' argument type is not valid")) + message=_("'obj' argument type is not valid")) def assert_vm(self, obj): if not isinstance(obj, vm.VM): raise exception.IllegalArgumentException( - _("'obj' argument type is not valid")) + message=_("'obj' argument type is not valid")) def add_hypervisor(self, hypervisor): self.assert_hypervisor(hypervisor)