[Cluster-devel] [PATCH 2/3] fence_amt: sending password over env
Ondrej Mular
omular at redhat.com
Fri Apr 11 11:41:45 UTC 2014
---
fence/agents/amt/fence_amt.py | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/fence/agents/amt/fence_amt.py b/fence/agents/amt/fence_amt.py
index dc2fd12..edab61a 100644
--- a/fence/agents/amt/fence_amt.py
+++ b/fence/agents/amt/fence_amt.py
@@ -1,6 +1,6 @@
#!/usr/bin/python -tt
-import sys, re
+import sys, re, os
import atexit
from pipes import quote
sys.path.append("@FENCEAGENTSLIBDIR@")
@@ -14,7 +14,7 @@ BUILD_DATE=""
#END_VERSION_GENERATION
def get_power_status(_, options):
- output = run_command(options, create_command(options, "status"))
+ output = amt_run_command(options, create_command(options, "status"))
match = re.search('Powerstate:[\\s]*(..)', str(output))
status = match.group(1) if match else None
@@ -26,18 +26,20 @@ def get_power_status(_, options):
return "off"
def set_power_status(_, options):
- run_command(options, create_command(options, options["--action"]))
+ amt_run_command(options, create_command(options, options["--action"]))
return
def reboot_cycle(_, options):
(status, _, _) = run_command(options, create_command(options, "cycle"))
return not bool(status)
-def create_command(options, action):
- # --password / -p
- cmd = "AMT_PASSWORD=" + quote(options["--password"])
+def amt_run_command(options, command, timeout = None):
+ env = os.environ.copy()
+ env["AMT_PASSWORD"] = quote(options["--password"])
+ return run_command(options, command, timeout, env)
- cmd += " " + options["--amttool-path"]
+def create_command(options, action):
+ cmd = options["--amttool-path"]
# --ip / -a
cmd += " " + options["--ip"]
--
1.8.3.1
More information about the Cluster-devel
mailing list