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
This commit is contained in:
parent
f750bcd521
commit
6d6cf18f31
@ -65,9 +65,7 @@ class DracVendorPassthru(base.VendorInterface):
|
|||||||
"""
|
"""
|
||||||
bios_attrs = {}
|
bios_attrs = {}
|
||||||
for name, bios_attr in drac_bios.get_config(task.node).items():
|
for name, bios_attr in drac_bios.get_config(task.node).items():
|
||||||
# NOTE(ifarkas): call from python-dracclient returns list of
|
bios_attrs[name] = bios_attr.__dict__
|
||||||
# namedtuples, converting it to dict here.
|
|
||||||
bios_attrs[name] = bios_attr._asdict()
|
|
||||||
|
|
||||||
return bios_attrs
|
return bios_attrs
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
# Copyright 2015 Dell, Inc.
|
# Copyright (c) 2015-2016 Dell Inc. or its subsidiaries.
|
||||||
# All Rights Reserved.
|
# All Rights Reserved.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
# 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.conductor import mgr_utils
|
||||||
from ironic.tests.unit.db import base as db_base
|
from ironic.tests.unit.db import base as db_base
|
||||||
from ironic.tests.unit.db import utils as db_utils
|
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
|
from ironic.tests.unit.objects import utils as obj_utils
|
||||||
|
|
||||||
INFO_DICT = db_utils.get_test_drac_info()
|
INFO_DICT = db_utils.get_test_drac_info()
|
||||||
@ -51,15 +50,13 @@ class DracBIOSConfigurationTestCase(db_base.DbTestCase):
|
|||||||
self.addCleanup(patch_get_drac_client.stop)
|
self.addCleanup(patch_get_drac_client.stop)
|
||||||
|
|
||||||
proc_virt_attr = {
|
proc_virt_attr = {
|
||||||
'name': 'ProcVirtualization',
|
|
||||||
'current_value': 'Enabled',
|
'current_value': 'Enabled',
|
||||||
'pending_value': None,
|
'pending_value': None,
|
||||||
'read_only': False,
|
'read_only': False,
|
||||||
'possible_values': ['Enabled', 'Disabled']}
|
'possible_values': ['Enabled', 'Disabled']}
|
||||||
self.bios_attrs = {
|
mock_proc_virt_attr = mock.NonCallableMock(spec=[], **proc_virt_attr)
|
||||||
'ProcVirtualization': test_utils.dict_to_namedtuple(
|
mock_proc_virt_attr.name = 'ProcVirtualization'
|
||||||
values=proc_virt_attr)
|
self.bios_attrs = {'ProcVirtualization': mock_proc_virt_attr}
|
||||||
}
|
|
||||||
|
|
||||||
def test_get_config(self):
|
def test_get_config(self):
|
||||||
self.mock_client.list_bios_settings.return_value = self.bios_attrs
|
self.mock_client.list_bios_settings.return_value = self.bios_attrs
|
||||||
|
@ -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.
|
Loading…
x
Reference in New Issue
Block a user