Follow up to introspection data driver api revision
In https://review.openstack.org/#/c/637673, the get introspection interface is narrowed down to only accept node uuid, which previously accepts both uuid and name. But the name to uuid conversion is missing in the reapply api, which causes feature regression, and this is the fix :( Story: 1726713 Task: 11373 Change-Id: I6912853deab77f1365f665ca1e52c13063d2cdf1
This commit is contained in:
parent
88789e3412
commit
9c6c7c0a57
|
@ -126,16 +126,16 @@ class ConductorManager(object):
|
|||
introspect.abort(node_id, token=token)
|
||||
|
||||
@messaging.expected_exceptions(utils.Error)
|
||||
def do_reapply(self, context, node_id, token=None):
|
||||
def do_reapply(self, context, node_uuid, token=None):
|
||||
try:
|
||||
data = process.get_introspection_data(node_id, processed=False,
|
||||
data = process.get_introspection_data(node_uuid, processed=False,
|
||||
get_json=True)
|
||||
except utils.IntrospectionDataStoreDisabled:
|
||||
raise utils.Error(_('Inspector is not configured to store '
|
||||
'data. Set the [processing]store_data '
|
||||
'configuration option to change this.'),
|
||||
code=400)
|
||||
process.reapply(node_id, data)
|
||||
process.reapply(node_uuid, data)
|
||||
|
||||
|
||||
def periodic_clean_up(): # pragma: no cover
|
||||
|
|
|
@ -310,9 +310,11 @@ def api_introspection_reapply(node_id):
|
|||
if flask.request.content_length:
|
||||
return error_response(_('User data processing is not '
|
||||
'supported yet'), code=400)
|
||||
|
||||
if not uuidutils.is_uuid_like(node_id):
|
||||
node = ir_utils.get_node(node_id, fields=['uuid'])
|
||||
node_id = node.uuid
|
||||
client = rpc.get_client()
|
||||
client.call({}, 'do_reapply', node_id=node_id)
|
||||
client.call({}, 'do_reapply', node_uuid=node_id)
|
||||
return '', 202
|
||||
|
||||
|
||||
|
|
|
@ -285,20 +285,20 @@ def _finish(node_info, ironic, introspection_data, power_off=True):
|
|||
node_info=node_info, data=introspection_data)
|
||||
|
||||
|
||||
def reapply(node_ident, data=None):
|
||||
def reapply(node_uuid, data=None):
|
||||
"""Re-apply introspection steps.
|
||||
|
||||
Re-apply preprocessing, postprocessing and introspection rules on
|
||||
stored data.
|
||||
|
||||
:param node_ident: node UUID or name
|
||||
:param node_uuid: node UUID
|
||||
:raises: utils.Error
|
||||
|
||||
"""
|
||||
|
||||
LOG.debug('Processing re-apply introspection request for node '
|
||||
'UUID: %s', node_ident)
|
||||
node_info = node_cache.get_node(node_ident, locked=False)
|
||||
'UUID: %s', node_uuid)
|
||||
node_info = node_cache.get_node(node_uuid, locked=False)
|
||||
if not node_info.acquire_lock(blocking=False):
|
||||
# Note (mkovacik): it should be sufficient to check data
|
||||
# presence & locking. If either introspection didn't start
|
||||
|
|
|
@ -370,7 +370,7 @@ class TestApiReapply(BaseAPITest):
|
|||
self.app.post('/v1/introspection/%s/data/unprocessed' %
|
||||
self.uuid)
|
||||
self.client_mock.call.assert_called_once_with({}, 'do_reapply',
|
||||
node_id=self.uuid)
|
||||
node_uuid=self.uuid)
|
||||
|
||||
def test_user_data(self):
|
||||
res = self.app.post('/v1/introspection/%s/data/unprocessed' %
|
||||
|
@ -392,7 +392,7 @@ class TestApiReapply(BaseAPITest):
|
|||
message = json.loads(res.data.decode())['error']['message']
|
||||
self.assertEqual(str(exc), message)
|
||||
self.client_mock.call.assert_called_once_with({}, 'do_reapply',
|
||||
node_id=self.uuid)
|
||||
node_uuid=self.uuid)
|
||||
|
||||
def test_generic_error(self):
|
||||
exc = utils.Error('Oops', code=400)
|
||||
|
@ -405,7 +405,16 @@ class TestApiReapply(BaseAPITest):
|
|||
message = json.loads(res.data.decode())['error']['message']
|
||||
self.assertEqual(str(exc), message)
|
||||
self.client_mock.call.assert_called_once_with({}, 'do_reapply',
|
||||
node_id=self.uuid)
|
||||
node_uuid=self.uuid)
|
||||
|
||||
@mock.patch.object(ir_utils, 'get_node', autospec=True)
|
||||
def test_reapply_with_node_name(self, get_mock):
|
||||
get_mock.return_value = mock.Mock(uuid=self.uuid)
|
||||
self.app.post('/v1/introspection/%s/data/unprocessed' %
|
||||
'fake-node')
|
||||
self.client_mock.call.assert_called_once_with({}, 'do_reapply',
|
||||
node_uuid=self.uuid)
|
||||
get_mock.assert_called_once_with('fake-node', fields=['uuid'])
|
||||
|
||||
|
||||
class TestApiRules(BaseAPITest):
|
||||
|
|
Loading…
Reference in New Issue