Esempio n. 1
0
 def __init__(self, db_driver=None, image_service=None):
     self.image_service = (image_service
                           or glance.get_default_image_service())
     self.scheduler_rpcapi = scheduler_rpcapi.SchedulerAPI()
     self.volume_rpcapi = volume_rpcapi.VolumeAPI()
     self.availability_zone_names = ()
     super(API, self).__init__(db_driver)
Esempio n. 2
0
    def __init__(self, db_driver=None):
        self.scheduler_rpcapi = scheduler_rpcapi.SchedulerAPI()
        self.volume_rpcapi = volume_rpcapi.VolumeAPI()
        self.availability_zone_names = ()
        self.volume_api = volume_api.API()

        super(API, self).__init__(db_driver)
Esempio n. 3
0
    def _test_scheduler_api(self, method, rpc_method, **kwargs):
        ctxt = context.RequestContext('fake_user', 'fake_project')
        rpcapi = scheduler_rpcapi.SchedulerAPI()
        expected_retval = 'foo' if method == 'call' else None
        expected_version = kwargs.pop('version', rpcapi.RPC_API_VERSION)
        expected_msg = rpcapi.make_msg(method, **kwargs)
        expected_msg['version'] = expected_version

        self.fake_args = None
        self.fake_kwargs = None

        def _fake_rpc_method(*args, **kwargs):
            self.fake_args = args
            self.fake_kwargs = kwargs
            if expected_retval:
                return expected_retval

        self.stubs.Set(rpc, rpc_method, _fake_rpc_method)

        retval = getattr(rpcapi, method)(ctxt, **kwargs)

        self.assertEqual(retval, expected_retval)
        expected_args = [ctxt, CONF.scheduler_topic, expected_msg]
        for arg, expected_arg in zip(self.fake_args, expected_args):
            self.assertEqual(arg, expected_arg)
Esempio n. 4
0
 def __init__(self, host=None, db_driver=None, service_name='undefined',
              cluster=None):
     self.last_capabilities = None
     self.service_name = service_name
     self.scheduler_rpcapi = scheduler_rpcapi.SchedulerAPI()
     super(SchedulerDependentManager, self).__init__(host, db_driver,
                                                     cluster=cluster)
Esempio n. 5
0
 def __init__(self, db_driver=None, image_service=None):
     self.image_service = (image_service
                           or glance.get_default_image_service())
     self.scheduler_rpcapi = scheduler_rpcapi.SchedulerAPI()
     self.volume_rpcapi = volume_rpcapi.VolumeAPI()
     self.availability_zones = []
     self.availability_zones_last_fetched = None
     self.key_manager = keymgr.API()
     super(API, self).__init__(db_driver)
Esempio n. 6
0
 def __init__(self, ext_mgr=None):
     self.ext_mgr = ext_mgr
     super(ServiceController, self).__init__()
     self.volume_api = volume.API()
     self.rpc_apis = {
         constants.SCHEDULER_BINARY: scheduler_rpcapi.SchedulerAPI(),
         constants.VOLUME_BINARY: volume_rpcapi.VolumeAPI(),
         constants.BACKUP_BINARY: backup_rpcapi.BackupAPI(),
     }
Esempio n. 7
0
 def test_cleanup_too_old(self, method):
     cleanup_request = objects.CleanupRequest(self.context)
     rpcapi = scheduler_rpcapi.SchedulerAPI()
     with mock.patch.object(rpcapi.client,
                            'can_send_version',
                            return_value=False) as can_send_mock:
         self.assertRaises(exception.ServiceTooOld, getattr(rpcapi, method),
                           self.context, cleanup_request)
         can_send_mock.assert_called_once_with('3.4')
Esempio n. 8
0
 def __init__(self, scheduler_driver=None, service_name=None,
              *args, **kwargs):
     if not scheduler_driver:
         scheduler_driver = CONF.scheduler_driver
     self.driver = importutils.import_object(scheduler_driver)
     super(SchedulerManager, self).__init__(*args, **kwargs)
     self._startup_delay = True
     self.volume_api = volume_rpcapi.VolumeAPI()
     self.sch_api = scheduler_rpcapi.SchedulerAPI()
     self.rpc_api_version = versionutils.convert_version_to_int(
         self.RPC_API_VERSION)
