From fe5ca2bbc103d25d159bc23b00c3acdfb024c0d2 Mon Sep 17 00:00:00 2001
From: Andrea Spadaccini <spadaccio@google.com>
Date: Tue, 1 Nov 2011 18:45:27 +0000
Subject: [PATCH] Move hooks PATH environment variable to constants

Move the contents of the PATH environment variable for hooks to
constants, and use its value in the code and in the hooks documentation.

Signed-off-by: Andrea Spadaccini <spadaccio@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>
---
 doc/hooks.rst    | 2 +-
 lib/constants.py | 1 +
 lib/mcpu.py      | 2 +-
 3 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/doc/hooks.rst b/doc/hooks.rst
index aa934f550..0de63e322 100644
--- a/doc/hooks.rst
+++ b/doc/hooks.rst
@@ -98,7 +98,7 @@ The scripts will be run as follows:
 
 - stdout and stderr are directed to files
 
-- PATH is reset to ``/sbin:/bin:/usr/sbin:/usr/bin``
+- PATH is reset to :pyeval:`constants.HOOKS_PATH`
 
 - the environment is cleared, and only ganeti-specific variables will
   be left
diff --git a/lib/constants.py b/lib/constants.py
index a7b09a34b..e04e9b3b4 100644
--- a/lib/constants.py
+++ b/lib/constants.py
@@ -332,6 +332,7 @@ HOOKS_PHASE_POST = "post"
 HOOKS_NAME_CFGUPDATE = "config-update"
 HOOKS_NAME_WATCHER = "watcher"
 HOOKS_VERSION = 2
+HOOKS_PATH = "/sbin:/bin:/usr/sbin:/usr/bin"
 
 # hooks subject type (what object type does the LU deal with)
 HTYPE_CLUSTER = "CLUSTER"
diff --git a/lib/mcpu.py b/lib/mcpu.py
index 229ecf483..c41012b53 100644
--- a/lib/mcpu.py
+++ b/lib/mcpu.py
@@ -561,7 +561,7 @@ class HooksMaster(object):
 
     """
     env = {
-      "PATH": "/sbin:/bin:/usr/sbin:/usr/bin",
+      "PATH": constants.HOOKS_PATH,
       "GANETI_HOOKS_VERSION": constants.HOOKS_VERSION,
       "GANETI_OP_CODE": self.opcode,
       "GANETI_DATA_DIR": constants.DATA_DIR,
-- 
GitLab