Move hooks PATH environment variable to constants
authorAndrea Spadaccini <spadaccio@google.com>
Tue, 1 Nov 2011 18:45:27 +0000 (18:45 +0000)
committerIustin Pop <iustin@google.com>
Wed, 9 May 2012 09:31:30 +0000 (11:31 +0200)
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>
(cherry picked from commit fe5ca2bbc103d25d159bc23b00c3acdfb024c0d2)
Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

doc/hooks.rst
lib/constants.py
lib/mcpu.py

index d9f09f2..3cf8bc7 100644 (file)
@@ -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
index 4fa186e..90b9922 100644 (file)
@@ -328,6 +328,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"
index 89046c6..ba07b83 100644 (file)
@@ -519,7 +519,7 @@ class HooksMaster(object):
     cfg = self.lu.cfg
 
     env = {
-      "PATH": "/sbin:/bin:/usr/sbin:/usr/bin",
+      "PATH": constants.HOOKS_PATH,
       "GANETI_HOOKS_VERSION": constants.HOOKS_VERSION,
       "GANETI_OP_CODE": self.op.OP_ID,
       "GANETI_DATA_DIR": constants.DATA_DIR,