summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-06-06 12:33:56 +0000
committerGerrit Code Review <review@openstack.org>2017-06-06 12:33:56 +0000
commit15a4ca43a9a2f6231ce4307ecdc11e4a97dd9dcb (patch)
tree255b5bff195c5af01fbb74e0ada4ce894930ec09
parent1bd1acd32c9537f74ccfe7a501745aa96fd1f83a (diff)
parent03abd22cba170a569ed50e1ff25c127b5a479d20 (diff)
Merge "Fix 'introspection bulk status' when some nodes were never introspected" into stable/newton
-rw-r--r--releasenotes/notes/bulk-status-missing-50cc60281c6e20f5.yaml6
-rw-r--r--tripleoclient/tests/v1/baremetal/fakes.py5
-rw-r--r--tripleoclient/tests/v1/baremetal/test_baremetal.py21
-rw-r--r--tripleoclient/v1/baremetal.py13
4 files changed, 42 insertions, 3 deletions
diff --git a/releasenotes/notes/bulk-status-missing-50cc60281c6e20f5.yaml b/releasenotes/notes/bulk-status-missing-50cc60281c6e20f5.yaml
new file mode 100644
index 0000000..84565f1
--- /dev/null
+++ b/releasenotes/notes/bulk-status-missing-50cc60281c6e20f5.yaml
@@ -0,0 +1,6 @@
1---
2fixes:
3 - |
4 The ``introspection bulk status`` command no longer aborts if some nodes
5 in the Ironic registry were never introspected. See bug `1689540
6 <https://bugs.launchpad.net/tripleo/+bug/1689540>`_.
diff --git a/tripleoclient/tests/v1/baremetal/fakes.py b/tripleoclient/tests/v1/baremetal/fakes.py
index f9d8bdb..57fdde1 100644
--- a/tripleoclient/tests/v1/baremetal/fakes.py
+++ b/tripleoclient/tests/v1/baremetal/fakes.py
@@ -79,7 +79,10 @@ class FakeInspectorClient(object):
79 self.on_introspection.append(uuid) 79 self.on_introspection.append(uuid)
80 80
81 def get_status(self, uuid): 81 def get_status(self, uuid):
82 return self.states[uuid] 82 try:
83 return self.states[uuid]
84 except KeyError:
85 raise ironic_inspector_client.ClientError(mock.Mock())
83 86
84 def get_data(self, uuid): 87 def get_data(self, uuid):
85 try: 88 try:
diff --git a/tripleoclient/tests/v1/baremetal/test_baremetal.py b/tripleoclient/tests/v1/baremetal/test_baremetal.py
index aaf84e3..df2738d 100644
--- a/tripleoclient/tests/v1/baremetal/test_baremetal.py
+++ b/tripleoclient/tests/v1/baremetal/test_baremetal.py
@@ -739,6 +739,27 @@ class TestStatusBaremetalIntrospectionBulk(fakes.TestBaremetal):
739 ] 739 ]
740 )) 740 ))
741 741
742 def test_missing_nodes(self):
743 client = self.app.client_manager.baremetal
744 client.node.list.return_value = [
745 mock.Mock(uuid="ABCDEFGH"),
746 mock.Mock(uuid="IJKLMNOP"),
747 mock.Mock(uuid="QRSTUVWX"),
748 ]
749 inspector_client = self.app.client_manager.baremetal_introspection
750 inspector_client.states['IJKLMNOP'] = {'finished': False,
751 'error': None}
752
753 parsed_args = self.check_parser(self.cmd, [], [])
754 result = self.cmd.take_action(parsed_args)
755
756 self.assertEqual(result, (
757 ('Node UUID', 'Finished', 'Error'),
758 [
759 ('IJKLMNOP', False, None),
760 ]
761 ))
762
742 763
743class TestConfigureReadyState(fakes.TestBaremetal): 764class TestConfigureReadyState(fakes.TestBaremetal):
744 765
diff --git a/tripleoclient/v1/baremetal.py b/tripleoclient/v1/baremetal.py
index fb90f69..ef321ec 100644
--- a/tripleoclient/v1/baremetal.py
+++ b/tripleoclient/v1/baremetal.py
@@ -21,6 +21,7 @@ import logging
21import time 21import time
22import uuid 22import uuid
23 23
24import ironic_inspector_client
24from osc_lib.command import command 25from osc_lib.command import command
25from osc_lib.i18n import _ 26from osc_lib.i18n import _
26 27
@@ -251,8 +252,16 @@ class StatusBaremetalIntrospectionBulk(command.Lister):
251 self.log.debug("Getting introspection status of Ironic node {0}" 252 self.log.debug("Getting introspection status of Ironic node {0}"
252 .format(node.uuid)) 253 .format(node.uuid))
253 254
254 statuses.append((node.uuid, 255 try:
255 inspector_client.get_status(node.uuid))) 256 status = inspector_client.get_status(node.uuid)
257 except ironic_inspector_client.ClientError as exc:
258 # This API returns an error when the node was never
259 # introspected before. Exclude it from output in this case.
260 self.log.debug('Introspection status for node %(node)s '
261 'returned error %(exc)s',
262 {'node': node.uuid, 'exc': exc})
263 else:
264 statuses.append((node.uuid, status))
256 265
257 return ( 266 return (
258 ("Node UUID", "Finished", "Error"), 267 ("Node UUID", "Finished", "Error"),