def main(): args = cmd() func = None if args.daemon == "monitor": func = monitor if args.daemon == "rpc": from rpc.run import RPC_server_start from functools import partial func = partial(RPC_server_start, args.host, args.rpc_port) func.__name__ = "rpc" if args.daemon == "test": func = test if args.start and func: run(func) elif args.stop and func: stop(func) else: print("you must choose a operator : start/stop", file=sys.stderr) if args.rpc_client: from rpc import get_client, interact interact( get_client((args.host, args.rpc_port), args.auth_token.encode()))
def join_peer(self, peer): try: cli = rpc.get_client(peer['ip'], peer['port']) # get peer info through ping remote_info = cli.ping(self.info) # update to local bucket self.update_bucket(remote_info) # get more peer info through find_node rpc more_peers = cli.find_node(self.info, self.guid) for new_peer in more_peers: self.update_bucket(new_peer) except: logger.error("unexcept error when joining: %s", peer) return
def __init__(self): super(XJobAPI, self).__init__() rpc.init(CONF) target = messaging.Target(topic=topics.TOPIC_XJOB, version='1.0') upgrade_level = CONF.upgrade_levels.xjobapi version_cap = 1.0 if upgrade_level == 'auto': version_cap = self._determine_version_cap(target) else: version_cap = self.VERSION_ALIASES.get(upgrade_level, upgrade_level) serializer = Serializer() self.client = rpc.get_client(target, version_cap=version_cap, serializer=serializer)
def get_client(self, node_info): # TODO cache? cli = rpc.get_client(node_info['ip'], node_info['port']) return cli