Log xCAT REST call details as debug info
Log xCAT REST request target xCAT server ip address, method, url, body and headers before sending it. Log xCAT http response status, reason and message after recieved the response. Change-Id: I76dc9a7d57cfbdf8bf6e175bb8d7da92850445fe
This commit is contained in:
parent
152742168b
commit
b13e505b5d
@ -1729,12 +1729,19 @@ class ZVMInstanceTestCases(ZVMTestCase):
|
||||
self._set_fake_xcat_responses([self._generate_xcat_resp(info)])
|
||||
self._instance.update_node_info(image_meta)
|
||||
|
||||
def test_deploy_node(self):
|
||||
self._set_fake_xcat_responses([self._generate_xcat_resp(['fake'])])
|
||||
@mock.patch('nova.virt.zvm.utils.xcat_request')
|
||||
@mock.patch('nova.virt.zvm.utils.get_host')
|
||||
def test_deploy_node(self, get_host, xcat_req):
|
||||
get_host.return_value = 'fake@fakehost'
|
||||
xcat_req.return_value = 'fake'
|
||||
self._instance.deploy_node('fakeimg', '/fake/file', '0100')
|
||||
|
||||
def test_deploy_node_failed(self):
|
||||
self._set_fake_xcat_responses([{'data': [{'error': ['fake']}]}])
|
||||
@mock.patch('nova.virt.zvm.utils.xcat_request')
|
||||
@mock.patch('nova.virt.zvm.utils.get_host')
|
||||
def test_deploy_node_failed(self, get_host, xcat_req):
|
||||
get_host.return_value = 'fake@fakehost'
|
||||
xcat_req.side_effect = exception.ZVMXCATDeployNodeFailed(node="fake",
|
||||
msg='msg')
|
||||
self.assertRaises(exception.ZVMXCATDeployNodeFailed,
|
||||
self._instance.deploy_node, 'fakeimg', '/fake/file')
|
||||
|
||||
|
@ -199,6 +199,18 @@ class XCATConnection():
|
||||
headers = {'content-type': 'text/plain',
|
||||
'content-length': len(body)}
|
||||
|
||||
_rep_ptn = ''.join(('&password=', CONF.zvm_xcat_password))
|
||||
LOG.debug("Sending request to xCAT. xCAT-Server:%(xcat_server)s "
|
||||
"Request-method:%(method)s "
|
||||
"URL:%(url)s "
|
||||
"Headers:%(headers)s "
|
||||
"Body:%(body)s" %
|
||||
{'xcat_server': CONF.zvm_xcat_server,
|
||||
'method': method,
|
||||
'url': url.replace(_rep_ptn, ''), # hide password in log
|
||||
'headers': str(headers),
|
||||
'body': body})
|
||||
|
||||
try:
|
||||
self.conn.request(method, url, body, headers)
|
||||
except socket.gaierror as err:
|
||||
@ -220,6 +232,8 @@ class XCATConnection():
|
||||
'reason': res.reason,
|
||||
'message': msg}
|
||||
|
||||
LOG.debug("xCAT response: %s" % str(resp))
|
||||
|
||||
# Only "200" or "201" returned from xCAT can be considered
|
||||
# as good status
|
||||
err = None
|
||||
|
Loading…
x
Reference in New Issue
Block a user