Exemplo n.º 1
0
    def test_schedule_group(self, _mock_service_get_all):
        # Make sure _schedule_group() can find host successfully.
        sched = fakes.FakeFilterScheduler()
        sched.host_manager = fakes.FakeHostManager()
        fake_context = context.RequestContext('user', 'project',
                                              is_admin=True)

        fakes.mock_host_manager_db_calls(_mock_service_get_all)

        specs = {'capabilities:consistencygroup_support': '<is> True'}
        request_spec = {'volume_properties': {'project_id': 1,
                                              'size': 0},
                        'volume_type': {'name': 'Type1',
                                        'extra_specs': specs}}
        request_spec2 = {'volume_properties': {'project_id': 1,
                                               'size': 0},
                         'volume_type': {'name': 'Type2',
                                         'extra_specs': specs}}
        request_spec_list = [request_spec, request_spec2]
        group_spec = {'group_type': {'name': 'GrpType'},
                      'volume_properties': {'project_id': 1,
                                            'size': 0}}
        weighed_host = sched._schedule_generic_group(fake_context,
                                                     group_spec,
                                                     request_spec_list,
                                                     {}, [])
        self.assertIsNotNone(weighed_host.obj)
        self.assertTrue(_mock_service_get_all.called)
Exemplo n.º 2
0
    def test_schedule_consistencygroup_no_cg_support_in_extra_specs(
            self,
            _mock_service_get_all):
        # Make sure _schedule_group() can find host successfully even
        # when consistencygroup_support is not specified in volume type's
        # extra specs
        sched = fakes.FakeFilterScheduler()
        sched.host_manager = fakes.FakeHostManager()
        fake_context = context.RequestContext('user', 'project',
                                              is_admin=True)

        fakes.mock_host_manager_db_calls(_mock_service_get_all)

        request_spec = {'volume_properties': {'project_id': 1,
                                              'size': 0},
                        'volume_type': {'name': 'Type1',
                                        'extra_specs': {}}}
        request_spec2 = {'volume_properties': {'project_id': 1,
                                               'size': 0},
                         'volume_type': {'name': 'Type2',
                                         'extra_specs': {}}}
        request_spec_list = [request_spec, request_spec2]
        weighed_host = sched._schedule_group(fake_context,
                                             request_spec_list,
                                             {})
        self.assertIsNotNone(weighed_host.obj)
        self.assertTrue(_mock_service_get_all.called)
    def test_schedule_consistencygroup(self, _mock_service_get_all_by_topic):
        # Make sure _schedule_group() can find host successfully.
        sched = fakes.FakeFilterScheduler()
        sched.host_manager = fakes.FakeHostManager()
        fake_context = context.RequestContext('user', 'project', is_admin=True)

        fakes.mock_host_manager_db_calls(_mock_service_get_all_by_topic)

        specs = {'capabilities:consistencygroup_support': '<is> True'}
        request_spec = {
            'volume_properties': {
                'project_id': 1,
                'size': 0
            },
            'volume_type': {
                'name': 'Type1',
                'extra_specs': specs
            }
        }
        request_spec2 = {
            'volume_properties': {
                'project_id': 1,
                'size': 0
            },
            'volume_type': {
                'name': 'Type2',
                'extra_specs': specs
            }
        }
        request_spec_list = [request_spec, request_spec2]
        weighed_host = sched._schedule_group(fake_context, request_spec_list,
                                             {})
        self.assertIsNotNone(weighed_host.obj)
        self.assertTrue(_mock_service_get_all_by_topic.called)
