From 14013e5d8ebf1082e54671cc8f212c5da0c295ac Mon Sep 17 00:00:00 2001
From: Michele Tartara <mtartara@google.com>
Date: Thu, 21 Feb 2013 16:25:36 +0000
Subject: [PATCH] Add user and group for the monitoring agent

This commit adds the user and group variables for the monitoring agent in all
the configuration files where they are required.

Signed-off-by: Michele Tartara <mtartara@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>
---
 Makefile.am                     |  7 ++++++-
 autotools/build-bash-completion |  2 +-
 configure.ac                    | 20 +++++++++++++-------
 lib/constants.py                |  2 ++
 4 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 40202272a..e3d67423b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1454,6 +1454,8 @@ lib/_autoconf.py: Makefile | stamp-directories
 	  echo "CONFD_GROUP = '$(CONFD_GROUP)'"; \
 	  echo "NODED_USER = '$(NODED_USER)'"; \
 	  echo "NODED_GROUP = '$(NODED_GROUP)'"; \
+	  echo "MOND_USER = '$(MOND_USER)'"; \
+	  echo "MOND_GROUP = '$(MOND_GROUP)'"; \
 	  echo "DISK_SEPARATOR = '$(DISK_SEPARATOR)'"; \
 	  echo "QEMUIMG_PATH = '$(QEMUIMG_PATH)'"; \
 	  echo "HTOOLS = True"; \
@@ -1461,7 +1463,7 @@ lib/_autoconf.py: Makefile | stamp-directories
 	  echo "XEN_CMD = '$(XEN_CMD)'"; \
 	  echo "ENABLE_SPLIT_QUERY = $(ENABLE_SPLIT_QUERY)"; \
 	  echo "ENABLE_RESTRICTED_COMMANDS = $(ENABLE_RESTRICTED_COMMANDS)"; \
-	  echo "ENABLE_MONITORING = $(ENABLE_MONITORING)"; \
+	  echo "ENABLE_MOND = $(ENABLE_MOND)"; \
 ## Write dictionary with man page name as the key and the section number as the
 ## value
 	  echo "MAN_PAGES = {"; \
@@ -1532,12 +1534,15 @@ $(REPLACE_VARS_SED): $(SHELL_ENV_INIT) Makefile stamp-directories
 	  echo 's#@''GNTRAPIUSER@#$(RAPI_USER)#g'; \
 	  echo 's#@''GNTCONFDUSER@#$(CONFD_USER)#g'; \
 	  echo 's#@''GNTNODEDUSER@#$(NODED_USER)#g'; \
+	  echo 's#@''GNTMONDUSER@#$(MOND_USER)#g'; \
 	  echo 's#@''GNTRAPIGROUP@#$(RAPI_GROUP)#g'; \
 	  echo 's#@''GNTADMINGROUP@#$(ADMIN_GROUP)#g'; \
 	  echo 's#@''GNTCONFDGROUP@#$(CONFD_GROUP)#g'; \
 	  echo 's#@''GNTMASTERDGROUP@#$(MASTERD_GROUP)#g'; \
+	  echo 's#@''GNTMONDGROUP@#$(MOND_GROUP)#g'; \
 	  echo 's#@''GNTDAEMONSGROUP@#$(DAEMONS_GROUP)#g'; \
 	  echo 's#@''CUSTOM_ENABLE_CONFD@#$(ENABLE_CONFD)#g'; \
+	  echo 's#@''CUSTOM_ENABLE_MOND@#$(ENABLE_MOND)#g'; \
 	  echo 's#@''MODULES@#$(strip $(lint_python_code))#g'; \
 	  echo 's#@''XEN_CONFIG_DIR@#$(XEN_CONFIG_DIR)#g'; \
 	  echo; \
diff --git a/autotools/build-bash-completion b/autotools/build-bash-completion
index 49ad9c541..63def1270 100755
--- a/autotools/build-bash-completion
+++ b/autotools/build-bash-completion
@@ -859,7 +859,7 @@ def main():
                            debug=debug)
 
   # mon-collector, if monitoring is enabled
