From 40cbea18e6afba46cdc72712b89a122a1377592b Mon Sep 17 00:00:00 2001 From: zhufl Date: Fri, 15 Mar 2019 09:50:06 +0800 Subject: [PATCH] Pass kwargs to exception to get better format of error message If we do not pass kwargs to exception, the parameter will be deemed as message and msg_fmt is ignored, so the message will be displayed directly. This is to pass kwargs to some exceptions, to get better format of error message. Change-Id: I66677a90430d9e6699619539cb8f575f57b19433 --- nova/cmd/common.py | 2 +- nova/db/sqlalchemy/api.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/nova/cmd/common.py b/nova/cmd/common.py index e65f78b735cc..684ae7ba2626 100644 --- a/nova/cmd/common.py +++ b/nova/cmd/common.py @@ -47,7 +47,7 @@ def block_db_access(service_name): LOG.error('No db access allowed in %(service_name)s: ' '%(stacktrace)s', dict(service_name=service_name, stacktrace=stacktrace)) - raise exception.DBNotAllowed(service_name) + raise exception.DBNotAllowed(binary=service_name) nova.db.api.IMPL = NoDB() diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index af747ffebc8f..2d8b5574cf47 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -1788,7 +1788,7 @@ def instance_destroy(context, instance_uuid, constraint=None): if uuidutils.is_uuid_like(instance_uuid): instance_ref = _instance_get_by_uuid(context, instance_uuid) else: - raise exception.InvalidUUID(instance_uuid) + raise exception.InvalidUUID(uuid=instance_uuid) query = model_query(context, models.Instance).\ filter_by(uuid=instance_uuid) @@ -2772,7 +2772,7 @@ def _instance_metadata_update_in_place(context, instance, metadata_type, model, def _instance_update(context, instance_uuid, values, expected, original=None): if not uuidutils.is_uuid_like(instance_uuid): - raise exception.InvalidUUID(instance_uuid) + raise exception.InvalidUUID(uuid=instance_uuid) if expected is None: expected = {}