def main(): from solarsan import logging logger = logging.getLogger(__name__) from solarsan.cluster.models import Peer from solarsan.conf import rpyc_conn_config from rpyc.utils.server import ThreadedServer #from rpyc.utils.server import ThreadedZmqServer, OneShotZmqServer from setproctitle import setproctitle from .service import CLIService import rpyc title = 'SolarSan CLI' setproctitle('[%s]' % title) local = Peer.get_local() cluster_iface_bcast = local.cluster_nic.broadcast # Allow all public attrs, because exposed_ is stupid and should be a # f*****g decorator. #t = ThreadedZmqServer(CLIService, port=18863, #t = OneShotZmqServer(CLIService, port=18863, t = ThreadedServer(CLIService, port=18863, registrar=rpyc.utils.registry.UDPRegistryClient(ip=cluster_iface_bcast, #logger=None, logger=logger, ), auto_register=True, logger=logger, #logger=None, protocol_config=rpyc_conn_config) t.start()
def dkv_node_info(self): dkv = self.dkv if not self._local_peer: self._local_peer = Peer.get_local() local = self._local_peer node = "/nodes/%s" % (local.uuid) ttl = 20 dkv.set("%s/alive" % node, "yes", ttl=ttl) if not dkv.get("%s/hostname" % node, None): logger.info("Node info is not in Dkv; adding..") dkv.set("%s/hostname" % node, local.hostname) dkv.set("%s/cluster_iface" % node, local.cluster_iface)
def main(): from rpyc.utils.server import ThreadedServer from setproctitle import setproctitle title = 'SolarSan Storage' setproctitle('[%s]' % title) local = Peer.get_local() cluster_iface_bcast = local.cluster_nic.broadcast # Allow all public attrs, because exposed_ is stupid and should be a # f*****g decorator. t = ThreadedServer(StorageService, port=18862, registrar=rpyc.utils.registry.UDPRegistryClient(ip=cluster_iface_bcast, #logger=None, logger=logger, ), auto_register=True, #logger=logger.getChild('rpc.server_storage'), logger=logger, #logger=None, protocol_config=conf.rpyc_conn_config) t.start()
def get_services_cli(): return Peer.get_local().get_service("cli", client_service=ClientService)
def get_peer(uuid=None, local=False): if local: return Peer.get_local() else: return Peer.objects.get(uuid=uuid)