From c81a2925b87d2654d4db7447900959cd8c31c609 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 10 Oct 2011 15:38:38 +0200 Subject: [PATCH] accept exec_path, setup__target_host Signed-off-by: Nico Schottelius --- lib/cdist/config_install.py | 15 +++++++++++---- lib/cdist/exec.py | 4 ++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/cdist/config_install.py b/lib/cdist/config_install.py index 0da820b2..6191b118 100644 --- a/lib/cdist/config_install.py +++ b/lib/cdist/config_install.py @@ -38,13 +38,21 @@ CODE_HEADER = "#!/bin/sh -e\n" class ConfigInstall: """Cdist main class to hold arbitrary data""" - def __init__(self, target_host, - initial_manifest=False, base_path=False, debug=False): + def __init__(self, + target_host, + initial_manifest=False, + base_path=False, + exec_path=sys.argv[0], + debug=False): self.target_host = target_host + # FIXME: should this be setup here? + os.environ['__target_host'] = self.target_host self.debug = debug - self.exec_path = sys.argv[0] + + # Required for testing + self.exec_path = exec_path # Base and Temp Base if base_path: @@ -55,7 +63,6 @@ class ConfigInstall: os.pardir, os.pardir)) - # Local input self.cache_path = os.path.join(self.base_path, "cache", self.target_host) diff --git a/lib/cdist/exec.py b/lib/cdist/exec.py index a9b8d147..63a3dfa3 100644 --- a/lib/cdist/exec.py +++ b/lib/cdist/exec.py @@ -34,7 +34,7 @@ def shell_run_or_debug_fail(script, *args, remote_prefix=False, **kargs): if remote_prefix: remote_prefix = os.environ['__remote_exec'].split() - remote_prefix.append(os.environ['target_host']) + remote_prefix.append(os.environ['__target_host']) args[0][:0] = remote_prefix log.debug("Shell exec cmd: %s", args) @@ -65,7 +65,7 @@ def shell_run_or_debug_fail(script, *args, remote_prefix=False, **kargs): def run_or_fail(*args, remote_prefix=False, **kargs): if remote_prefix: remote_prefix = os.environ['__remote_exec'].split() - remote_prefix.append(os.environ['target_host']) + remote_prefix.append(os.environ['__target_host']) args[0][:0] = remote_prefix log.debug("Exec: " + " ".join(*args))