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
......@@ -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)
......
......@@ -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
......
......@@ -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>
......
......@@ -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("/")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment