Ejemplo n.º 1
0
    def test_different_host(self, _mock_novaclient, fake_extensions):
        _mock_novaclient.return_value = fakes.FakeNovaClient()
        fake_extensions.return_value = (
            fakes.FakeNovaClient().list_extensions.show_all())
        filt_cls = self.class_map['InstanceLocalityFilter']()
        host = fakes.FakeHostState('host1', {})
        uuid = nova.novaclient().servers.create('host2')

        filter_properties = {
            'context': self.context,
            'scheduler_hints': {
                'local_to_instance': uuid
            }
        }
        self.assertFalse(filt_cls.host_passes(host, filter_properties))
Ejemplo n.º 2
0
    def test_same_host(self, _mock_novaclient):
        _mock_novaclient.return_value = fakes.FakeNovaClient()
        filt_cls = self.class_map['InstanceLocalityFilter']()
        host = fakes.FakeHostState('host1', {})
        uuid = nova.novaclient().servers.create('host1')

        filter_properties = {'context': self.context,
                             'scheduler_hints': {'local_to_instance': uuid}}
        self.assertTrue(filt_cls.host_passes(host, filter_properties))
Ejemplo n.º 3
0
    def test_nova_no_extended_server_attributes(self, _mock_novaclient):
        _mock_novaclient.return_value = fakes.FakeNovaClient(
            ext_srv_attr=False)
        filt_cls = self.class_map['InstanceLocalityFilter']()
        host = fakes.FakeHostState('host1', {})
        uuid = nova.novaclient().servers.create('host1')

        filter_properties = {'context': self.context,
                             'scheduler_hints': {'local_to_instance': uuid}}
        self.assertRaises(exception.CinderException,
                          filt_cls.host_passes, host, filter_properties)
Ejemplo n.º 4
0
    def test_nova_timeout(self, _mock_request, fake_extensions):
        # Simulate a HTTP timeout
        _mock_request.side_effect = request_exceptions.Timeout
        fake_extensions.return_value = (
            fakes.FakeNovaClient().list_extensions.show_all())

        filt_cls = self.class_map['InstanceLocalityFilter']()
        host = fakes.FakeHostState('host1', {})

        filter_properties = \
            {'context': self.context, 'scheduler_hints':
                {'local_to_instance': 'e29b11d4-15ef-34a9-a716-598a6f0b5467'}}
        self.assertRaises(exception.APITimeout, filt_cls.host_passes, host,
                          filter_properties)