Send request_id on glance calls
This changes the constructor so that glance calls will carry forward the request_id to the glance service. ``global_id`` is a magic property on new oslo.context which is either set to the global_request_id sent into Nova, or the local request id if it's not set. Fix some unit tests to handle this new parameter when mocking glanceclient calls. oslo spec I65de8261746b25d45e105394f4eeb95b9cb3bd42 Change-Id: I16f9dda3c904c4a2578fa6a691fed646a41f6793
This commit is contained in:
parent
6b38344496
commit
9189d9be88
@ -91,6 +91,7 @@ def _glanceclient_from_endpoint(context, endpoint, version):
|
||||
# NOTE(sdague): even if we aren't using keystone, it doesn't
|
||||
# hurt to send these headers.
|
||||
params['identity_headers'] = generate_identity_headers(context)
|
||||
params['global_request_id'] = context.global_id
|
||||
if endpoint.startswith('https://'):
|
||||
# https specific params
|
||||
params['insecure'] = CONF.glance.api_insecure
|
||||
|
@ -353,8 +353,9 @@ class TestCreateGlanceClient(test.NoDBTestCase):
|
||||
'X-User-Id': 'fake',
|
||||
'X-Roles': '',
|
||||
'X-Tenant-Id': 'fake',
|
||||
'X-Identity-Status': 'Confirmed'
|
||||
}
|
||||
'X-Identity-Status': 'Confirmed',
|
||||
},
|
||||
'global_request_id': mock.ANY
|
||||
}
|
||||
glance._glanceclient_from_endpoint(ctx, expected_endpoint, 2)
|
||||
init_mock.assert_called_once_with('2', expected_endpoint,
|
||||
@ -370,8 +371,9 @@ class TestCreateGlanceClient(test.NoDBTestCase):
|
||||
'X-User-Id': 'fake',
|
||||
'X-Roles': '',
|
||||
'X-Tenant-Id': 'fake',
|
||||
'X-Identity-Status': 'Confirmed'
|
||||
}
|
||||
'X-Identity-Status': 'Confirmed',
|
||||
},
|
||||
'global_request_id': mock.ANY
|
||||
}
|
||||
glance._glanceclient_from_endpoint(ctx, expected_endpoint, 2)
|
||||
init_mock.assert_called_once_with('2', expected_endpoint,
|
||||
@ -511,10 +513,11 @@ class TestGlanceClientWrapper(test.NoDBTestCase):
|
||||
ssl_enable_mock):
|
||||
self.flags(ca_file='foo.cert', cert_file='bar.cert',
|
||||
key_file='wut.key', group='ssl')
|
||||
ctxt = mock.sentinel.ctx
|
||||
ctxt = mock.MagicMock()
|
||||
glance._glanceclient_from_endpoint(ctxt, 'https://host4:9295', 2)
|
||||
client_mock.assert_called_once_with(
|
||||
'2', 'https://host4:9295', insecure=False, ssl_compression=False,
|
||||
'2', 'https://host4:9295', global_request_id=mock.ANY,
|
||||
insecure=False, ssl_compression=False,
|
||||
cert_file='bar.cert', key_file='wut.key', cacert='foo.cert',
|
||||
identity_headers=mock.ANY)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user