Add possibility to pass global request ID
It can be done via ipa-global-request-id kernel commandline parameter. Story: 2007681 Task: 39792 Change-Id: I6f544327d310c976a1625cfb411947591867882a
This commit is contained in:
parent
c4a78862d3
commit
ba6ca246f5
@ -36,6 +36,12 @@ cli_opts = [
|
||||
'A special value "mdns" can be specified to fetch the '
|
||||
'URL using multicast DNS service discovery.'),
|
||||
|
||||
cfg.StrOpt('global_request_id',
|
||||
default=APARAMS.get('ipa-global-request-id'),
|
||||
help='Global request ID header to provide to Ironic API. '
|
||||
'Can be supplied as "ipa-global-request-id" kernel '
|
||||
'parameter. The value must be in form "req-<UUID>".'),
|
||||
|
||||
cfg.StrOpt('listen_host',
|
||||
default=APARAMS.get('ipa-listen-host',
|
||||
netutils.get_wildcard_address()),
|
||||
|
@ -68,6 +68,8 @@ class APIClient(object):
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
})
|
||||
if CONF.global_request_id:
|
||||
headers["X-OpenStack-Request-ID"] = CONF.global_request_id
|
||||
|
||||
verify, cert = utils.get_ssl_client_options(CONF)
|
||||
return self.session.request(method,
|
||||
|
@ -109,6 +109,8 @@ class TestBaseIronicPythonAgent(base.IronicAgentTest):
|
||||
|
||||
def test_successful_heartbeat(self):
|
||||
response = FakeResponse(status_code=202)
|
||||
req_id = "req-14c99bd0-1bb5-4d74-972b-e282a50ce441"
|
||||
self.config(global_request_id=req_id)
|
||||
|
||||
self.api_client.session.request = mock.Mock()
|
||||
self.api_client.session.request.return_value = response
|
||||
@ -122,8 +124,12 @@ class TestBaseIronicPythonAgent(base.IronicAgentTest):
|
||||
|
||||
heartbeat_path = 'v1/heartbeat/deadbeef-dabb-ad00-b105-f00d00bab10c'
|
||||
request_args = self.api_client.session.request.call_args[0]
|
||||
data = self.api_client.session.request.call_args[1]['data']
|
||||
request_kwargs = self.api_client.session.request.call_args[1]
|
||||
data = request_kwargs["data"]
|
||||
self.assertEqual('POST', request_args[0])
|
||||
request_headers = request_kwargs["headers"]
|
||||
self.assertEqual(
|
||||
req_id, request_headers["X-OpenStack-Request-ID"])
|
||||
self.assertEqual(API_URL + heartbeat_path, request_args[1])
|
||||
expected_data = {
|
||||
'callback_url': 'http://192.0.2.1:9999',
|
||||
|
Loading…
x
Reference in New Issue
Block a user