Merge "Fix 'introspection bulk status' when some nodes were never introspected" into stable/newton

This commit is contained in:
Jenkins 2017-06-06 12:33:56 +00:00 committed by Gerrit Code Review
commit 15a4ca43a9
4 changed files with 42 additions and 3 deletions

View File

@ -0,0 +1,6 @@
---
fixes:
- |
The ``introspection bulk status`` command no longer aborts if some nodes
in the Ironic registry were never introspected. See bug `1689540
<https://bugs.launchpad.net/tripleo/+bug/1689540>`_.

View File

@ -79,7 +79,10 @@ class FakeInspectorClient(object):
self.on_introspection.append(uuid)
def get_status(self, uuid):
return self.states[uuid]
try:
return self.states[uuid]
except KeyError:
raise ironic_inspector_client.ClientError(mock.Mock())
def get_data(self, uuid):
try:

View File

@ -739,6 +739,27 @@ class TestStatusBaremetalIntrospectionBulk(fakes.TestBaremetal):
]
))
def test_missing_nodes(self):
client = self.app.client_manager.baremetal
client.node.list.return_value = [
mock.Mock(uuid="ABCDEFGH"),
mock.Mock(uuid="IJKLMNOP"),
mock.Mock(uuid="QRSTUVWX"),
]
inspector_client = self.app.client_manager.baremetal_introspection
inspector_client.states['IJKLMNOP'] = {'finished': False,
'error': None}
parsed_args = self.check_parser(self.cmd, [], [])
result = self.cmd.take_action(parsed_args)
self.assertEqual(result, (
('Node UUID', 'Finished', 'Error'),
[
('IJKLMNOP', False, None),
]
))
class TestConfigureReadyState(fakes.TestBaremetal):

View File

@ -21,6 +21,7 @@ import logging
import time
import uuid
import ironic_inspector_client
from osc_lib.command import command
from osc_lib.i18n import _
@ -251,8 +252,16 @@ class StatusBaremetalIntrospectionBulk(command.Lister):
self.log.debug("Getting introspection status of Ironic node {0}"
.format(node.uuid))
statuses.append((node.uuid,
inspector_client.get_status(node.uuid)))
try:
status = inspector_client.get_status(node.uuid)
except ironic_inspector_client.ClientError as exc:
# This API returns an error when the node was never
# introspected before. Exclude it from output in this case.
self.log.debug('Introspection status for node %(node)s '
'returned error %(exc)s',
{'node': node.uuid, 'exc': exc})
else:
statuses.append((node.uuid, status))
return (
("Node UUID", "Finished", "Error"),