summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Pioso <richard.pioso@dell.com>2016-10-28 20:11:18 -0400
committerRichard Pioso <richard.pioso@dell.com>2016-10-31 15:00:32 -0400
commit6d6cf18f3171f42af1567c65240a7a6a759377c2 (patch)
treec3663ea28f6ee1ff108d8e147f1ae3aa8f544b06
parentf750bcd52124951db1beac95a00572c0548a01a6 (diff)
downloadironic-6d6cf18f3171f42af1567c65240a7a6a759377c2.tar.gz
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
-rw-r--r--ironic/drivers/modules/drac/vendor_passthru.py4
-rw-r--r--ironic/tests/unit/drivers/modules/drac/test_bios.py11
-rw-r--r--releasenotes/notes/drac-fix-get_bios_config-vendor-passthru-causes-exception-1e1dbeeb3e924f29.yaml7
3 files changed, 12 insertions, 10 deletions
diff --git a/ironic/drivers/modules/drac/vendor_passthru.py b/ironic/drivers/modules/drac/vendor_passthru.py
index 07b08135e..be45ef61c 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 6561e3c35..b9933ce08 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 000000000..f57b556f8
--- /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.