diff --git a/ironic_inspector/plugins/extra_hardware.py b/ironic_inspector/plugins/extra_hardware.py index e9fa6d955..9a65dfc5d 100644 --- a/ironic_inspector/plugins/extra_hardware.py +++ b/ironic_inspector/plugins/extra_hardware.py @@ -96,7 +96,7 @@ class ExtraHardwareHook(base.ProcessingHook): try: item[3] = int(item[3]) - except ValueError: + except (ValueError, TypeError): pass converted_1[item[2]] = item[3] diff --git a/ironic_inspector/test/test_plugins_extra_hardware.py b/ironic_inspector/test/test_plugins_extra_hardware.py index 84c44371b..54fcf2f2b 100644 --- a/ironic_inspector/test/test_plugins_extra_hardware.py +++ b/ironic_inspector/test/test_plugins_extra_hardware.py @@ -84,3 +84,14 @@ class TestExtraHardware(test_base.NodeTest): self.hook.before_update(introspection_data, self.node_info) self.assertFalse(patch_mock.called) self.assertFalse(swift_conn.create_object.called) + + def test__convert_edeploy_data(self, patch_mock, swift_mock): + introspection_data = [['Sheldon', 'J.', 'Plankton', '123'], + ['Larry', 'the', 'Lobster', None], + ['Eugene', 'H.', 'Krabs', 'The cashier']] + + data = self.hook._convert_edeploy_data(introspection_data) + expected_data = {'Sheldon': {'J.': {'Plankton': 123}}, + 'Larry': {'the': {'Lobster': None}}, + 'Eugene': {'H.': {'Krabs': 'The cashier'}}} + self.assertEqual(expected_data, data) diff --git a/releasenotes/notes/edeploy-typeerror-6486e31923d91666.yaml b/releasenotes/notes/edeploy-typeerror-6486e31923d91666.yaml new file mode 100644 index 000000000..f51af3180 --- /dev/null +++ b/releasenotes/notes/edeploy-typeerror-6486e31923d91666.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - Fixes a problem which caused an unhandled TypeError exception to + bubble up when inspector was attempting to convert some eDeploy data + to integer.