use context in explorer

Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
Nico Schottelius 2011-10-11 16:49:50 +02:00
parent ba43212681
commit 588731661e
2 changed files with 13 additions and 23 deletions

View file

@ -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"""

View file

@ -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