From 8c96d01fcdba4c757c3760daca58c67032057d20 Mon Sep 17 00:00:00 2001 From: Guido Trotter <ultrotter@google.com> Date: Thu, 23 Jul 2009 14:11:54 +0100 Subject: [PATCH] Move rapi to GetDaemonPort Currently rapi is the only daemon which accepts a port option, rather than querying its own port from services, and failing back to the default if not found. Changing this to conform to what other daemons do. Also update the ganeti-rapi(8) manpage Signed-off-by: Guido Trotter <ultrotter@google.com> Reviewed-by: Michael Hanselmann <hansmi@google.com> --- daemons/ganeti-rapi | 11 ++++------- lib/constants.py | 5 +++-- man/ganeti-rapi.sgml | 5 ++--- qa/qa_rapi.py | 2 +- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/daemons/ganeti-rapi b/daemons/ganeti-rapi index 2288f17f4..3f0bb8cc1 100755 --- a/daemons/ganeti-rapi +++ b/daemons/ganeti-rapi @@ -184,16 +184,12 @@ def ParseOptions(): """ parser = optparse.OptionParser(description="Ganeti Remote API", - usage="%prog [-d] [-p port]", + usage="%prog [-d]", version="%%prog (ganeti) %s" % constants.RAPI_VERSION) parser.add_option("-d", "--debug", dest="debug", help="Enable some debug messages", default=False, action="store_true") - parser.add_option("-p", "--port", dest="port", - help="Port to run API (%s default)." % - constants.RAPI_PORT, - default=constants.RAPI_PORT, type="int") parser.add_option("--no-ssl", dest="ssl", help="Do not secure HTTP protocol with SSL", default=True, action="store_false") @@ -213,7 +209,7 @@ def ParseOptions(): options, args = parser.parse_args() if len(args) != 0: - print >> sys.stderr, "Usage: %s [-d] [-p port]" % sys.argv[0] + print >> sys.stderr, "Usage: %s [-d]" % sys.argv[0] sys.exit(constants.EXIT_FAILURE) if options.ssl and not (options.ssl_cert and options.ssl_key): @@ -245,6 +241,7 @@ def main(): ssl_params = None ssconf.CheckMaster(options.debug) + port = utils.GetDaemonPort(constants.RAPI) if options.fork: utils.Daemonize(logfile=constants.LOG_RAPISERVER) @@ -255,7 +252,7 @@ def main(): utils.WritePidFile(constants.RAPI_PID) try: mainloop = daemon.Mainloop() - server = RemoteApiHttpServer(mainloop, options.bind_address, options.port, + server = RemoteApiHttpServer(mainloop, options.bind_address, port, ssl_params=ssl_params, ssl_verify_peer=False, request_executor_class= JsonErrorRequestExecutor) diff --git a/lib/constants.py b/lib/constants.py index 2080bf245..33dddbbb3 100644 --- a/lib/constants.py +++ b/lib/constants.py @@ -117,12 +117,15 @@ RAPI_PID = "ganeti-rapi" NODE_INITD_SCRIPT = _autoconf.SYSCONFDIR + "/init.d/ganeti" NODED = "ganeti-noded" +RAPI = "ganeti-rapi" DAEMONS_PORTS = { # daemon-name: ("proto", "default-port") NODED: ("tcp", 1811), + RAPI: ("tcp", 5080), } DEFAULT_NODED_PORT = DAEMONS_PORTS[NODED][1] +DEFAULT_RAPI_PORT = DAEMONS_PORTS[RAPI][1] FIRST_DRBD_PORT = 11000 LAST_DRBD_PORT = 14999 @@ -496,8 +499,6 @@ OPS_FINALIZED = frozenset([OP_STATUS_CANCELED, ELOG_MESSAGE = "message" ELOG_PROGRESS = "progress" -RAPI_PORT = 5080 - # max dynamic devices MAX_NICS = 8 MAX_DISKS = 16 diff --git a/man/ganeti-rapi.sgml b/man/ganeti-rapi.sgml index 20a82850d..00ddfde05 100644 --- a/man/ganeti-rapi.sgml +++ b/man/ganeti-rapi.sgml @@ -40,7 +40,6 @@ <command>&dhpackage; </command> <arg>-d</arg> <arg>-f</arg> - <arg>-p <replaceable>PORT</replaceable></arg> <arg>--no-ssl</arg> <arg>-K <replaceable>SSL_KEY_FILE</replaceable></arg> <arg>-C <replaceable>SSL_CERT_FILE</replaceable></arg> @@ -65,8 +64,8 @@ </para> <para> - The daemon will listen by default on the port 5080, but this can - be changed via the <option>-p</option> option. + The daemon will listen to the "ganeti-rapi" tcp port, as listed in the + system services database, or to port 5080 by default. </para> <para> diff --git a/qa/qa_rapi.py b/qa/qa_rapi.py index 76b96f10b..1ab34f931 100644 --- a/qa/qa_rapi.py +++ b/qa/qa_rapi.py @@ -64,7 +64,7 @@ def Enabled(): def _DoTests(uris): master = qa_config.GetMasterNode() host = master["primary"] - port = qa_config.get("rapi-port", default=constants.RAPI_PORT) + port = qa_config.get("rapi-port", default=constants.DEFAULT_RAPI_PORT) for uri, verify in uris: assert uri.startswith("/") -- GitLab