예제 #1
0
 def setup(self):
     authenticator = TlsliteVdbAuthenticator.from_dict(users)
     self.server = ThreadedServer(rpyc.SlaveService, hostname = "localhost", 
         authenticator = authenticator, auto_register = False)
     self.server.logger.quiet = True
     thread.start_new(self.server.start, ())
     time.sleep(1) # make sure the server has initialized, etc.
예제 #2
0
 def setup(self):
     authenticator = TlsliteVdbAuthenticator.from_dict(users)
     self.server = ThreadedServer(rpyc.SlaveService,
                                  hostname="localhost",
                                  authenticator=authenticator,
                                  auto_register=False)
     self.server.logger.quiet = True
     thread.start_new(self.server.start, ())
     time.sleep(1)  # make sure the server has initialized, etc.
예제 #3
0
def startClusterManager(config):
    global service, data

    dfs = instantiateImplementation(config.get("ClusterManager", "dfs"),
                                    config)
    data = instantiateImplementation(config.get("ClusterManager", "data"),
                                     config)
    service = instantiateImplementation(
        config.get("ClusterManager", "service"), config, data, dfs)

    if boolean(config.get("Security", "authAndEncrypt")):
        users = {}
        userDatabase = data.getUsers()
        for user in userDatabase.values():
            if user.passwd != None:
                users[user.name] = user.passwd
        users[config.get('AllowedUsers', 'nodeManagerUser')] = config.get(
            'AllowedUsers', 'nodeManagerPassword')
        users[config.get('AllowedUsers',
                         'agentUser')] = config.get('AllowedUsers',
                                                    'agentPassword')
        authenticator = TlsliteVdbAuthenticator.from_dict(users)

        # XXXstroucki ThreadedServer is liable to have exceptions
        # occur within if an endpoint is lost.
        t = ThreadedServer(service=rpycservices.ManagerService,
                           hostname='0.0.0.0',
                           port=int(config.get('ClusterManagerService',
                                               'port')),
                           auto_register=False,
                           authenticator=authenticator)
    else:
        t = ThreadedServer(service=rpycservices.ManagerService,
                           hostname='0.0.0.0',
                           port=int(config.get('ClusterManagerService',
                                               'port')),
                           auto_register=False)
    t.logger.setLevel(logging.ERROR)
    t.service.service = service
    t.service._type = 'ClusterManagerService'

    debugConsole(globals())

    t.start()
    # shouldn't exit by itself
    return
예제 #4
0
def get_options():
    options, args = parser.parse_args()
    if args:
        parser.error("does not take positional arguments: %r" % (args, ))

    options.mode = options.mode.lower()

    if options.regtype.lower() == "udp":
        if options.reghost is None:
            options.reghost = "255.255.255.255"
        options.registrar = UDPRegistryClient(ip=options.reghost,
                                              port=options.regport)
    elif options.regtype.lower() == "tcp":
        if options.reghost is None:
            parser.error("must specific --registry-host")
        options.registrar = TCPRegistryClient(ip=options.reghost,
                                              port=options.regport)
    else:
        parser.error("invalid registry type %r" % (options.regtype, ))

    if options.vdbfile:
        if not os.path.exists(options.vdbfile):
            parser.error("vdb file does not exist")
        options.authenticator = TlsliteVdbAuthenticator.from_file(
            options.vdbfile, mode="r")
    if options.ssl_keyfile or options.ssl_certfile or options.ssl_cafile:
        if not options.ssl_keyfile:
            parser.error("SSL: keyfile required")
        if not options.ssl_certfile:
            parser.error("SSL: certfile required")
        options.authenticator = SSLAuthenticator(options.ssl_keyfile,
                                                 options.ssl_certfile,
                                                 options.ssl_cafile)
        if not options.port:
            options.port = DEFAULT_SERVER_SSL_PORT
    else:
        options.authenticator = None
        if not options.port:
            options.port = DEFAULT_SERVER_PORT

    options.handler = "serve_%s" % (options.mode, )
    if options.handler not in globals():
        parser.error("invalid mode %r" % (options.mode, ))

    return options
예제 #5
0
def get_options():
    options, args = parser.parse_args()
    if args:
        parser.error("does not take positional arguments: %r" % (args,))

    options.mode = options.mode.lower()

    if options.regtype.lower() == "udp":
        if options.reghost is None:
            options.reghost = "255.255.255.255"
        options.registrar = UDPRegistryClient(ip = options.reghost, port = options.regport)
    elif options.regtype.lower() == "tcp":
        if options.reghost is None:
            parser.error("must specific --registry-host")
        options.registrar = TCPRegistryClient(ip = options.reghost, port = options.regport)
    else:
        parser.error("invalid registry type %r" % (options.regtype,))

    if options.vdbfile:
        if not os.path.exists(options.vdbfile):
            parser.error("vdb file does not exist")
        options.authenticator = TlsliteVdbAuthenticator.from_file(options.vdbfile, mode = "r")
    if options.ssl_keyfile or options.ssl_certfile or options.ssl_cafile:
        if not options.ssl_keyfile:
            parser.error("SSL: keyfile required")
        if not options.ssl_certfile:
            parser.error("SSL: certfile required")
        options.authenticator = SSLAuthenticator(options.ssl_keyfile, 
            options.ssl_certfile, options.ssl_cafile)
        if not options.port:
            options.port = DEFAULT_SERVER_SSL_PORT
    else:
        options.authenticator = None
        if not options.port:
            options.port = DEFAULT_SERVER_PORT

    options.handler = "serve_%s" % (options.mode,)
    if options.handler not in globals():
        parser.error("invalid mode %r" % (options.mode,))
    
    return options
예제 #6
0
def startNodeManager():
    global config, dfs, vmm, service, server, log, notifier
    publisher = instantiateImplementation(
        config.get("NodeManager", "publisher"), config)
    tashi.publisher = publisher
    dfs = instantiateImplementation(config.get("NodeManager", "dfs"), config)
    vmm = instantiateImplementation(config.get("NodeManager", "vmm"), config,
                                    dfs, None)
    service = instantiateImplementation(config.get("NodeManager", "service"),
                                        config, vmm)
    vmm.nm = service

    if boolean(config.get("Security", "authAndEncrypt")):
        users = {}
        users[config.get('AllowedUsers', 'clusterManagerUser')] = config.get(
            'AllowedUsers', 'clusterManagerPassword')
        authenticator = TlsliteVdbAuthenticator.from_dict(users)

        # XXXstroucki: ThreadedServer is liable to have exceptions
        # occur within if an endpoint is lost.
        t = ThreadedServer(service=rpycservices.ManagerService,
                           hostname='0.0.0.0',
                           port=int(config.get('NodeManagerService', 'port')),
                           auto_register=False,
                           authenticator=authenticator)
    else:
        t = ThreadedServer(service=rpycservices.ManagerService,
                           hostname='0.0.0.0',
                           port=int(config.get('NodeManagerService', 'port')),
                           auto_register=False)
    t.logger.setLevel(logging.ERROR)
    t.service.service = service
    t.service._type = 'NodeManagerService'

    debugConsole(globals())

    t.start()
    # shouldn't exit by itself
    sys.exit(0)