Esempio n. 1
0
    def test_list_hypervisors(self):
        '''This test verifies that calling list_hypervisors results in a call
        to nova client.'''
        uuid1 = uuid.uuid4().hex
        uuid2 = uuid.uuid4().hex
        self.use_compute_discovery()
        self.register_uris([
            dict(method='GET',
                 uri='https://compute.example.com/v2.1/os-hypervisors/detail',
                 json={
                     'hypervisors': [
                         fakes.make_fake_hypervisor(uuid1, 'testserver1'),
                         fakes.make_fake_hypervisor(uuid2, 'testserver2'),
                     ]
                 },
                 validate={
                     'headers': {
                         'OpenStack-API-Version': 'compute 2.53'
                     }
                 }),
        ])

        r = self.cloud.list_hypervisors()

        self.assertEqual(2, len(r))
        self.assertEqual('testserver1', r[0]['name'])
        self.assertEqual(uuid1, r[0]['id'])
        self.assertEqual('testserver2', r[1]['name'])
        self.assertEqual(uuid2, r[1]['id'])

        self.assert_calls()
Esempio n. 2
0
    def test_list_hypervisors(self):
        '''This test verifies that calling list_hypervisors results in a call
        to nova client.'''
        self.register_uris([
            dict(method='GET',
                 uri=self.get_mock_url(
                     'compute', 'public', append=['os-hypervisors', 'detail']),
                 json={'hypervisors': [
                     fakes.make_fake_hypervisor('1', 'testserver1'),
                     fakes.make_fake_hypervisor('2', 'testserver2'),
                 ]}),
        ])

        r = self.cloud.list_hypervisors()

        self.assertEqual(2, len(r))
        self.assertEqual('testserver1', r[0]['hypervisor_hostname'])
        self.assertEqual('testserver2', r[1]['hypervisor_hostname'])

        self.assert_calls()
    def test_list_hypervisors(self):
        '''This test verifies that calling list_hypervisors results in a call
        to nova client.'''
        self.register_uris([
            dict(method='GET',
                 uri=self.get_mock_url(
                     'compute', 'public', append=['os-hypervisors', 'detail']),
                 json={'hypervisors': [
                     fakes.make_fake_hypervisor('1', 'testserver1'),
                     fakes.make_fake_hypervisor('2', 'testserver2'),
                 ]}),
        ])

        r = self.cloud.list_hypervisors()

        self.assertEqual(2, len(r))
        self.assertEqual('testserver1', r[0]['hypervisor_hostname'])
        self.assertEqual('testserver2', r[1]['hypervisor_hostname'])

        self.assert_calls()
Esempio n. 4
0
    def test_list_old_hypervisors(self):
        '''This test verifies that calling list_hypervisors on a pre-2.53 cloud
        calls the old version.'''
        self.use_compute_discovery(
            compute_version_json='old-compute-version.json')
        self.register_uris([
            dict(method='GET',
                 uri='https://compute.example.com/v2.1/os-hypervisors/detail',
                 json={
                     'hypervisors': [
                         fakes.make_fake_hypervisor('1', 'testserver1'),
                         fakes.make_fake_hypervisor('2', 'testserver2'),
                     ]
                 }),
        ])

        r = self.cloud.list_hypervisors()

        self.assertEqual(2, len(r))
        self.assertEqual('testserver1', r[0]['name'])
        self.assertEqual('testserver2', r[1]['name'])

        self.assert_calls()