Remove InvalidParameterValue exception
The InvalidParameterValue exception does not define a meaningful
msg_fmt. It is currently _("%(err)s"), which is the equivalent of
nothing and does not help with translation.
Replace InvalidParameterValue with Invalid exceptions.
Change-Id: If8b064e446cbc97e380127f360f262be9e8877a1
Closes-Bug: #1538398
This commit is contained in:
@@ -56,7 +56,10 @@ class Migrate(base.BaseAction):
|
||||
return wrapper.live_migrate_instance(
|
||||
instance_id=self.instance_uuid, dest_hostname=destination)
|
||||
else:
|
||||
raise exception.InvalidParameterValue(err=self.migration_type)
|
||||
raise exception.Invalid(
|
||||
message=(_('Migration of type %(migration_type)s is not '
|
||||
'supported.') %
|
||||
{'migration_type': self.migration_type}))
|
||||
else:
|
||||
raise exception.InstanceNotFound(name=self.instance_uuid)
|
||||
|
||||
|
||||
@@ -133,12 +133,6 @@ class InvalidGoal(Invalid):
|
||||
msg_fmt = _("Goal %(goal)s is not defined in Watcher configuration file")
|
||||
|
||||
|
||||
# Cannot be templated as the error syntax varies.
|
||||
# msg needs to be constructed when raised.
|
||||
class InvalidParameterValue(Invalid):
|
||||
msg_fmt = _("%(err)s")
|
||||
|
||||
|
||||
class InvalidUUID(Invalid):
|
||||
msg_fmt = _("Expected a uuid but received %(uuid)s")
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@ class BaseConnection(object):
|
||||
:param audit_template_id: The id or uuid of an audit template.
|
||||
:returns: An audit template.
|
||||
:raises: AuditTemplateNotFound
|
||||
:raises: InvalidParameterValue
|
||||
:raises: Invalid
|
||||
"""
|
||||
|
||||
@abc.abstractmethod
|
||||
@@ -209,7 +209,7 @@ class BaseConnection(object):
|
||||
:param audit_id: The id or uuid of an audit.
|
||||
:returns: An audit.
|
||||
:raises: AuditNotFound
|
||||
:raises: InvalidParameterValue
|
||||
:raises: Invalid
|
||||
"""
|
||||
|
||||
def soft_delete_audit(self, audit_id):
|
||||
@@ -299,6 +299,7 @@ class BaseConnection(object):
|
||||
:returns: A action.
|
||||
:raises: ActionNotFound
|
||||
:raises: ActionReferenced
|
||||
:raises: Invalid
|
||||
"""
|
||||
|
||||
@abc.abstractmethod
|
||||
@@ -371,4 +372,5 @@ class BaseConnection(object):
|
||||
:returns: An action plan.
|
||||
:raises: ActionPlanNotFound
|
||||
:raises: ActionPlanReferenced
|
||||
:raises: Invalid
|
||||
"""
|
||||
|
||||
@@ -274,8 +274,9 @@ class Connection(api.BaseConnection):
|
||||
|
||||
def update_audit_template(self, audit_template_id, values):
|
||||
if 'uuid' in values:
|
||||
msg = _("Cannot overwrite UUID for an existing AuditTemplate.")
|
||||
raise exception.InvalidParameterValue(err=msg)
|
||||
raise exception.Invalid(
|
||||
message=_("Cannot overwrite UUID for an existing "
|
||||
"Audit Template."))
|
||||
|
||||
return self._do_update_audit_template(audit_template_id, values)
|
||||
|
||||
@@ -383,8 +384,9 @@ class Connection(api.BaseConnection):
|
||||
|
||||
def update_audit(self, audit_id, values):
|
||||
if 'uuid' in values:
|
||||
msg = _("Cannot overwrite UUID for an existing Audit.")
|
||||
raise exception.InvalidParameterValue(err=msg)
|
||||
raise exception.Invalid(
|
||||
message=_("Cannot overwrite UUID for an existing "
|
||||
"Audit."))
|
||||
|
||||
return self._do_update_audit(audit_id, values)
|
||||
|
||||
@@ -474,8 +476,9 @@ class Connection(api.BaseConnection):
|
||||
def update_action(self, action_id, values):
|
||||
# NOTE(dtantsur): this can lead to very strange errors
|
||||
if 'uuid' in values:
|
||||
msg = _("Cannot overwrite UUID for an existing Action.")
|
||||
raise exception.InvalidParameterValue(err=msg)
|
||||
raise exception.Invalid(
|
||||
message=_("Cannot overwrite UUID for an existing "
|
||||
"Action."))
|
||||
|
||||
return self._do_update_action(action_id, values)
|
||||
|
||||
@@ -583,8 +586,9 @@ class Connection(api.BaseConnection):
|
||||
|
||||
def update_action_plan(self, action_plan_id, values):
|
||||
if 'uuid' in values:
|
||||
msg = _("Cannot overwrite UUID for an existing Audit.")
|
||||
raise exception.InvalidParameterValue(err=msg)
|
||||
raise exception.Invalid(
|
||||
message=_("Cannot overwrite UUID for an existing "
|
||||
"Action Plan."))
|
||||
|
||||
return self._do_update_action_plan(action_plan_id, values)
|
||||
|
||||
|
||||
@@ -88,6 +88,10 @@ msgstr ""
|
||||
msgid "The target state is not defined"
|
||||
msgstr ""
|
||||
|
||||
#: watcher/applier/actions/migration.py:60
|
||||
msgid "Migration of type %(migration_type)s is not supported."
|
||||
msgstr ""
|
||||
|
||||
#: watcher/applier/workflow_engine/default.py:126
|
||||
#, python-format
|
||||
msgid "The WorkFlow Engine has failed to execute the action %s"
|
||||
@@ -162,11 +166,6 @@ msgstr ""
|
||||
msgid "Goal %(goal)s is not defined in Watcher configuration file"
|
||||
msgstr ""
|
||||
|
||||
#: watcher/common/exception.py:139
|
||||
#, python-format
|
||||
msgid "%(err)s"
|
||||
msgstr ""
|
||||
|
||||
#: watcher/common/exception.py:143
|
||||
#, python-format
|
||||
msgid "Expected a uuid but received %(uuid)s"
|
||||
|
||||
@@ -126,7 +126,7 @@ class DbActionTestCase(base.DbTestCase):
|
||||
|
||||
def test_update_action_uuid(self):
|
||||
action = self._create_test_action()
|
||||
self.assertRaises(exception.InvalidParameterValue,
|
||||
self.assertRaises(exception.Invalid,
|
||||
self.dbapi.update_action, action['id'],
|
||||
{'uuid': 'hello'})
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ class DbActionPlanTestCase(base.DbTestCase):
|
||||
|
||||
def test_update_action_plan_uuid(self):
|
||||
action_plan = self._create_test_action_plan()
|
||||
self.assertRaises(exception.InvalidParameterValue,
|
||||
self.assertRaises(exception.Invalid,
|
||||
self.dbapi.update_action_plan, action_plan['id'],
|
||||
{'uuid': 'hello'})
|
||||
|
||||
|
||||
@@ -147,7 +147,7 @@ class DbAuditTestCase(base.DbTestCase):
|
||||
|
||||
def test_update_audit_uuid(self):
|
||||
audit = self._create_test_audit()
|
||||
self.assertRaises(exception.InvalidParameterValue,
|
||||
self.assertRaises(exception.Invalid,
|
||||
self.dbapi.update_audit, audit['id'],
|
||||
{'uuid': 'hello'})
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ class DbAuditTemplateTestCase(base.DbTestCase):
|
||||
|
||||
def test_update_audit_template_uuid(self):
|
||||
audit_template = self._create_test_audit_template()
|
||||
self.assertRaises(exception.InvalidParameterValue,
|
||||
self.assertRaises(exception.Invalid,
|
||||
self.dbapi.update_audit_template,
|
||||
audit_template['id'],
|
||||
{'uuid': 'hello'})
|
||||
|
||||
Reference in New Issue
Block a user