Exemplo n.º 4
0
    def test_schedule_group(self, specs, _mock_service_get_all):
        # Make sure _schedule_group() can find host successfully.
        sched = fakes.FakeFilterScheduler()
        sched.host_manager = fakes.FakeHostManager()
        fake_context = context.RequestContext('user', 'project',
                                              is_admin=True)

        fakes.mock_host_manager_db_calls(_mock_service_get_all)

        request_spec = {'volume_properties': {'project_id': 1,
                                              'size': 0},
                        'volume_type': {'name': 'Type1',
                                        'extra_specs': specs}}
        request_spec2 = {'volume_properties': {'project_id': 1,
                                               'size': 0},
                         'volume_type': {'name': 'Type2',
                                         'extra_specs': specs}}
        request_spec_list = [request_spec, request_spec2]
        group_spec = {'group_type': {'name': 'GrpType'},
                      'volume_properties': {'project_id': 1,
                                            'size': 0}}
        weighed_host = sched._schedule_generic_group(fake_context,
                                                     group_spec,
                                                     request_spec_list,
                                                     {}, [])
        self.assertIsNotNone(weighed_host.obj)
        self.assertTrue(_mock_service_get_all.called)
    def test_create_volume_update_fault(self, _mock_service_get_all,
                                        _mock_volume_get,
                                        _mock_vol_fault_update,
                                        _mock_vol_update):
        sched = fakes.FakeFilterScheduler()
        sched.host_manager = fakes.FakeHostManager()
        fake_context = context.RequestContext('user', 'project', is_admin=True)

        fakes.mock_host_manager_db_calls(_mock_service_get_all)

        volume = fake_volume.fake_volume_obj(self.context)
        _mock_volume_get.return_value = volume

        driver.volume_update_db(self.context, volume.id, 'fake_host',
                                'fake_cluster')

        request_spec = {
            'volume_type': {
                'name': 'LVM_iSCSI'
            },
            'volume_properties': {
                'project_id': 1,
                'size': 1
            },
            'volume_id': volume.id,
            'snapshot_id': None,
            'image_id': None
        }
        request_spec = objects.RequestSpec.from_primitives(request_spec)
        sched.schedule_create_volume(fake_context, request_spec, {})
        _mock_vol_fault_update.assert_called_once_with(
            fake_context, volume.id, dict(message='', details=''))
Exemplo n.º 6
0
    def test_schedule_consistencygroup_no_cg_support_in_extra_specs(
            self,
            _mock_service_get_all):
        # Make sure _schedule_group() can find host successfully even
        # when consistencygroup_support is not specified in volume type's
        # extra specs
        sched = fakes.FakeFilterScheduler()
        sched.host_manager = fakes.FakeHostManager()
        fake_context = context.RequestContext('user', 'project',
                                              is_admin=True)

        fakes.mock_host_manager_db_calls(_mock_service_get_all)

        request_spec = {'volume_properties': {'project_id': 1,
                                              'size': 0},
                        'volume_type': {'name': 'Type1',
                                        'extra_specs': {}}}
        request_spec2 = {'volume_properties': {'project_id': 1,
                                               'size': 0},
                         'volume_type': {'name': 'Type2',
                                         'extra_specs': {}}}
        request_spec_list = [request_spec, request_spec2]
        weighed_host = sched._schedule_group(fake_context,
                                             request_spec_list,
                                             {})
        self.assertIsNotNone(weighed_host.obj)
        self.assertTrue(_mock_service_get_all.called)
    def _host_passes_filters_setup(self, mock_obj):
        sched = fakes.FakeFilterScheduler()
        sched.host_manager = fakes.FakeHostManager()
        fake_context = context.RequestContext('user', 'project', is_admin=True)

        fakes.mock_host_manager_db_calls(mock_obj)

        return (sched, fake_context)
 def _get_all_hosts(self, _mock_service_get_all_by_topic, disabled=False):
     ctxt = context.get_admin_context()
     fakes.mock_host_manager_db_calls(_mock_service_get_all_by_topic,
                                      disabled=disabled)
     host_states = self.host_manager.get_all_host_states(ctxt)
     _mock_service_get_all_by_topic.assert_called_once_with(
         ctxt, CONF.volume_topic, disabled=disabled)
     return host_states
Exemplo n.º 9
0
 def _get_all_hosts(self, _mock_service_get_all_by_topic, disabled=False):
     ctxt = context.get_admin_context()
     fakes.mock_host_manager_db_calls(_mock_service_get_all_by_topic,
                                      disabled=disabled)
     host_states = self.host_manager.get_all_host_states(ctxt)
     _mock_service_get_all_by_topic.assert_called_once_with(
         ctxt, CONF.volume_topic, disabled=disabled)
     return host_states
