From ef62c73022b0ed1387d941eea1455e215061278c Mon Sep 17 00:00:00 2001 From: jichenjc Date: Fri, 18 Nov 2016 16:03:38 +0800 Subject: [PATCH] Add ignore warning message routine sometimes we get console log from low layer and this is normal to contain 'warning' keyward, we need ignore this routine to avoid too much logs in compute log Change-Id: I661dd49e194adcf8e6d30b035f104254c6d916df --- nova/virt/zvm/instance.py | 3 ++- nova/virt/zvm/utils.py | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/nova/virt/zvm/instance.py b/nova/virt/zvm/instance.py index a31b1f1..d69b24a 100644 --- a/nova/virt/zvm/instance.py +++ b/nova/virt/zvm/instance.py @@ -829,7 +829,8 @@ class ZVMInstance(object): url = self._xcat_url.rinv('/' + self._name, '&field=--consoleoutput' '&field=%s') % logsize - res_info = zvmutils.xcat_request("GET", url) + # Because we might have logs in the console, we need ignore the warning + res_info = zvmutils.xcat_request("GET", url, ignore_warning=True) with zvmutils.expect_invalid_xcat_resp_data(res_info): log_data = res_info['info'][0][0] diff --git a/nova/virt/zvm/utils.py b/nova/virt/zvm/utils.py index 60927d7..089f1d0 100644 --- a/nova/virt/zvm/utils.py +++ b/nova/virt/zvm/utils.py @@ -369,11 +369,11 @@ class XCATConnection(object): return resp -def xcat_request(method, url, body=None, headers=None): +def xcat_request(method, url, body=None, headers=None, ignore_warning=False): headers = headers or {} conn = XCATConnection() resp = conn.request(method, url, body, headers) - return load_xcat_resp(resp['message']) + return load_xcat_resp(resp['message'], ignore_warning=ignore_warning) def jsonloads(jsonstr): @@ -495,7 +495,7 @@ def mapping_power_stat(power_stat): @wrap_invalid_xcat_resp_data_error -def load_xcat_resp(message): +def load_xcat_resp(message, ignore_warning=False): """Abstract information from xCAT REST response body. As default, xCAT response will in format of JSON and can be @@ -531,7 +531,8 @@ def load_xcat_resp(message): else: raise exception.ZVMXCATInternalError(msg=message) - _log_warnings(resp) + if not ignore_warning: + _log_warnings(resp) return resp