| 1 |
# |
| 2 |
# Copyright 2018 Red Hat Inc. |
| 3 |
# |
| 4 |
# Copyright (c) 2022 Dell Inc. or its subsidiaries. |
| 5 |
# |
| 6 |
# Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 7 |
# not use this file except in compliance with the License. You may obtain |
| 8 |
# a copy of the License at |
| 9 |
# |
| 10 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 11 |
# |
| 12 |
# Unless required by applicable law or agreed to in writing, software |
| 13 |
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 14 |
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 15 |
# License for the specific language governing permissions and limitations |
| 16 |
# under the License. |
| 17 |
|
| 18 |
from oslo_log import log as logging |
| 19 |
from tempest import config |
| 20 |
from tempest.lib import decorators |
| 21 |
|
| 22 |
from ironic_tempest_plugin.tests.scenario import \ |
| 23 |
baremetal_standalone_manager as bsm |
| 24 |
|
| 25 |
LOG = logging.getLogger(__name__) |
| 26 |
CONF = config.CONF |
| 27 |
|
| 28 |
|
| 29 |
class BaremetalFakeBios( |
| 30 |
bsm.BaremetalStandaloneScenarioTest): |
| 31 |
|
| 32 |
driver = 'fake-hardware' |
| 33 |
bios_interface = 'fake' |
| 34 |
deploy_interface = 'iscsi' |
| 35 |
image_ref = CONF.baremetal.whole_disk_image_ref |
| 36 |
wholedisk_image = True |
| 37 |
delete_node = False |
| 38 |
api_microversion = '1.40' |
| 39 |
|
| 40 |
@decorators.idempotent_id('ef55c44a-cc10-4cf6-8fda-85f0c0793150') |
| 41 |
def test_bios_apply_and_reset_configuration(self): |
| 42 |
settings = [ |
| 43 |
{ |
| 44 |
"name": "setting1_name", |
| 45 |
"value": "setting1_value" |
| 46 |
}, |
| 47 |
{ |
| 48 |
"name": "setting2_name", |
| 49 |
"value": "setting2_value" |
| 50 |
} |
| 51 |
] |
| 52 |
|
| 53 |
self.check_bios_apply_and_reset_configuration(self.node, settings) |
| 54 |
|
| 55 |
|
| 56 |
class BaremetalIdracBiosCleaning( |
| 57 |
bsm.BaremetalStandaloneScenarioTest): |
| 58 |
|
| 59 |
mandatory_attr = ['driver', 'bios_interface'] |
| 60 |
|
| 61 |
credentials = ['primary', 'admin'] |
| 62 |
driver = 'idrac' |
| 63 |
delete_node = False |
| 64 |
api_microversion = '1.40' |
| 65 |
|
| 66 |
def _get_bios_setting_to_update(self): |
| 67 |
_, bios_settings = self.baremetal_client.\ |
| 68 |
list_node_bios_settings(self.node['uuid']) |
| 69 |
|
| 70 |
for attr_name in bios_settings['bios']: |
| 71 |
if attr_name['name'] == "ProcVirtualization": |
| 72 |
if attr_name['value'] == 'Disabled': |
| 73 |
new_attr_value = "Enabled" |
| 74 |
else: |
| 75 |
new_attr_value = "Disabled" |
| 76 |
setting_to_update = [ |
| 77 |
{ |
| 78 |
"name": "ProcVirtualization", |
| 79 |
"value": new_attr_value |
| 80 |
} |
| 81 |
] |
| 82 |
|
| 83 |
return setting_to_update |
| 84 |
|
| 85 |
def _verify_bios_settings(self, bios_settings_to_verify): |
| 86 |
_, current_bios_settings = self.baremetal_client.\ |
| 87 |
list_node_bios_settings(self.node['uuid']) |
| 88 |
|
| 89 |
for setting in bios_settings_to_verify: |
| 90 |
found_setting = None |
| 91 |
for i in current_bios_settings['bios']: |
| 92 |
if i['name'] == setting['name']: |
| 93 |
found_setting = i |
| 94 |
break |
| 95 |
self.assertIsNotNone(found_setting) |
| 96 |
self.assertEqual(setting['value'], found_setting['value']) |
| 97 |
|
| 98 |
@decorators.idempotent_id('6ded82ab-b444-436b-bb78-06fa5957d6c3') |
| 99 |
def test_bios_apply_configuration(self): |
| 100 |
setting = self._get_bios_setting_to_update() |
| 101 |
clean_steps = [ |
| 102 |
{ |
| 103 |
"interface": "bios", |
| 104 |
"step": "apply_configuration", |
| 105 |
"args": {"settings": setting} |
| 106 |
} |
| 107 |
] |
| 108 |
|
| 109 |
self.manual_cleaning(self.node, clean_steps=clean_steps) |
| 110 |
self._verify_bios_settings(setting) |
| 111 |
|
| 112 |
restore_setting = self._get_bios_setting_to_update() |
| 113 |
clean_steps_restore = [ |
| 114 |
{ |
| 115 |
"interface": "bios", |
| 116 |
"step": "apply_configuration", |
| 117 |
"args": {"settings": restore_setting} |
| 118 |
} |
| 119 |
] |
| 120 |
|
| 121 |
self.manual_cleaning(self.node, clean_steps=clean_steps_restore) |
| 122 |
self._verify_bios_settings(restore_setting) |
| 123 |
|
| 124 |
|
| 125 |
class BaremetalIdracRedfishBios( |
| 126 |
BaremetalIdracBiosCleaning): |
| 127 |
bios_interface = 'idrac-redfish' |