def PrepRapi(options, _): """Prep remote API function, executed with the PID file held. """ mainloop = daemon.Mainloop() users = RapiUsers() handler = RemoteApiHandler(users.Get, options.reqauth) # Setup file watcher (it'll be driven by asyncore) SetupFileWatcher(pathutils.RAPI_USERS_FILE, compat.partial(users.Load, pathutils.RAPI_USERS_FILE)) users.Load(pathutils.RAPI_USERS_FILE) server = http.server.HttpServer(mainloop, options.bind_address, options.port, options.max_clients, handler, ssl_params=options.ssl_params, ssl_verify_peer=False) server.Start() return (mainloop, server)
def PrepNoded(options, _): """Preparation node daemon function, executed with the PID file held. """ if options.mlock: request_executor_class = MlockallRequestExecutor try: utils.Mlockall() except errors.NoCtypesError: logging.warning("Cannot set memory lock, ctypes module not found") request_executor_class = http.server.HttpServerRequestExecutor else: request_executor_class = http.server.HttpServerRequestExecutor # Read SSL certificate if options.ssl: ssl_params = http.HttpSslParams(ssl_key_path=options.ssl_key, ssl_cert_path=options.ssl_cert) else: ssl_params = None err = _PrepareQueueLock() if err is not None: # this might be some kind of file-system/permission error; while # this breaks the job queue functionality, we shouldn't prevent # startup of the whole node daemon because of this logging.critical("Can't init/verify the queue, proceeding anyway: %s", err) handler = NodeRequestHandler() mainloop = daemon.Mainloop() server = http.server.HttpServer( mainloop, options.bind_address, options.port, options.max_clients, handler, ssl_params=ssl_params, ssl_verify_peer=True, request_executor_class=request_executor_class, ssl_verify_callback=SSLVerifyPeer) server.Start() return (mainloop, server)
def PrepRapi(options, _): """Prep remote API function, executed with the PID file held. """ mainloop = daemon.Mainloop() if options.pamauth: options.reqauth = True authenticator = pam.PamAuthenticator() else: authenticator = basic_auth.BasicAuthenticator() handler = RemoteApiHandler(authenticator, options.reqauth) server = \ http.server.HttpServer(mainloop, options.bind_address, options.port, handler, ssl_params=options.ssl_params, ssl_verify_peer=False) server.Start() return (mainloop, server)