-  if _autoconf.ENABLE_MONITORING:
+  if _autoconf.ENABLE_MOND:
     WriteHaskellCmdCompletion(sw, "src/mon-collector", debug=debug)
 
   # Reset extglob to original value
diff --git a/configure.ac b/configure.ac
index c1ac05305..1a17cc133 100644
--- a/configure.ac
+++ b/configure.ac
@@ -243,15 +243,18 @@ AC_ARG_WITH([user-prefix],
   [user_masterd="${withval}masterd";
    user_rapi="${withval}rapi";
    user_confd="${withval}confd";
-   user_noded="$user_default"],
+   user_noded="$user_default";
+   user_mond="${withval}mond"],
   [user_masterd="$user_default";
    user_rapi="$user_default";
    user_confd="$user_default";
-   user_noded="$user_default"])
+   user_noded="$user_default";
+   user_mond="$user_default"])
 AC_SUBST(MASTERD_USER, $user_masterd)
 AC_SUBST(RAPI_USER, $user_rapi)
 AC_SUBST(CONFD_USER, $user_confd)
 AC_SUBST(NODED_USER, $user_noded)
+AC_SUBST(MOND_USER, $user_mond)
 
 # --with-group-prefix=...
 AC_ARG_WITH([group-prefix],
@@ -265,19 +268,22 @@ AC_ARG_WITH([group-prefix],
    group_confd="${withval}confd";
    group_masterd="${withval}masterd";
    group_noded="$group_default";
-   group_daemons="${withval}daemons";],
+   group_daemons="${withval}daemons";
+   group_mond="${withval}mond"],
   [group_rapi="$group_default";
    group_admin="$group_default";
    group_confd="$group_default";
    group_masterd="$group_default";
    group_noded="$group_default";
-   group_daemons="$group_default"])
+   group_daemons="$group_default";
+   group_mond="$group_default"])
 AC_SUBST(RAPI_GROUP, $group_rapi)
 AC_SUBST(ADMIN_GROUP, $group_admin)
 AC_SUBST(CONFD_GROUP, $group_confd)
 AC_SUBST(MASTERD_GROUP, $group_masterd)
 AC_SUBST(NODED_GROUP, $group_noded)
 AC_SUBST(DAEMONS_GROUP, $group_daemons)
+AC_SUBST(MOND_GROUP, $group_mond)
 
 # Print the config to the user
 AC_MSG_NOTICE([Running ganeti-masterd as $group_masterd:$group_masterd])
@@ -475,7 +481,7 @@ AC_ARG_ENABLE([confd],
   [],
   [enable_confd=check])
 
-ENABLE_MONITORING=
+ENABLE_MOND=
 AC_ARG_ENABLE([monitoring],
   [AS_HELP_STRING([--enable-monitoring],
   [enable the ganeti monitoring agent (default: check)])],
@@ -573,8 +579,8 @@ fi
 if test "$has_monitoring" = True; then
   AC_MSG_NOTICE([Enabling the monitoring agent usage])
 fi
-AC_SUBST(ENABLE_MONITORING, $has_monitoring)
-AM_CONDITIONAL([ENABLE_MONITORING], [test "$has_monitoring" = True])
+AC_SUBST(ENABLE_MOND, $has_monitoring)
+AM_CONDITIONAL([ENABLE_MOND], [test "$has_monitoring" = True])
 
 # development modules
 HS_NODEV=
diff --git a/lib/constants.py b/lib/constants.py
index 5dc54b120..f1f016fdf 100644
--- a/lib/constants.py
+++ b/lib/constants.py
@@ -106,6 +106,8 @@ CONFD_USER = _autoconf.CONFD_USER
 CONFD_GROUP = _autoconf.CONFD_GROUP
 NODED_USER = _autoconf.NODED_USER
 NODED_GROUP = _autoconf.NODED_GROUP
+MOND_USER = _autoconf.MOND_USER
+MOND_GROUP = _autoconf.MOND_GROUP
 SSH_LOGIN_USER = _autoconf.SSH_LOGIN_USER
 SSH_CONSOLE_USER = _autoconf.SSH_CONSOLE_USER
 
-- 
GitLab