From d76d013b3c280d9641697bffe28441a30b14b107 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 18 Nov 2011 10:39:21 +0100 Subject: [PATCH 1/7] check env [TODO] Signed-off-by: Nico Schottelius --- doc/dev/todo/TAKEME | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/dev/todo/TAKEME b/doc/dev/todo/TAKEME index f424a81d..14a643ea 100644 --- a/doc/dev/todo/TAKEME +++ b/doc/dev/todo/TAKEME @@ -13,6 +13,8 @@ TESTS - multiple defines of object: - fail if different parameters - succeed if same parameters +- verify that all env variables in doc/man/cdist-reference.text.sh + exist in the right stages USER INTERFACE -------------- From df258cf330cb015ac233a09fda0c863190582942 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 18 Nov 2011 11:10:32 +0100 Subject: [PATCH 2/7] +__target_user comment Signed-off-by: Nico Schottelius --- doc/dev/todo/TAKEME | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/dev/todo/TAKEME b/doc/dev/todo/TAKEME index 14a643ea..de043a07 100644 --- a/doc/dev/todo/TAKEME +++ b/doc/dev/todo/TAKEME @@ -16,6 +16,8 @@ TESTS - verify that all env variables in doc/man/cdist-reference.text.sh exist in the right stages + __target_user - unneeded? + USER INTERFACE -------------- - add support $__tmp? From 7c8f9e8b9873f5324eff0cbe8d8b00b80136c018 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 18 Nov 2011 14:05:26 +0100 Subject: [PATCH 3/7] remove reference to __target_user - has never been used and is not implemented anymore Signed-off-by: Nico Schottelius --- doc/dev/todo/TAKEME | 2 -- doc/man/cdist-reference.text.sh | 3 --- 2 files changed, 5 deletions(-) diff --git a/doc/dev/todo/TAKEME b/doc/dev/todo/TAKEME index de043a07..14a643ea 100644 --- a/doc/dev/todo/TAKEME +++ b/doc/dev/todo/TAKEME @@ -16,8 +16,6 @@ TESTS - verify that all env variables in doc/man/cdist-reference.text.sh exist in the right stages - __target_user - unneeded? - USER INTERFACE -------------- - add support $__tmp? diff --git a/doc/man/cdist-reference.text.sh b/doc/man/cdist-reference.text.sh index 9127096c..0a7b551e 100755 --- a/doc/man/cdist-reference.text.sh +++ b/doc/man/cdist-reference.text.sh @@ -188,9 +188,6 @@ __object_name:: __target_host:: The host we are deploying to. Available for: initial manifest, type manifest, type gencode -__target_user:: - User to use for authentication on remote host. - Currently static in core. __type:: Path to the current type. Available for: type manifest, type gencode From 31403722ce240e9a42518639987eaa80b4afdf25 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Fri, 18 Nov 2011 14:36:51 +0100 Subject: [PATCH 4/7] todo++ Signed-off-by: Steven Armstrong --- doc/dev/todo/TAKEME | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/dev/todo/TAKEME b/doc/dev/todo/TAKEME index 14a643ea..be76b040 100644 --- a/doc/dev/todo/TAKEME +++ b/doc/dev/todo/TAKEME @@ -15,6 +15,8 @@ TESTS - succeed if same parameters - verify that all env variables in doc/man/cdist-reference.text.sh exist in the right stages +- test DependencyResolver + USER INTERFACE -------------- From 654e19f28bf1d78b84d30bf3b616c4e75c2b258d Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Fri, 18 Nov 2011 14:40:25 +0100 Subject: [PATCH 5/7] mark _run_command as private Signed-off-by: Steven Armstrong --- conf/type/__file/gencode-local | 2 -- lib/cdist/exec/remote.py | 6 +++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/conf/type/__file/gencode-local b/conf/type/__file/gencode-local index ae8625b5..0c6c249d 100755 --- a/conf/type/__file/gencode-local +++ b/conf/type/__file/gencode-local @@ -31,8 +31,6 @@ if [ -f "$__object/parameter/source" ]; then remote_cksum="$(cat "$__object/explorer/cksum")" if [ "$local_cksum" != "$remote_cksum" ]; then - # Export target_host so remote_copy script has access to it - echo "export __target_host=\"$__target_host\"" echo "$__remote_copy" "$source" "${__target_host}:${destination}" fi else diff --git a/lib/cdist/exec/remote.py b/lib/cdist/exec/remote.py index 433f4cbc..87db7273 100644 --- a/lib/cdist/exec/remote.py +++ b/lib/cdist/exec/remote.py @@ -91,7 +91,7 @@ class Remote(object): self.rmdir(destination) command = self._copy.split() command.extend(["-r", source, self.target_host + ":" + destination]) - self.run_command(command) + self._run_command(command) def run(self, command, env=None, return_output=False): """Run the given command with the given environment on the remote side. @@ -102,9 +102,9 @@ class Remote(object): cmd = self._exec.split() cmd.append(self.target_host) cmd.extend(command) - return self.run_command(cmd, env=env, return_output=return_output) + return self._run_command(cmd, env=env, return_output=return_output) - def run_command(self, command, env=None, return_output=False): + def _run_command(self, command, env=None, return_output=False): """Run the given command with the given environment. Return the output as a string. From 98dec302a603c599a9300f0259166854e96d32d1 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Fri, 18 Nov 2011 14:44:32 +0100 Subject: [PATCH 6/7] export __target_host for use in __remote_{copy,exec} scripts Signed-off-by: Steven Armstrong --- lib/cdist/exec/local.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/cdist/exec/local.py b/lib/cdist/exec/local.py index 41094faa..0b67c747 100644 --- a/lib/cdist/exec/local.py +++ b/lib/cdist/exec/local.py @@ -95,6 +95,12 @@ class Local(object): """ assert isinstance(command, (list, tuple)), "list or tuple argument expected, got: %s" % command self.log.debug("Local run: %s", command) + + if env is None: + env = {} + # Export __target_host for use in __remote_{copy,exec} scripts + env['__target_host'] = self.target_host + try: if return_output: return subprocess.check_output(command, env=env).decode() @@ -114,8 +120,13 @@ class Local(object): command.append(script) self.log.debug("Local run script: %s", command) - if env: - self.log.debug("Local run script env: %s", env) + + if env is None: + env = {} + # Export __target_host for use in __remote_{copy,exec} scripts + env['__target_host'] = self.target_host + + self.log.debug("Local run script env: %s", env) try: if return_output: From bf133253039a409479463902cb2c9fb74ceb59e0 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Fri, 18 Nov 2011 14:56:59 +0100 Subject: [PATCH 7/7] if env is not given, os.environ is used -> need to also do that Signed-off-by: Steven Armstrong --- lib/cdist/exec/local.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/cdist/exec/local.py b/lib/cdist/exec/local.py index 0b67c747..613f5cf2 100644 --- a/lib/cdist/exec/local.py +++ b/lib/cdist/exec/local.py @@ -97,7 +97,7 @@ class Local(object): self.log.debug("Local run: %s", command) if env is None: - env = {} + env = os.environ.copy() # Export __target_host for use in __remote_{copy,exec} scripts env['__target_host'] = self.target_host @@ -122,7 +122,7 @@ class Local(object): self.log.debug("Local run script: %s", command) if env is None: - env = {} + env = os.environ.copy() # Export __target_host for use in __remote_{copy,exec} scripts env['__target_host'] = self.target_host