From 8298bb0bf5b8e19ee1188fdef89f08e43f8c85ea Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 19 Aug 2013 11:33:44 +0200 Subject: [PATCH] fix test cdist.test.config_install.ConfigInstallRunTestCase Signed-off-by: Nico Schottelius --- cdist/config_install.py | 1 - cdist/exec/remote.py | 12 ++++++++++-- cdist/test/config_install/__init__.py | 22 +++++++++++----------- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/cdist/config_install.py b/cdist/config_install.py index c7f141dd..2db4c4af 100644 --- a/cdist/config_install.py +++ b/cdist/config_install.py @@ -117,7 +117,6 @@ class ConfigInstall(object): try: local = cdist.exec.local.Local( target_host=host, - exec_path=sys.argv[0], initial_manifest=args.manifest, out_path=args.out_path, add_conf_dirs=args.conf_dir) diff --git a/cdist/exec/remote.py b/cdist/exec/remote.py index 647474fa..01f028a9 100644 --- a/cdist/exec/remote.py +++ b/cdist/exec/remote.py @@ -43,12 +43,20 @@ class Remote(object): Directly accessing the remote side from python code is a bug. """ - def __init__(self, target_host, remote_exec, remote_copy): + def __init__(self, + target_host, + remote_exec, + remote_copy, + base_path=None): self.target_host = target_host - self.base_path = os.environ.get('__cdist_remote_out_dir', "/var/lib/cdist") self._exec = remote_exec self._copy = remote_copy + if base_path: + self.base_path = base_path + else: + self.base_path = "/var/lib/cdist" + self.conf_path = os.path.join(self.base_path, "conf") self.object_path = os.path.join(self.base_path, "object") diff --git a/cdist/test/config_install/__init__.py b/cdist/test/config_install/__init__.py index b8daf4f8..4047abe4 100644 --- a/cdist/test/config_install/__init__.py +++ b/cdist/test/config_install/__init__.py @@ -27,7 +27,6 @@ from cdist import test from cdist import core import cdist -import cdist.context import cdist.config import cdist.core.cdist_type import cdist.core.cdist_object @@ -49,22 +48,23 @@ class ConfigInstallRunTestCase(test.CdistTestCase): self.temp_dir = self.mkdtemp() self.out_dir = os.path.join(self.temp_dir, "out") - self.remote_out_dir = os.path.join(self.temp_dir, "remote") + os.mkdir(self.out_dir) + self.local = cdist.exec.local.Local( + target_host=self.target_host, + out_path=self.out_dir) - os.environ['__cdist_out_dir'] = self.out_dir - os.environ['__cdist_remote_out_dir'] = self.remote_out_dir - - self.context = cdist.context.Context( + self.remote_dir = os.path.join(self.temp_dir, "remote") + os.mkdir(self.remote_dir) + self.remote = cdist.exec.remote.Remote( target_host=self.target_host, remote_copy=self.remote_copy, remote_exec=self.remote_exec, - exec_path=test.cdist_exec_path, - debug=True) + base_path=self.remote_dir) - self.context.local.object_path = object_base_path - self.context.local.type_path = type_base_path + self.local.object_path = object_base_path + self.local.type_path = type_base_path - self.config = cdist.config.Config(self.context) + self.config = cdist.config.Config(self.local, self.remote) self.objects = list(core.CdistObject.list_objects(object_base_path, type_base_path)) self.object_index = dict((o.name, o) for o in self.objects)