aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--functest/core/singlevm.py8
-rw-r--r--functest/opnfv_tests/openstack/rally/rally.py2
-rw-r--r--functest/opnfv_tests/openstack/shaker/shaker.py2
-rw-r--r--functest/opnfv_tests/openstack/tempest/tempest.py3
-rw-r--r--functest/opnfv_tests/openstack/vmtp/vmtp.py2
-rw-r--r--functest/tests/unit/openstack/rally/test_rally.py4
6 files changed, 14 insertions, 7 deletions
diff --git a/functest/core/singlevm.py b/functest/core/singlevm.py
index 0473a21da..734eb22d5 100644
--- a/functest/core/singlevm.py
+++ b/functest/core/singlevm.py
@@ -256,6 +256,14 @@ class VmReady1(tenantnetwork.TenantNetwork1):
self.__logger.debug(
"Orphan security group %s in use", sec_group.id)
+ def count_active_hypervisors(self):
+ """Count all hypervisors which are up."""
+ compute_cnt = 0
+ for hypervisor in self.orig_cloud.list_hypervisors():
+ if hypervisor['state'] == 'up':
+ compute_cnt += 1
+ return compute_cnt
+
def run(self, **kwargs):
"""Boot the new VM
diff --git a/functest/opnfv_tests/openstack/rally/rally.py b/functest/opnfv_tests/openstack/rally/rally.py
index d9fb1fb5c..95447c08d 100644
--- a/functest/opnfv_tests/openstack/rally/rally.py
+++ b/functest/opnfv_tests/openstack/rally/rally.py
@@ -517,7 +517,7 @@ class RallyBase(singlevm.VmReady2):
shutil.copytree(task_macro, macro_dir)
self.update_keystone_default_role()
- self.compute_cnt = len(self.cloud.list_hypervisors())
+ self.compute_cnt = self.count_active_hypervisors()
self.network_extensions = self.cloud.get_network_extensions()
self.flavor_alt = self.create_flavor_alt()
self.services = [service.name for service in
diff --git a/functest/opnfv_tests/openstack/shaker/shaker.py b/functest/opnfv_tests/openstack/shaker/shaker.py
index 46a44c775..9a31a8b19 100644
--- a/functest/opnfv_tests/openstack/shaker/shaker.py
+++ b/functest/opnfv_tests/openstack/shaker/shaker.py
@@ -48,7 +48,7 @@ class Shaker(singlevm.SingleVm2):
self.role = None
def check_requirements(self):
- if len(self.orig_cloud.list_hypervisors()) < 2:
+ if self.count_active_hypervisors() < 2:
self.__logger.warning("Shaker requires at least 2 hypervisors")
self.is_skipped = True
self.project.clean()
diff --git a/functest/opnfv_tests/openstack/tempest/tempest.py b/functest/opnfv_tests/openstack/tempest/tempest.py
index a6ec568a0..6d13bd206 100644
--- a/functest/opnfv_tests/openstack/tempest/tempest.py
+++ b/functest/opnfv_tests/openstack/tempest/tempest.py
@@ -567,8 +567,7 @@ class TempestCommon(singlevm.VmReady2):
self.deployment_dir = self.get_verifier_deployment_dir(
self.verifier_id, self.deployment_id)
- compute_cnt = len(self.orig_cloud.list_hypervisors())
-
+ compute_cnt = self.count_active_hypervisors()
self.image_alt = self.publish_image_alt()
self.flavor_alt = self.create_flavor_alt()
LOGGER.debug("flavor: %s", self.flavor_alt)
diff --git a/functest/opnfv_tests/openstack/vmtp/vmtp.py b/functest/opnfv_tests/openstack/vmtp/vmtp.py
index d102f6440..fa83c4522 100644
--- a/functest/opnfv_tests/openstack/vmtp/vmtp.py
+++ b/functest/opnfv_tests/openstack/vmtp/vmtp.py
@@ -60,7 +60,7 @@ class Vmtp(singlevm.VmReady2):
(_, self.pubkey_filename) = tempfile.mkstemp()
def check_requirements(self):
- if len(self.orig_cloud.list_hypervisors()) < 2:
+ if self.count_active_hypervisors() < 2:
self.__logger.warning("Vmtp requires at least 2 hypervisors")
self.is_skipped = True
self.project.clean()
diff --git a/functest/tests/unit/openstack/rally/test_rally.py b/functest/tests/unit/openstack/rally/test_rally.py
index c5cd5019e..c430e9794 100644
--- a/functest/tests/unit/openstack/rally/test_rally.py
+++ b/functest/tests/unit/openstack/rally/test_rally.py
@@ -291,8 +291,8 @@ class OSRallyTesting(unittest.TestCase):
def test_prepare_run_flavor_alt_creation_failed(self, *args):
# pylint: disable=unused-argument
self.rally_base.stests = ['test1', 'test2']
- with mock.patch.object(self.rally_base.cloud,
- 'list_hypervisors') as mock_list_hyperv, \
+ with mock.patch.object(self.rally_base, 'count_active_hypervisors') \
+ as mock_list_hyperv, \
mock.patch.object(self.rally_base, 'create_flavor_alt',
side_effect=Exception) \
as mock_create_flavor: