def __init__(self): super(ProtectionAPI, self).__init__() target = messaging.Target(topic=CONF.protection_topic, version=self.RPC_API_VERSION) serializer = objects_base.KarborObjectSerializer() self.client = rpc.get_client(target, version_cap=None, serializer=serializer)
def __init__(self): super(OperationEngineAPI, self).__init__() target = messaging.Target(topic=CONF.operationengine_topic, version=self.RPC_API_VERSION) serializer = objects_base.KarborObjectSerializer() client = rpc.get_client(target, version_cap=None, serializer=serializer) self._client = client.prepare(version='1.0')
def start(self): version_string = version.version_string() LOG.info('Starting %(topic)s node (version %(version_string)s)', {'topic': self.topic, 'version_string': version_string}) self.model_disconnected = False ctxt = context.get_admin_context() try: service_ref = db.service_get_by_args(ctxt, self.host, self.binary) self.service_id = service_ref['id'] except exception.NotFound: self._create_service_ref(ctxt) self.manager.init_host(service_id=self.service_id) LOG.debug("Creating RPC server for service %s", self.topic) target = messaging.Target(topic=self.topic, server=self.host) endpoints = [self.manager] endpoints.extend(self.manager.additional_endpoints) serializer = objects_base.KarborObjectSerializer() self.rpcserver = rpc.get_server(target, endpoints, serializer) self.rpcserver.start() self.manager.init_host_with_rpc() if self.report_interval: pulse = loopingcall.FixedIntervalLoopingCall( self.report_state) pulse.start(interval=self.report_interval, initial_delay=self.report_interval) self.timers.append(pulse) if self.periodic_interval: if self.periodic_fuzzy_delay: initial_delay = random.randint(0, self.periodic_fuzzy_delay) else: initial_delay = None periodic = loopingcall.FixedIntervalLoopingCall( self.periodic_tasks) periodic.start(interval=self.periodic_interval, initial_delay=initial_delay) self.timers.append(periodic)