Beispiel #1
0
 def test_compute_group(self):
     nodes = list(self.topology.get_group('compute'))
     self.assertNotEqual([], nodes)
     for node in nodes:
         self.assertIn('compute', node.groups)
     hypervisors = {
         hypervisor.hypervisor_hostname.split('.', 1)[0].lower(): hypervisor
         for hypervisor in nova.list_hypervisors()}
     for name, hypervisor in hypervisors.items():
         node = self.topology.get_node(name)
         self.assertEqual(name, node.name)
         self.assertIn(node, nodes)
Beispiel #2
0
    def test_migrate_server_with_host(self):
        """Tests cold migration actually ends on target hypervisor
        """
        server = self.setup_server()
        initial_hypervisor = nova.get_server_hypervisor(server)
        for hypervisor in nova.list_hypervisors(status='enabled', state='up'):
            if initial_hypervisor != hypervisor.hypervisor_hostname:
                target_hypervisor = hypervisor.hypervisor_hostname
                break
        else:
            tobiko.skip_test("Cannot find a valid hypervisor host to migrate "
                             "server to")

        server = self.migrate_server(server=server, host=target_hypervisor)

        final_hypervisor = nova.get_server_hypervisor(server)
        self.assertEqual(target_hypervisor, final_hypervisor)
Beispiel #3
0
    def _test_migrate_server_with_host(self, live: bool):
        """Tests cold migration actually ends on target hypervisor
        """
        server = self.ensure_server(status='ACTIVE')
        initial_hypervisor = nova.get_server_hypervisor(server)

        hypervisors = nova.list_hypervisors(
            status='enabled', state='up').select(
                lambda h: h.hypervisor_hostname != initial_hypervisor)
        if not hypervisors:
            tobiko.skip_test("Cannot find a valid hypervisor host to migrate "
                             "server to")
        target_hypervisor = random.choice(hypervisors).hypervisor_hostname

        server = self.migrate_server(host=target_hypervisor, live=live)
        final_hypervisor = nova.get_server_hypervisor(server)
        self.assertNotEqual(initial_hypervisor, final_hypervisor)
        self.assertEqual(target_hypervisor, final_hypervisor)
Beispiel #4
0
    def test_skip_if_missing_hypervisors(self, count=1, should_skip=False,
                                         **params):
        if should_skip:
            expected_exeption = self.skipException
        else:
            expected_exeption = self.failureException

        @nova.skip_if_missing_hypervisors(count=count, **params)
        def method():
            raise self.fail('Not skipped')

        exception = self.assertRaises(expected_exeption, method)
        if should_skip:
            hypervisors = nova.list_hypervisors(**params)
            message = "missing {!r} hypervisor(s)".format(
                count - len(hypervisors))
            if params:
                message += " with {!s}".format(
                    ','.join('{!s}={!r}'.format(k, v)
                             for k, v in params.items()))
            self.assertEqual(message, str(exception))
        else:
            self.assertEqual('Not skipped', str(exception))
Beispiel #5
0
 def discover_compute_nodes(self):
     for hypervisor in nova.list_hypervisors():
         self.add_node(hostname=hypervisor.hypervisor_hostname,
                       address=hypervisor.host_ip,
                       group='compute')
Beispiel #6
0
 def test_list_hypervisors_with_hypervisor_hostname(self):
     hypervisor1 = nova.list_hypervisors().first
     hypervisor2 = nova.list_hypervisors(
         hypervisor_hostname=hypervisor1.hypervisor_hostname).unique
     self.assertEqual(hypervisor1, hypervisor2)
Beispiel #7
0
 def test_list_hypervisors_without_details(self):
     hypervisor = nova.list_hypervisors(detailed=False).first
     self.assertIsInstance(hypervisor.id, int)
     self.assertTrue(hypervisor.hypervisor_hostname)
     self.assertFalse(hasattr(hypervisor, 'host_ip'))
Beispiel #8
0
 def test_list_hypervisors(self):
     hypervisor = nova.list_hypervisors().first
     self.assertIsInstance(hypervisor.id, int)
     self.assertTrue(hypervisor.hypervisor_hostname)
     netaddr.IPAddress(hypervisor.host_ip)
Beispiel #9
0
def list_computes():
    """list compute host names"""
    return [compute.hypervisor_hostname for compute in nova.list_hypervisors()]