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 = {}
|
||||
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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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…
Reference in New Issue
Block a user