From 588731661e8a2f13effe29daaa65382de2d3edd4 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 11 Oct 2011 16:49:50 +0200 Subject: [PATCH] use context in explorer Signed-off-by: Nico Schottelius --- lib/cdist/config_install.py | 19 ++++++++++--------- lib/cdist/explorer.py | 17 +++-------------- 2 files changed, 13 insertions(+), 23 deletions(-) diff --git a/lib/cdist/config_install.py b/lib/cdist/config_install.py index cb903a93..2a1c828d 100644 --- a/lib/cdist/config_install.py +++ b/lib/cdist/config_install.py @@ -31,6 +31,8 @@ import time import cdist.core import cdist.context import cdist.exec +import cdist.explorer +#import cdist.manifest class ConfigInstall(object): """Cdist main class to hold arbitrary data""" @@ -40,12 +42,11 @@ class ConfigInstall(object): self.context = context self.exec_wrapper = cdist.exec.Wrapper( - targe_host = self.target_host, - remote_exec=os.environ['__remote_exec'].split(), - remote_copy=os.environ['__remote_copy'].split() - ) + target_host = self.context.target_host, + remote_exec=self.context.remote_exec, + remote_copy=self.context.remote_copy) - self.explorer = cdist.explorer.Explorer() + self.explorer = cdist.explorer.Explorer(self.context) self.manifest = cdist.manifest.Mamifest() self.log = logging.getLogger(self.context.target_host) @@ -79,7 +80,7 @@ class ConfigInstall(object): # explicitly! def __init_env(self): """Environment usable for other stuff""" - os.environ['__target_host'] = self.target_host + os.environ['__target_host'] = self.context.target_host if self.debug: os.environ['__debug'] = "yes" @@ -114,7 +115,7 @@ class ConfigInstall(object): # Setup env Variable: # env = os.environ.copy() - env['__target_host'] = self.target_host + env['__target_host'] = self.context.target_host env['__global'] = self.out_path env["__object"] = os.path.join(self.object_base_path, cdist_object.path) env["__object_id"] = cdist_object.object_id @@ -178,7 +179,7 @@ class ConfigInstall(object): def deploy_to(self): """Mimic the old deploy to: Deploy to one host""" - log.info("Deploying to " + self.target_host) + log.info("Deploying to " + self.context.target_host) self.stage_prepare() self.stage_run() @@ -188,7 +189,7 @@ class ConfigInstall(object): self.deploy_to() self.cleanup() log.info("Finished run of %s in %s seconds", - self.target_host, time.time() - start_time) + self.context.target_host, time.time() - start_time) def stage_prepare(self): """Do everything for a deploy, minus the actual code stage""" diff --git a/lib/cdist/explorer.py b/lib/cdist/explorer.py index e2c41f8a..b0db60bc 100644 --- a/lib/cdist/explorer.py +++ b/lib/cdist/explorer.py @@ -37,21 +37,10 @@ log = logging.getLogger(__name__) class Explorer: """Execute explorers""" - def __init__(self, - object_base_path, - remote_global_explorer_path, - remote_type_path, - remote_object_path, - type_path, - exec_hint): + def __init__(self, context): + self.context = context - self.object_base_path = object_base_path - self.remote_global_explorer_path = remote_global_explorer_path - self.remote_type_path = remote_type_path - self.remote_object_path = remote_object_path - self.exec_hint = exec_hint - - def run_type_explorer(self, cdist_object) + def run_type_explorer(self, cdist_object): """Run type specific explorers for objects""" cdist_type = cdist_object.type