Gitweb: http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=92928f5fd... Commit: 92928f5fd7f90805df98d46311a6e99e17ae0fd9 Parent: 95c1e64c75c9ae0410febd9653d6e65b88ff0d88 Author: Ondrej Mular omular@redhat.com AuthorDate: Fri Apr 11 07:41:45 2014 -0400 Committer: Marek 'marx' Grac mgrac@redhat.com CommitterDate: Mon Apr 14 13:55:03 2014 +0200
fence_amt: sending password over env
--- fence/agents/amt/fence_amt.py | 16 +++++++++------- 1 files 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"]