Esempio n. 9
0
 def __init__(
     self,
     host=None,
     service_name='undefined',
     cluster=None,
     *args,
     **kwargs,
 ):
     self.last_capabilities = None
     self.service_name = service_name
     self.scheduler_rpcapi = scheduler_rpcapi.SchedulerAPI()
     super().__init__(host, cluster=cluster, *args, **kwargs)
Esempio n. 10
0
    def test_cleanup(self, method, host, cluster, get_client):
        cleanup_request = objects.CleanupRequest(self.context,
                                                 host=host,
                                                 cluster_name=cluster)
        rpcapi = scheduler_rpcapi.SchedulerAPI()
        getattr(rpcapi, method)(self.context, cleanup_request)

        prepare = get_client.return_value.prepare

        prepare.assert_called_once_with(version='3.4')
        rpc_call = 'cast' if method == 'do_cleanup' else 'call'
        getattr(prepare.return_value, rpc_call).assert_called_once_with(
            self.context, method, cleanup_request=cleanup_request)
Esempio n. 11
0
    def _test_scheduler_api(self, method, rpc_method,
                            fanout=False, **kwargs):
        ctxt = context.RequestContext('fake_user', 'fake_project')
        rpcapi = scheduler_rpcapi.SchedulerAPI()
        expected_retval = 'foo' if rpc_method == 'call' else None

        target = {
            "fanout": fanout,
            "version": kwargs.pop('version', rpcapi.RPC_API_VERSION)
        }

        expected_msg = copy.deepcopy(kwargs)

        self.fake_args = None
        self.fake_kwargs = None

        def _fake_prepare_method(*args, **kwds):
            for kwd in kwds:
                self.assertEqual(target[kwd], kwds[kwd])
            return rpcapi.client

        def _fake_rpc_method(*args, **kwargs):
            self.fake_args = args
            self.fake_kwargs = kwargs
            if expected_retval:
                return expected_retval

        with mock.patch.object(rpcapi.client, "prepare") as mock_prepared:
            mock_prepared.side_effect = _fake_prepare_method

            with mock.patch.object(rpcapi.client, rpc_method) as mock_method:
                mock_method.side_effect = _fake_rpc_method
                retval = getattr(rpcapi, method)(ctxt, **kwargs)
                self.assertEqual(expected_retval, retval)
                expected_args = [ctxt, method, expected_msg]
                for arg, expected_arg in zip(self.fake_args, expected_args):
                    self.assertEqual(expected_arg, arg)

                for kwarg, value in self.fake_kwargs.items():
                    self.assertEqual(expected_msg[kwarg], value)
Esempio n. 12
0
 def __init__(self, *args, **kwargs):
     self.sch_api = sch_rpc.SchedulerAPI()
Esempio n. 13
0
 def __init__(self, db=None):
     self.backup_rpcapi = backup_rpcapi.BackupAPI()
     self.scheduler_rpcapi = scheduler_rpcapi.SchedulerAPI()
     self.volume_api = cinder.volume.API()
     super(API, self).__init__(db)
Esempio n. 14
0
 def __init__(self):
     self.scheduler_api = rpcapi.SchedulerAPI()
     super(SchedulerStatsController, self).__init__()
Esempio n. 15
0
 def reset(self):
     super(SchedulerDependentManager, self).reset()
     self.scheduler_rpcapi = scheduler_rpcapi.SchedulerAPI()
Esempio n. 16
0
 def reset(self):
     super(SchedulerManager, self).reset()
     self.volume_api = volume_rpcapi.VolumeAPI()
     self.sch_api = scheduler_rpcapi.SchedulerAPI()
     self.driver.reset()
Esempio n. 17
0
 def __init__(self, host=None, db_driver=None, service_name='undefined'):
     self.last_capabilities = None
     self.service_name = service_name
     self.scheduler_rpcapi = scheduler_rpcapi.SchedulerAPI()
     self._tp = greenpool.GreenPool()
     super(SchedulerDependentManager, self).__init__(host, db_driver)
Esempio n. 18
0
File: api.py Progetto: crowdy/cinder
 def __init__(self):
     self.backup_rpcapi = backup_rpcapi.BackupAPI()
     self.scheduler_rpcapi = scheduler_rpcapi.SchedulerAPI()
     self.volume_api = cinder.volume.API()
     super().__init__()