Add --enable-rapi parameter to configure
authorMichael Hanselmann <hansmi@google.com>
Fri, 9 May 2008 12:46:52 +0000 (12:46 +0000)
committerMichael Hanselmann <hansmi@google.com>
Fri, 9 May 2008 12:46:52 +0000 (12:46 +0000)
This allows developers and packagers to control whether they want to start
the remote API daemon, ganeti-rapi, automatically or not.

Reviewed-by: ultrotter

DEVNOTES
configure.ac
daemons/ganeti-master
lib/Makefile.am
lib/constants.py

index 862f239..83714ff 100644 (file)
--- a/DEVNOTES
+++ b/DEVNOTES
@@ -6,4 +6,5 @@ Configuring for development
 
 sh autogen.sh && \
 ./configure --enable-maintainer-mode \
-  --prefix=/usr/local --sysconfdir=/etc --localstatedir=/var
+  --prefix=/usr/local --sysconfdir=/etc --localstatedir=/var \
+  --enable-rapi
index 53380bf..331c856 100644 (file)
@@ -64,6 +64,21 @@ AC_ARG_WITH([xen-initrd],
   [xen_initrd="/boot/initrd-2.6-xenU"])
 AC_SUBST(XEN_INITRD, $xen_initrd)
 
+# --enable-rapi
+AC_ARG_ENABLE([rapi],
+  [AS_HELP_STRING([--enable-rapi],
+    [Whether to enable remote API daemon]
+  )])
+if test "$enable_rapi" = "yes"
+then
+  enable_rapi_py=True
+else
+  enable_rapi=no
+  enable_rapi_py=False
+fi
+AC_SUBST(PY_ENABLE_RAPI, $enable_rapi_py)
+
+
 # Check common programs
 AC_PROG_INSTALL
 AC_PROG_LN_S
index 5d882fc..b13ed98 100755 (executable)
@@ -128,11 +128,12 @@ def StartMaster(master_netdev, master_ip, debug):
                          "-s", master_ip, master_ip])
   # we'll ignore the exit code of arping
 
-  # Start remote API
-  result = utils.RunCmd(["ganeti-rapi", "--port=%s" % constants.RAPI_PORT])
-  if debug and result.failed:
-    sys.stderr.write("Failed to start ganeti-rapi, error: %s\n" %
-                     result.output)
+  if constants.RAPI_ENABLE:
+    # Start remote API
+    result = utils.RunCmd(["ganeti-rapi", "--port=%s" % constants.RAPI_PORT])
+    if debug and result.failed:
+      sys.stderr.write("Failed to start ganeti-rapi, error: %s\n" %
+                       result.output)
 
   return EXIT_OK
 
@@ -141,10 +142,13 @@ def StopMaster(master_netdev, master_ip, debug):
   """Stops the master.
 
   """
-  # Stop remote API
-  result = utils.RunCmd(["fuser", "-k", "-n", "tcp", str(constants.RAPI_PORT)])
-  if debug and result.failed:
-    sys.stderr.write("Failed to stop ganeti-rapi, error: %s\n" % result.output)
+  if constants.RAPI_ENABLE:
+    # Stop remote API
+    result = utils.RunCmd(["fuser", "-k", "-n", "tcp",
+                          str(constants.RAPI_PORT)])
+    if debug and result.failed:
+      sys.stderr.write("Failed to stop ganeti-rapi, error: %s\n" %
+                       result.output)
 
   result = utils.RunCmd(["ip", "address", "del", "%s/32" % master_ip,
                          "dev", master_netdev])
index 062bcf1..c965f1f 100644 (file)
@@ -22,6 +22,7 @@ _autoconf.py: Makefile
          echo "XEN_KERNEL = '$(XEN_KERNEL)'"; \
          echo "XEN_INITRD = '$(XEN_INITRD)'"; \
          echo "IALLOCATOR_SEARCH_PATH = [$(IALLOCATOR_SEARCH_PATH)]"; \
+         echo "RAPI_ENABLE = $(PY_ENABLE_RAPI)"; \
        } > $@
 
 include $(srcdir)/Makefile.libcommon
index d970ec3..15446ed 100644 (file)
@@ -182,4 +182,5 @@ IARUN_FAILURE = 2
 IARUN_SUCCESS = 3
 
 # Remote API constants
+RAPI_ENABLE = _autoconf.RAPI_ENABLE
 RAPI_PORT = 5080