Exemplo n.º 10
0
    def _host_passes_filters_setup(self, mock_obj):
        sched = fakes.FakeFilterScheduler()
        sched.host_manager = fakes.FakeHostManager()
        fake_context = context.RequestContext('user', 'project',
                                              is_admin=True)

        fakes.mock_host_manager_db_calls(mock_obj)

        return (sched, fake_context)
 def _get_all_backends(self, _mock_service_get_all, disabled=False):
     ctxt = context.get_admin_context()
     fakes.mock_host_manager_db_calls(_mock_service_get_all,
                                      disabled=disabled)
     backend_states = self.host_manager.get_all_backend_states(ctxt)
     _mock_service_get_all.assert_called_once_with(
         ctxt,
         None,  # backend_match_level
         topic=constants.VOLUME_TOPIC, frozen=False, disabled=disabled)
     return backend_states
Exemplo n.º 12
0
 def test_create_volume_host_same_as_group(self, _mock_service_get_all):
     # Ensure we don't clear the host whose backend is same as
     # group's backend.
     sched = fakes.FakeFilterScheduler()
     sched.host_manager = fakes.FakeHostManager()
     fakes.mock_host_manager_db_calls(_mock_service_get_all)
     fake_context = context.RequestContext('user', 'project')
     request_spec = {'volume_properties': {'project_id': 1,
                                           'size': 1},
                     'volume_type': {'name': 'LVM_iSCSI'},
                     'group_backend': 'host1'}
     weighed_host = sched._schedule(fake_context, request_spec, {})
     self.assertEqual('host1#lvm1', weighed_host.obj.host)
Exemplo n.º 13
0
 def test_create_volume_host_same_as_cg(self, _mock_service_get_all):
     # Ensure we don't clear the host whose backend is same as
     # consistencygroup's backend.
     sched = fakes.FakeFilterScheduler()
     sched.host_manager = fakes.FakeHostManager()
     fakes.mock_host_manager_db_calls(_mock_service_get_all)
     fake_context = context.RequestContext('user', 'project')
     request_spec = {'volume_properties': {'project_id': 1,
                                           'size': 1},
                     'volume_type': {'name': 'LVM_iSCSI'},
                     'CG_backend': 'host1'}
     weighed_host = sched._schedule(fake_context, request_spec, {})
     self.assertEqual('host1#lvm1', weighed_host.obj.host)
Exemplo n.º 14
0
 def test_create_volume_clear_host_different_with_cg(self,
                                                     _mock_service_get_all):
     # Ensure we clear those hosts whose backend is not same as
     # consistencygroup's backend.
     sched = fakes.FakeFilterScheduler()
     sched.host_manager = fakes.FakeHostManager()
     fakes.mock_host_manager_db_calls(_mock_service_get_all)
     fake_context = context.RequestContext('user', 'project')
     request_spec = {'volume_properties': {'project_id': 1,
                                           'size': 1},
                     'volume_type': {'name': 'LVM_iSCSI'},
                     'CG_backend': 'host@lvmdriver'}
     weighed_host = sched._schedule(fake_context, request_spec, {})
     self.assertIsNone(weighed_host)
Exemplo n.º 15
0
 def test_create_volume_clear_host_different_with_group(
         self, _mock_service_get_all):
     # Ensure we clear those hosts whose backend is not same as
     # group's backend.
     sched = fakes.FakeFilterScheduler()
     sched.host_manager = fakes.FakeHostManager()
     fakes.mock_host_manager_db_calls(_mock_service_get_all)
     fake_context = context.RequestContext('user', 'project')
     request_spec = {'volume_properties': {'project_id': 1,
                                           'size': 1},
                     'volume_type': {'name': 'LVM_iSCSI'},
                     'group_backend': 'host@lvmdriver'}
     weighed_host = sched._schedule(fake_context, request_spec, {})
     self.assertIsNone(weighed_host)
Exemplo n.º 16
0
 def test_create_volume_host_different_with_resource_backend(
         self, resource_backend, multibackend_with_pools,
         _mock_service_get_all):
     sched = fakes.FakeFilterScheduler()
     sched.host_manager = fakes.FakeHostManager(
         multibackend_with_pools=multibackend_with_pools)
     fakes.mock_host_manager_db_calls(
         _mock_service_get_all, backends_with_pools=multibackend_with_pools)
     fake_context = context.RequestContext('user', 'project')
     request_spec = {'volume_properties': {'project_id': 1,
                                           'size': 1},
                     'volume_type': {'name': 'LVM_iSCSI'},
                     'resource_backend': resource_backend}
     weighed_host = sched._schedule(fake_context, request_spec, {})
     self.assertIsNone(weighed_host)
Exemplo n.º 17
0
 def test_create_volume_host_different_with_resource_backend(
         self, resource_backend, multibackend_with_pools,
         _mock_service_get_all):
     sched = fakes.FakeFilterScheduler()
     sched.host_manager = fakes.FakeHostManager(
         multibackend_with_pools=multibackend_with_pools)
     fakes.mock_host_manager_db_calls(
         _mock_service_get_all, backends_with_pools=multibackend_with_pools)
     fake_context = context.RequestContext('user', 'project')
     request_spec = {'volume_properties': {'project_id': 1,
                                           'size': 1},
                     'volume_type': {'name': 'LVM_iSCSI'},
                     'resource_backend': resource_backend}
     weighed_host = sched._schedule(fake_context, request_spec, {})
     self.assertIsNone(weighed_host)
Exemplo n.º 18
0
    def test_schedule_happy_day(self, _mock_service_get_all_by_topic):
        # Make sure there's nothing glaringly wrong with _schedule()
        # by doing a happy day pass through.
        sched = fakes.FakeFilterScheduler()
        sched.host_manager = fakes.FakeHostManager()
        fake_context = context.RequestContext('user', 'project',
                                              is_admin=True)

        fakes.mock_host_manager_db_calls(_mock_service_get_all_by_topic)

        request_spec = {'volume_type': {'name': 'LVM_iSCSI'},
                        'volume_properties': {'project_id': 1,
                                              'size': 1}}
        weighed_host = sched._schedule(fake_context, request_spec, {})
        self.assertIsNotNone(weighed_host.obj)
        self.assertTrue(_mock_service_get_all_by_topic.called)
Exemplo n.º 19
0
    def test_schedule_happy_day(self, _mock_service_get_all_by_topic):
        # Make sure there's nothing glaringly wrong with _schedule()
        # by doing a happy day pass through.
        sched = fakes.FakeFilterScheduler()
        sched.host_manager = fakes.FakeHostManager()
        fake_context = context.RequestContext('user', 'project',
                                              is_admin=True)

        fakes.mock_host_manager_db_calls(_mock_service_get_all_by_topic)

        request_spec = {'volume_type': {'name': 'LVM_iSCSI'},
                        'volume_properties': {'project_id': 1,
                                              'size': 1}}
        weighed_host = sched._schedule(fake_context, request_spec, {})
        self.assertIsNotNone(weighed_host.obj)
        self.assertTrue(_mock_service_get_all_by_topic.called)
Exemplo n.º 20
0
 def test_create_volume_host_same_as_resource(self, resource_backend,
                                              multibackend_with_pools,
                                              _mock_service_get_all):
     # Ensure we don't clear the host whose backend is same as
     # requested backend (ex: create from source-volume/snapshot,
     # or create within a group)
     sched = fakes.FakeFilterScheduler()
     sched.host_manager = fakes.FakeHostManager(
         multibackend_with_pools=multibackend_with_pools)
     fakes.mock_host_manager_db_calls(
         _mock_service_get_all, backends_with_pools=multibackend_with_pools)
     fake_context = context.RequestContext('user', 'project')
     request_spec = {'volume_properties': {'project_id': 1,
                                           'size': 1},
                     'volume_type': {'name': 'LVM_iSCSI'},
                     'resource_backend': resource_backend}
     weighed_host = sched._schedule(fake_context, request_spec, {})
     self.assertIn(resource_backend, weighed_host.obj.host)
Exemplo n.º 21
0
 def test_create_volume_host_same_as_resource(self, resource_backend,
                                              multibackend_with_pools,
                                              _mock_service_get_all):
     # Ensure we don't clear the host whose backend is same as
     # requested backend (ex: create from source-volume/snapshot,
     # or create within a group)
     sched = fakes.FakeFilterScheduler()
     sched.host_manager = fakes.FakeHostManager(
         multibackend_with_pools=multibackend_with_pools)
     fakes.mock_host_manager_db_calls(
         _mock_service_get_all, backends_with_pools=multibackend_with_pools)
     fake_context = context.RequestContext('user', 'project')
     request_spec = {'volume_properties': {'project_id': 1,
                                           'size': 1},
                     'volume_type': {'name': 'LVM_iSCSI'},
                     'resource_backend': resource_backend}
     weighed_host = sched._schedule(fake_context, request_spec, {})
     self.assertIn(resource_backend, weighed_host.obj.host)