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
(cherry picked from commit ef62c73022)
This commit is contained in:
jichenjc 2016-11-18 16:03:38 +08:00
parent 19e5a6f0e9
commit d2cc445d20
2 changed files with 7 additions and 5 deletions

View File

@ -832,7 +832,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]

View File

@ -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