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.core
import cdist.context import cdist.context
import cdist.exec import cdist.exec
import cdist.explorer
#import cdist.manifest
class ConfigInstall(object): class ConfigInstall(object):
"""Cdist main class to hold arbitrary data""" """Cdist main class to hold arbitrary data"""
@ -40,12 +42,11 @@ class ConfigInstall(object):
self.context = context self.context = context
self.exec_wrapper = cdist.exec.Wrapper( self.exec_wrapper = cdist.exec.Wrapper(
targe_host = self.target_host, target_host = self.context.target_host,
remote_exec=os.environ['__remote_exec'].split(), remote_exec=self.context.remote_exec,
remote_copy=os.environ['__remote_copy'].split() remote_copy=self.context.remote_copy)
)
self.explorer = cdist.explorer.Explorer() self.explorer = cdist.explorer.Explorer(self.context)
self.manifest = cdist.manifest.Mamifest() self.manifest = cdist.manifest.Mamifest()
self.log = logging.getLogger(self.context.target_host) self.log = logging.getLogger(self.context.target_host)
@ -79,7 +80,7 @@ class ConfigInstall(object):
# explicitly! # explicitly!
def __init_env(self): def __init_env(self):
"""Environment usable for other stuff""" """Environment usable for other stuff"""
os.environ['__target_host'] = self.target_host os.environ['__target_host'] = self.context.target_host
if self.debug: if self.debug:
os.environ['__debug'] = "yes" os.environ['__debug'] = "yes"
@ -114,7 +115,7 @@ class ConfigInstall(object):
# Setup env Variable: # Setup env Variable:
# #
env = os.environ.copy() env = os.environ.copy()
env['__target_host'] = self.target_host env['__target_host'] = self.context.target_host
env['__global'] = self.out_path env['__global'] = self.out_path
env["__object"] = os.path.join(self.object_base_path, cdist_object.path) env["__object"] = os.path.join(self.object_base_path, cdist_object.path)
env["__object_id"] = cdist_object.object_id env["__object_id"] = cdist_object.object_id
@ -178,7 +179,7 @@ class ConfigInstall(object):
def deploy_to(self): def deploy_to(self):
"""Mimic the old deploy to: Deploy to one host""" """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_prepare()
self.stage_run() self.stage_run()
@ -188,7 +189,7 @@ class ConfigInstall(object):
self.deploy_to() self.deploy_to()
self.cleanup() self.cleanup()
log.info("Finished run of %s in %s seconds", 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): def stage_prepare(self):
"""Do everything for a deploy, minus the actual code stage""" """Do everything for a deploy, minus the actual code stage"""

View file

@ -37,21 +37,10 @@ log = logging.getLogger(__name__)
class Explorer: class Explorer:
"""Execute explorers""" """Execute explorers"""
def __init__(self, def __init__(self, context):
object_base_path, self.context = context
remote_global_explorer_path,
remote_type_path,
remote_object_path,
type_path,
exec_hint):
self.object_base_path = object_base_path def run_type_explorer(self, cdist_object):
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)
"""Run type specific explorers for objects""" """Run type specific explorers for objects"""
cdist_type = cdist_object.type cdist_type = cdist_object.type