From 0197f8da13ffdff8103a1a35c118f82ffca6968e Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 26 Sep 2011 11:25:22 +0200 Subject: [PATCH] more cleanups from refactoring Signed-off-by: Nico Schottelius --- bin/cdist | 5 +++-- lib/cdist/path.py | 17 +++++++++-------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/bin/cdist b/bin/cdist index 3b19e388..f511d78e 100755 --- a/bin/cdist +++ b/bin/cdist @@ -35,6 +35,7 @@ import tempfile log = logging.getLogger(__name__) TYPE_PREFIX = "__" +CODE_HEADER = "#!/bin/sh -e\n" class Cdist: """Cdist main class to hold arbitrary data""" @@ -102,7 +103,7 @@ class Cdist: log.debug("%s exploring %s using %s storing to %s", cdist_object, explorer, remote_cmd, output) - self.run_or_fail(remote_cmd, stdout=output_fd, remote_prefix=self.remote_prefix) + cdist.exec.run_or_fail(remote_cmd, stdout=output_fd, remote_prefix=self.remote_prefix) output_fd.close() def init_deploy(self): @@ -240,7 +241,7 @@ class Cdist: self.run_initial_manifest() old_objects = [] - objects = self.list_objects() + objects = self.path.list_objects() # Continue process until no new objects are created anymore while old_objects != objects: diff --git a/lib/cdist/path.py b/lib/cdist/path.py index 16aa51ea..0fa753a8 100644 --- a/lib/cdist/path.py +++ b/lib/cdist/path.py @@ -21,6 +21,7 @@ import logging import os +import shutil import sys import tempfile @@ -31,7 +32,6 @@ REMOTE_OBJECT_DIR = os.path.join(REMOTE_BASE_DIR, "object") REMOTE_TYPE_DIR = os.path.join(REMOTE_CONF_DIR, "type") REMOTE_GLOBAL_EXPLORER_DIR = os.path.join(REMOTE_CONF_DIR, "explorer") -CODE_HEADER = "#!/bin/sh -e\n" DOT_CDIST = ".cdist" log = logging.getLogger(__name__) @@ -55,9 +55,13 @@ def file_to_list(filename): class Path: """Class that handles path related configurations""" - def __init__(self, target_host, - initial_manifest=False, remote_user="root", - remote_prefix=False, base_dir=None, debug=False): + def __init__(self, + target_host, + remote_user, + remote_prefix, + initial_manifest=False, + base_dir=None, + debug=False): # Base and Temp Base if base_dir: @@ -69,10 +73,7 @@ class Path: self.target_host = target_host self.remote_user = remote_user - if remote_prefix: - self.remote_prefix = remote_prefix - else: - self.remote_prefix = ["ssh", self.remote_user + "@" + self.target_host] + self.remote_prefix = remote_prefix self.conf_dir = os.path.join(self.base_dir, "conf") self.cache_base_dir = os.path.join(self.base_dir, "cache")