Skip to content
Snippets Groups Projects
Commit 8c96d01f authored by Guido Trotter's avatar Guido Trotter
Browse files

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: default avatarGuido Trotter <ultrotter@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent cd50653c
No related branches found
No related tags found
No related merge requests found
...@@ -184,16 +184,12 @@ def ParseOptions(): ...@@ -184,16 +184,12 @@ def ParseOptions():
""" """
parser = optparse.OptionParser(description="Ganeti Remote API", parser = optparse.OptionParser(description="Ganeti Remote API",
usage="%prog [-d] [-p port]", usage="%prog [-d]",
version="%%prog (ganeti) %s" % version="%%prog (ganeti) %s" %
constants.RAPI_VERSION) constants.RAPI_VERSION)
parser.add_option("-d", "--debug", dest="debug", parser.add_option("-d", "--debug", dest="debug",
help="Enable some debug messages", help="Enable some debug messages",
default=False, action="store_true") 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", parser.add_option("--no-ssl", dest="ssl",
help="Do not secure HTTP protocol with SSL", help="Do not secure HTTP protocol with SSL",
default=True, action="store_false") default=True, action="store_false")
...@@ -213,7 +209,7 @@ def ParseOptions(): ...@@ -213,7 +209,7 @@ def ParseOptions():
options, args = parser.parse_args() options, args = parser.parse_args()
if len(args) != 0: 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) sys.exit(constants.EXIT_FAILURE)
if options.ssl and not (options.ssl_cert and options.ssl_key): if options.ssl and not (options.ssl_cert and options.ssl_key):
...@@ -245,6 +241,7 @@ def main(): ...@@ -245,6 +241,7 @@ def main():
ssl_params = None ssl_params = None
ssconf.CheckMaster(options.debug) ssconf.CheckMaster(options.debug)
port = utils.GetDaemonPort(constants.RAPI)
if options.fork: if options.fork:
utils.Daemonize(logfile=constants.LOG_RAPISERVER) utils.Daemonize(logfile=constants.LOG_RAPISERVER)
...@@ -255,7 +252,7 @@ def main(): ...@@ -255,7 +252,7 @@ def main():
utils.WritePidFile(constants.RAPI_PID) utils.WritePidFile(constants.RAPI_PID)
try: try:
mainloop = daemon.Mainloop() 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, ssl_params=ssl_params, ssl_verify_peer=False,
request_executor_class= request_executor_class=
JsonErrorRequestExecutor) JsonErrorRequestExecutor)
......
...@@ -117,12 +117,15 @@ RAPI_PID = "ganeti-rapi" ...@@ -117,12 +117,15 @@ RAPI_PID = "ganeti-rapi"
NODE_INITD_SCRIPT = _autoconf.SYSCONFDIR + "/init.d/ganeti" NODE_INITD_SCRIPT = _autoconf.SYSCONFDIR + "/init.d/ganeti"
NODED = "ganeti-noded" NODED = "ganeti-noded"
RAPI = "ganeti-rapi"
DAEMONS_PORTS = { DAEMONS_PORTS = {
# daemon-name: ("proto", "default-port") # daemon-name: ("proto", "default-port")
NODED: ("tcp", 1811), NODED: ("tcp", 1811),
RAPI: ("tcp", 5080),
} }
DEFAULT_NODED_PORT = DAEMONS_PORTS[NODED][1] DEFAULT_NODED_PORT = DAEMONS_PORTS[NODED][1]
DEFAULT_RAPI_PORT = DAEMONS_PORTS[RAPI][1]
FIRST_DRBD_PORT = 11000 FIRST_DRBD_PORT = 11000
LAST_DRBD_PORT = 14999 LAST_DRBD_PORT = 14999
...@@ -496,8 +499,6 @@ OPS_FINALIZED = frozenset([OP_STATUS_CANCELED, ...@@ -496,8 +499,6 @@ OPS_FINALIZED = frozenset([OP_STATUS_CANCELED,
ELOG_MESSAGE = "message" ELOG_MESSAGE = "message"
ELOG_PROGRESS = "progress" ELOG_PROGRESS = "progress"
RAPI_PORT = 5080
# max dynamic devices # max dynamic devices
MAX_NICS = 8 MAX_NICS = 8
MAX_DISKS = 16 MAX_DISKS = 16
......
...@@ -40,7 +40,6 @@ ...@@ -40,7 +40,6 @@
<command>&dhpackage; </command> <command>&dhpackage; </command>
<arg>-d</arg> <arg>-d</arg>
<arg>-f</arg> <arg>-f</arg>
<arg>-p <replaceable>PORT</replaceable></arg>
<arg>--no-ssl</arg> <arg>--no-ssl</arg>
<arg>-K <replaceable>SSL_KEY_FILE</replaceable></arg> <arg>-K <replaceable>SSL_KEY_FILE</replaceable></arg>
<arg>-C <replaceable>SSL_CERT_FILE</replaceable></arg> <arg>-C <replaceable>SSL_CERT_FILE</replaceable></arg>
...@@ -65,8 +64,8 @@ ...@@ -65,8 +64,8 @@
</para> </para>
<para> <para>
The daemon will listen by default on the port 5080, but this can The daemon will listen to the "ganeti-rapi" tcp port, as listed in the
be changed via the <option>-p</option> option. system services database, or to port 5080 by default.
</para> </para>
<para> <para>
......
...@@ -64,7 +64,7 @@ def Enabled(): ...@@ -64,7 +64,7 @@ def Enabled():
def _DoTests(uris): def _DoTests(uris):
master = qa_config.GetMasterNode() master = qa_config.GetMasterNode()
host = master["primary"] 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: for uri, verify in uris:
assert uri.startswith("/") assert uri.startswith("/")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment