diff --git a/releasenotes/notes/add-target-host-filter-94803e93b701d052.yaml b/releasenotes/notes/add-target-host-filter-94803e93b701d052.yaml new file mode 100644 index 0000000000..83a3728a40 --- /dev/null +++ b/releasenotes/notes/add-target-host-filter-94803e93b701d052.yaml @@ -0,0 +1,6 @@ +--- +features: + - | + Add a new config option `[compute]/target_hosts_to_avoid` which will + filter out any hypervisor candidates with a hostname that matches the + provided pattern when determining target hosts for migration. diff --git a/tempest/api/compute/admin/test_hosts.py b/tempest/api/compute/admin/test_hosts.py index 0d79570e9c..849b53542a 100644 --- a/tempest/api/compute/admin/test_hosts.py +++ b/tempest/api/compute/admin/test_hosts.py @@ -14,8 +14,11 @@ from tempest.api.compute import base from tempest.common import tempest_fixtures as fixtures +from tempest import config from tempest.lib import decorators +CONF = config.CONF + class HostsAdminTestJSON(base.BaseV2ComputeAdminTest): """Tests nova hosts API using admin privileges.""" @@ -70,7 +73,7 @@ class HostsAdminTestJSON(base.BaseV2ComputeAdminTest): hosts = [host for host in hosts if ( host['service'] == 'compute' and - not host['host_name'].endswith('-ironic'))] + CONF.compute.target_hosts_to_avoid not in host['host_name'])] self.assertNotEmpty(hosts) for host in hosts: diff --git a/tempest/api/compute/base.py b/tempest/api/compute/base.py index 889010991e..1069e0f395 100644 --- a/tempest/api/compute/base.py +++ b/tempest/api/compute/base.py @@ -720,7 +720,7 @@ class BaseV2ComputeAdminTest(BaseV2ComputeTest): binary='nova-compute')['services'] hosts = [] for svc in svcs: - if svc['host'].endswith('-ironic'): + if CONF.compute.target_hosts_to_avoid in svc['host']: continue if svc['state'] == 'up' and svc['status'] == 'enabled': if CONF.compute.compute_volume_common_az: diff --git a/tempest/config.py b/tempest/config.py index 0fcc71c6e7..9d7526afdd 100644 --- a/tempest/config.py +++ b/tempest/config.py @@ -418,7 +418,11 @@ ComputeGroup = [ help="Specify destination host for live-migration and cold" " migration. If option is not set tests will use host" " automatically."), - + cfg.StrOpt('target_hosts_to_avoid', + default='-ironic', + help="When aggregating available hypervisors for testing," + " avoid migrating to and booting any test VM on hosts with" + " a name that matches the provided pattern"), ] placement_group = cfg.OptGroup(name='placement', diff --git a/tempest/scenario/test_instances_with_cinder_volumes.py b/tempest/scenario/test_instances_with_cinder_volumes.py index b9ac2c8c3a..0ddbec187e 100644 --- a/tempest/scenario/test_instances_with_cinder_volumes.py +++ b/tempest/scenario/test_instances_with_cinder_volumes.py @@ -80,7 +80,7 @@ class TestInstancesWithCinderVolumes(manager.ScenarioTest): for host in zone['hosts']: if 'nova-compute' in zone['hosts'][host] and \ zone['hosts'][host]['nova-compute']['available'] and \ - not host.endswith('-ironic'): + CONF.compute.target_hosts_to_avoid not in host: hosts.append({'zone': zone['zoneName'], 'host_name': host}) diff --git a/tempest/scenario/test_server_multinode.py b/tempest/scenario/test_server_multinode.py index fe85234466..556b9251c7 100644 --- a/tempest/scenario/test_server_multinode.py +++ b/tempest/scenario/test_server_multinode.py @@ -48,7 +48,7 @@ class TestServerMultinode(manager.ScenarioTest): for host in zone['hosts']: if 'nova-compute' in zone['hosts'][host] and \ zone['hosts'][host]['nova-compute']['available'] and \ - not host.endswith('-ironic'): + CONF.compute.target_hosts_to_avoid not in host: hosts.append({'zone': zone['zoneName'], 'host_name': host})