| 1 |
# |
| 2 |
# Copyright 2017 Mirantis Inc. |
| 3 |
# |
| 4 |
# Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 5 |
# not use this file except in compliance with the License. You may obtain |
| 6 |
# a copy of the License at |
| 7 |
# |
| 8 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 |
# |
| 10 |
# Unless required by applicable law or agreed to in writing, software |
| 11 |
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 12 |
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 13 |
# License for the specific language governing permissions and limitations |
| 14 |
# under the License. |
| 15 |
|
| 16 |
from oslo_log import log as logging |
| 17 |
from tempest.common import utils |
| 18 |
from tempest import config |
| 19 |
from tempest.lib import decorators |
| 20 |
|
| 21 |
from ironic_tempest_plugin.tests.scenario import \ |
| 22 |
baremetal_standalone_manager as bsm |
| 23 |
|
| 24 |
LOG = logging.getLogger(__name__) |
| 25 |
CONF = config.CONF |
| 26 |
|
| 27 |
|
| 28 |
class BaremetalAdoptionDriverWholedisk( |
| 29 |
bsm.BaremetalStandaloneScenarioTest): |
| 30 |
|
| 31 |
if 'redfish' in CONF.baremetal.enabled_hardware_types: |
| 32 |
driver = 'redfish' |
| 33 |
else: |
| 34 |
driver = 'ipmi' |
| 35 |
image_ref = CONF.baremetal.whole_disk_image_ref |
| 36 |
wholedisk_image = True |
| 37 |
deploy_interface = 'direct' |
| 38 |
# 1.37 is required to be able to copy traits |
| 39 |
api_microversion = '1.37' |
| 40 |
|
| 41 |
@classmethod |
| 42 |
def skip_checks(cls): |
| 43 |
super(BaremetalAdoptionDriverWholedisk, cls).skip_checks() |
| 44 |
if cls.driver == 'ipmi': |
| 45 |
skip_msg = ("Adoption feature is covered by redfish driver") |
| 46 |
raise cls.skipException(skip_msg) |
| 47 |
if not CONF.baremetal_feature_enabled.adoption: |
| 48 |
skip_msg = ("Adoption feature is not enabled") |
| 49 |
raise cls.skipException(skip_msg) |
| 50 |
|
| 51 |
@classmethod |
| 52 |
def recreate_node(cls): |
| 53 |
# Now record all up-to-date node information for creation |
| 54 |
cls.node = cls.get_node(cls.node['uuid']) |
| 55 |
body = {'driver_info': cls.node['driver_info'], |
| 56 |
'instance_info': cls.node['instance_info'], |
| 57 |
'driver': cls.node['driver'], |
| 58 |
'properties': cls.node['properties']} |
| 59 |
if set(body['driver_info'].get('redfish_password')) == {'*'}: |
| 60 |
# A hack to enable devstack testing without showing secrets |
| 61 |
# secrets. Use the hardcoded devstack value. |
| 62 |
body['driver_info']['redfish_password'] = 'password' |
| 63 |
# configdrive is hidden and anyway should be supplied on rebuild |
| 64 |
body['instance_info'].pop('configdrive', None) |
| 65 |
for key, value in cls.node.items(): |
| 66 |
if key.endswith('_interface') and value: |
| 67 |
body[key] = value |
| 68 |
traits = cls.node['traits'] |
| 69 |
_, vifs = cls.baremetal_client.vif_list(cls.node['uuid']) |
| 70 |
_, ports = cls.baremetal_client.list_ports(node=cls.node['uuid']) |
| 71 |
|
| 72 |
# Delete the active node using maintenance |
| 73 |
cls.update_node(cls.node['uuid'], [{'op': 'replace', |
| 74 |
'path': '/maintenance', |
| 75 |
'value': True}]) |
| 76 |
cls.baremetal_client.delete_node(cls.node['uuid']) |
| 77 |
|
| 78 |
# Now create an identical node and attach VIFs |
| 79 |
_, cls.node = cls.baremetal_client.create_node_raw(**body) |
| 80 |
if traits: |
| 81 |
cls.baremetal_client.set_node_traits(cls.node['uuid'], traits) |
| 82 |
for port in ports['ports']: |
| 83 |
cls.baremetal_client.create_port(cls.node['uuid'], |
| 84 |
address=port['address']) |
| 85 |
|
| 86 |
cls.set_node_provision_state(cls.node['uuid'], 'manage') |
| 87 |
cls.wait_provisioning_state(cls.node['uuid'], 'manageable', |
| 88 |
timeout=300, interval=5) |
| 89 |
|
| 90 |
for vif in vifs['vifs']: |
| 91 |
cls.vif_attach(cls.node['uuid'], vif['id']) |
| 92 |
|
| 93 |
return cls.node |
| 94 |
|
| 95 |
@decorators.idempotent_id('2f51890e-20d9-43ef-af39-41b335ec066b') |
| 96 |
@utils.services('image', 'network') |
| 97 |
def test_adoption(self): |
| 98 |
# First, prepare a deployed node. |
| 99 |
self.boot_node() |
| 100 |
|
| 101 |
# Then re-create it with the same parameters. |
| 102 |
self.recreate_node() |
| 103 |
|
| 104 |
# Now adoption! |
| 105 |
self.set_node_provision_state(self.node['uuid'], 'adopt') |
| 106 |
self.wait_provisioning_state(self.node['uuid'], 'active', |
| 107 |
timeout=300, interval=5) |
| 108 |
|
| 109 |
# Try to rebuild the server to make sure we can manage it now. |
| 110 |
self.set_node_provision_state(self.node['uuid'], 'rebuild') |
| 111 |
self.wait_provisioning_state(self.node['uuid'], 'active', |
| 112 |
timeout=CONF.baremetal.active_timeout, |
| 113 |
interval=30) |