def __init__(self, image_api=None, **kwargs): super(API, self).__init__(**kwargs) self.image_api = image_api or image.API() self.engine_rpcapi = rpcapi.EngineAPI() self.network_api = network.API() self.quota = quota.Quota() self.quota.register_resource(objects.quota.ServerResource()) self.consoleauth_rpcapi = consoleauth_rpcapi.ConsoleAuthAPI()
def __init__(self, host, topic): super(ConsoleAuthManager, self).__init__() self.host = host self.topic = topic self._started = False self._cache = None self._cache_server = None self.engine_rpcapi = rpcapi.EngineAPI()
def __init__(self, host, topic): super(BaseEngineManager, self).__init__(CONF) if not host: host = CONF.host self.host = host self.topic = topic self.network_api = network.API() self.driver = driver.load_engine_driver(CONF.engine.engine_driver) self.engine_rpcapi = rpcapi.EngineAPI() self._sync_power_pool = greenpool.GreenPool( size=CONF.engine.sync_power_state_pool_size) self._syncs_in_progress = {} self._started = False
def _test_rpcapi(self, method, rpc_method, **kwargs): rpcapi = engine_rpcapi.EngineAPI(topic='fake-topic') expected_retval = 'hello world' if rpc_method == 'call' else None expected_topic = 'fake-topic' target = { "topic": expected_topic, "server": CONF.host, "version": kwargs.pop('version', rpcapi.RPC_API_VERSION) } expected_msg = copy.deepcopy(kwargs) self.fake_args = None self.fake_kwargs = None def _fake_can_send_version_method(version): return messaging_utils.version_is_compatible( rpcapi.RPC_API_VERSION, version) def _fake_prepare_method(*args, **kwargs): for kwd in kwargs: self.assertEqual(kwargs[kwd], target[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, "can_send_version") as mock_can_send_version: mock_can_send_version.side_effect = _fake_can_send_version_method 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)(self.context, **kwargs) self.assertEqual(retval, expected_retval) expected_args = [self.context, method, expected_msg] for arg, expected_arg in zip(self.fake_args, expected_args): self.assertEqual(arg, expected_arg)
def reset(self): LOG.info('Reloading Mogan engine RPC API') self.engine_rpcapi = rpcapi.EngineAPI()