From 6d6cf18f3171f42af1567c65240a7a6a759377c2 Mon Sep 17 00:00:00 2001 From: Richard Pioso Date: Fri, 28 Oct 2016 20:11:18 -0400 Subject: [PATCH] DRAC get_bios_config() passthru causes exception The DRAC driver's (pxe_drac) get_bios_config() vendor passthru method raises an AttributeError exception. It no longer returns the current BIOS configuration. This is a regression from stable/mitaka. Triage found that get_bios_config() mistakenly treats the value returned by python-dracclient's list_bios_settings() as containing named tuples. When it calls the namedtuple _asdict() method, an AttributeError exception is raised. Revert get_bios_config()'s handling of the return value to use __dict__. Remove the comment that is not consistent with the implementation. Also revert the unit test case for a successful call to use mock to create the return value. Use mock.NonCallableMock with an empty specification (spec) to catch this type of bug in the future. Change-Id: I94afaa72a1ef25efc1b622e29e3a92a5d27f1892 Closes-Bug: #1637671 --- ironic/drivers/modules/drac/vendor_passthru.py | 4 +--- ironic/tests/unit/drivers/modules/drac/test_bios.py | 11 ++++------- ...or-passthru-causes-exception-1e1dbeeb3e924f29.yaml | 7 +++++++ 3 files changed, 12 insertions(+), 10 deletions(-) create mode 100644 releasenotes/notes/drac-fix-get_bios_config-vendor-passthru-causes-exception-1e1dbeeb3e924f29.yaml diff --git a/ironic/drivers/modules/drac/vendor_passthru.py b/ironic/drivers/modules/drac/vendor_passthru.py index 07b08135ed..be45ef61ca 100644 --- a/ironic/drivers/modules/drac/vendor_passthru.py +++ b/ironic/drivers/modules/drac/vendor_passthru.py @@ -65,9 +65,7 @@ class DracVendorPassthru(base.VendorInterface): """ bios_attrs = {} for name, bios_attr in drac_bios.get_config(task.node).items(): - # NOTE(ifarkas): call from python-dracclient returns list of - # namedtuples, converting it to dict here. - bios_attrs[name] = bios_attr._asdict() + bios_attrs[name] = bios_attr.__dict__ return bios_attrs diff --git a/ironic/tests/unit/drivers/modules/drac/test_bios.py b/ironic/tests/unit/drivers/modules/drac/test_bios.py index 6561e3c35c..b9933ce089 100644 --- a/ironic/tests/unit/drivers/modules/drac/test_bios.py +++ b/ironic/tests/unit/drivers/modules/drac/test_bios.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright 2015 Dell, Inc. +# Copyright (c) 2015-2016 Dell Inc. or its subsidiaries. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may @@ -28,7 +28,6 @@ from ironic.drivers.modules.drac import common as drac_common from ironic.tests.unit.conductor import mgr_utils from ironic.tests.unit.db import base as db_base from ironic.tests.unit.db import utils as db_utils -from ironic.tests.unit.drivers.modules.drac import utils as test_utils from ironic.tests.unit.objects import utils as obj_utils INFO_DICT = db_utils.get_test_drac_info() @@ -51,15 +50,13 @@ class DracBIOSConfigurationTestCase(db_base.DbTestCase): self.addCleanup(patch_get_drac_client.stop) proc_virt_attr = { - 'name': 'ProcVirtualization', 'current_value': 'Enabled', 'pending_value': None, 'read_only': False, 'possible_values': ['Enabled', 'Disabled']} - self.bios_attrs = { - 'ProcVirtualization': test_utils.dict_to_namedtuple( - values=proc_virt_attr) - } + mock_proc_virt_attr = mock.NonCallableMock(spec=[], **proc_virt_attr) + mock_proc_virt_attr.name = 'ProcVirtualization' + self.bios_attrs = {'ProcVirtualization': mock_proc_virt_attr} def test_get_config(self): self.mock_client.list_bios_settings.return_value = self.bios_attrs diff --git a/releasenotes/notes/drac-fix-get_bios_config-vendor-passthru-causes-exception-1e1dbeeb3e924f29.yaml b/releasenotes/notes/drac-fix-get_bios_config-vendor-passthru-causes-exception-1e1dbeeb3e924f29.yaml new file mode 100644 index 0000000000..f57b556f88 --- /dev/null +++ b/releasenotes/notes/drac-fix-get_bios_config-vendor-passthru-causes-exception-1e1dbeeb3e924f29.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - Fixes an issue which caused the DRAC driver (``pxe_drac``) + ``get_bios_config()`` vendor passthru method to unintentionally raise an + ``AttributeError`` exception. That method once again returns the current + BIOS configuration. For more information, see + https://bugs.launchpad.net/ironic/+bug/1637671.