Added utility function to retrieve the names of all hosts with a hypervisor.
[snaps.git] / snaps / openstack / utils / tests / nova_utils_tests.py
index 0c313b9..c7be5ef 100644 (file)
@@ -20,13 +20,15 @@ import os
 
 from snaps import file_utils
 from snaps.config.flavor import FlavorConfig
+from snaps.config.network import PortConfig
+from snaps.config.vm_inst import VmInstanceConfig
+from snaps.config.volume import VolumeConfig
 from snaps.openstack import create_instance
 from snaps.openstack.create_flavor import OpenStackFlavor
 from snaps.openstack.create_image import OpenStackImage
-from snaps.openstack.create_instance import (
-    VmInstanceSettings, OpenStackVmInstance)
-from snaps.openstack.create_network import OpenStackNetwork, PortSettings
-from snaps.openstack.create_volume import OpenStackVolume, VolumeSettings
+from snaps.openstack.create_instance import OpenStackVmInstance
+from snaps.openstack.create_network import OpenStackNetwork
+from snaps.openstack.create_volume import OpenStackVolume
 from snaps.openstack.tests import openstack_tests
 from snaps.openstack.tests.os_source_file_test import OSComponentTestCase
 from snaps.openstack.utils import (
@@ -51,6 +53,16 @@ class NovaSmokeTests(OSComponentTestCase):
         # This should not throw an exception
         nova.flavors.list()
 
+    def test_nova_get_hypervisor_hosts(self):
+        """
+        Tests to ensure that get_hypervisors() function works.
+        """
+        nova = nova_utils.nova_client(self.os_creds)
+
+        hosts = nova_utils.get_hypervisor_hosts(nova)
+        # This should not throw an exception
+        self.assertGreaterEqual(len(hosts), 1)
+
     def test_nova_connect_fail(self):
         """
         Tests to ensure that the improper credentials cannot connect.
@@ -258,12 +270,12 @@ class NovaUtilsInstanceTests(OSComponentTestCase):
                     name=guid + '-flavor-name', ram=256, disk=10, vcpus=1))
             self.flavor_creator.create()
 
-            port_settings = PortSettings(name=guid + '-port',
-                                         network_name=network_settings.name)
+            port_settings = PortConfig(
+                name=guid + '-port', network_name=network_settings.name)
             self.port = neutron_utils.create_port(
                 self.neutron, self.os_creds, port_settings)
 
-            self.instance_settings = VmInstanceSettings(
+            self.instance_settings = VmInstanceConfig(
                 name=guid + '-vm_inst',
                 flavor=self.flavor_creator.flavor_settings.name,
                 port_settings=[port_settings])
@@ -375,15 +387,15 @@ class NovaUtilsInstanceVolumeTests(OSComponentTestCase):
             self.flavor_creator.create()
 
             # Create Volume
-            volume_settings = VolumeSettings(
+            volume_settings = VolumeConfig(
                 name=self.__class__.__name__ + '-' + str(guid))
             self.volume_creator = OpenStackVolume(
                 self.os_creds, volume_settings)
             self.volume_creator.create(block=True)
 
-            port_settings = PortSettings(
+            port_settings = PortConfig(
                 name=guid + '-port', network_name=network_settings.name)
-            instance_settings = VmInstanceSettings(
+            instance_settings = VmInstanceConfig(
                 name=guid + '-vm_inst',
                 flavor=self.flavor_creator.flavor_settings.name,
                 port_settings=[port_settings])