From 8af45f83b20bd8a0e48f58eb5e7e9105bc76edda Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 23 Sep 2011 20:53:09 +0200 Subject: [PATCH] rearange remote_user Signed-off-by: Nico Schottelius --- bin/cdist | 17 ----------------- lib/cdist/path.py | 20 ++++++++++---------- 2 files changed, 10 insertions(+), 27 deletions(-) diff --git a/bin/cdist b/bin/cdist index 30fec278..67b96a09 100755 --- a/bin/cdist +++ b/bin/cdist @@ -88,7 +88,6 @@ class Cdist: initial_manifest=False, remote_user="root", home=None, debug=False): self.target_host = target_host - self.remote_prefix = ["ssh", "root@" + self.target_host] self.path = cdist.path.Path(target_host, initial_manifest=initial_manifest, @@ -98,7 +97,6 @@ class Cdist: self.debug = debug - # objects self.objects_prepared = [] self.remote_user = remote_user @@ -109,21 +107,6 @@ class Cdist: def remove_remote_dir(self, destination): self.run_or_fail(["rm", "-rf", destination], remote=True) - def transfer_dir(self, source, destination): - """Transfer directory and previously delete the remote destination""" - self.remove_remote_dir(destination) - self.run_or_fail(["scp", "-qr", source, - self.remote_user + "@" + - self.target_host + ":" + - destination]) - - def transfer_file(self, source, destination): - """Transfer file""" - self.run_or_fail(["scp", "-q", source, - self.remote_user + "@" + - self.target_host + ":" + - destination]) - def global_explorer_output_path(self, explorer): """Returns path of the output for a global explorer""" return os.path.join(self.global_explorer_out_dir, explorer) diff --git a/lib/cdist/path.py b/lib/cdist/path.py index 2050a1a3..1e9d7195 100644 --- a/lib/cdist/path.py +++ b/lib/cdist/path.py @@ -38,6 +38,7 @@ TYPE_PREFIX = "__" logging.basicConfig(level=logging.INFO, format='%(levelname)s: %(message)s') log = logging.getLogger() +import cdist.exec def file_to_list(filename): """Return list from \n seperated file""" @@ -53,9 +54,6 @@ def file_to_list(filename): return lines -# FIXME: self.run_or_fail needs to be elsewhere! -# Exec? - class Path: """Class that handles path related configurations""" @@ -70,6 +68,10 @@ class Path: self.base_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir)) self.temp_dir = tempfile.mkdtemp() + self.target_host = target_host + + self.remote_user = remote_user + self.remote_prefix = ["ssh", self.remote_user + "@" + self.target_host] self.conf_dir = os.path.join(self.base_dir, "conf") self.cache_base_dir = os.path.join(self.base_dir, "cache") @@ -98,8 +100,6 @@ class Path: # objects self.objects_prepared = [] - self.remote_user = remote_user - # Mostly static, but can be overwritten on user demand if initial_manifest: self.initial_manifest = initial_manifest @@ -121,26 +121,26 @@ class Path: def remote_mkdir(self, directory): """Create directory on remote side""" - self.run_or_fail(["mkdir", "-p", directory], remote=True) + cdist.exec.run_or_fail(["mkdir", "-p", directory], remote=True) def remote_cat(filename): """Use cat on the remote side for output""" - self.run_or_fail(["cat", filename], remote=True) + cdist.exec.run_or_fail(["cat", filename], remote=True) def remove_remote_dir(self, destination): - self.run_or_fail(["rm", "-rf", destination], remote=True) + cdist.exec.run_or_fail(["rm", "-rf", destination], remote=True) def transfer_dir(self, source, destination): """Transfer directory and previously delete the remote destination""" self.remove_remote_dir(destination) - self.run_or_fail(["scp", "-qr", source, + cdist.exec.run_or_fail(["scp", "-qr", source, self.remote_user + "@" + self.target_host + ":" + destination]) def transfer_file(self, source, destination): """Transfer file""" - self.run_or_fail(["scp", "-q", source, + cdist.exec.run_or_fail(["scp", "-q", source, self.remote_user + "@" + self.target_host + ":" + destination])