From 51ba594bf81d8354c981b086bbd735fa7ff2055b Mon Sep 17 00:00:00 2001 From: Pablo Bovina Date: Wed, 25 Aug 2021 17:23:17 -0400 Subject: [PATCH] Handle cgts-client calls for non-admin users Handle http client exceptions for non-admin users. This is because some alarms/events metadata are not available for them. For example if the call fails the user will see the a value like: "host=controller-1.port=enp0s8" instead of: "host=controller-1.port=0cbb441a-874d-418e-bd57-7aa1b8ab0044" Before this if an error in translation happened, the user experienced an alert badge saying "Unable to retrieve Events", then the user seen an empty table. Story: 2009077 Task: 43093 Signed-off-by: Pablo Bovina Change-Id: I68eeb103a6fe97beb1fb7969a1cd9503210cdcb0 --- fm-rest-api/fm/fm/api/controllers/v1/utils.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fm-rest-api/fm/fm/api/controllers/v1/utils.py b/fm-rest-api/fm/fm/api/controllers/v1/utils.py index fadbea68..873fde00 100644 --- a/fm-rest-api/fm/fm/api/controllers/v1/utils.py +++ b/fm-rest-api/fm/fm/api/controllers/v1/utils.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2018 Wind River Systems, Inc. +# Copyright (c) 2018-2021 Wind River Systems, Inc. # # SPDX-License-Identifier: Apache-2.0 # @@ -10,6 +10,7 @@ import contextlib import traceback import pecan import wsme +from cgtsclient import exc from oslo_config import cfg from oslo_log import log from oslo_utils import uuidutils @@ -112,6 +113,10 @@ def replace_name_with_uuid(instance_id): except exceptions.ServerNotFound: LOG.error("Can't find the port for name %s", value) pass + except exc.HTTPException as http_exc: + msg = "Http request failed with code {}" + LOG.error(msg.format(http_exc.code)) + pass if port: new_id = key + KEY_VALUE_SEP + port.uuid