intermediate commit for cdist state

Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
Nico Schottelius 2011-10-12 16:59:02 +02:00
parent c8522af0d0
commit e8f7fe3faa
2 changed files with 29 additions and 21 deletions

View file

@ -53,6 +53,9 @@ class ConfigInstall(object):
self.explorer = cdist.explorer.Explorer(self.context)
#self.manifest = cdist.manifest.Mamifest()
self.manifest.initial_manifest()
self.manifest.type_manifest(cdist_object)
self.log = logging.getLogger(self.context.target_host)
# Setup env to be used by others - FIXME

View file

@ -40,11 +40,33 @@ class Explorer:
def __init__(self, context):
self.context = context
self.global_explorer_path = os.path.join(self.context.conf_path, "explorer")
self.
try:
os.mkdir(self.context.global_explorer_out_path)
except OSError as e:
raise cdist.Error("Failed to create explorer out path: %s" % e)
def run_global_explorers(self):
"""Run global explorers"""
log.info("Running global explorers")
src_path = self.context.global_explorer_path
dst_path = self.context.remote_global_explorer_path
self.exec_wrapper.transfer_path(src_path, dst_path)
outputs = {}
for explorer in os.listdir(src_path):
outputs[explorer] = io.StringIO()
cmd = []
cmd.append("__explorer=" + remote_dst_path)
cmd.append(os.path.join(remote_dst_path, explorer))
cdist.exec.run_or_fail(cmd, stdout=outputs[explorer], remote_prefix=True)
def run_type_explorer(self, cdist_object):
"""Run type specific explorers for objects"""
@ -52,12 +74,12 @@ class Explorer:
self.transfer_type_explorers(cdist_type)
cmd = []
cmd.append("__explorer=" + self.remote_global_explorer_path)
cmd.append("__explorer=" + self.context.remote_global_explorer_path)
cmd.append("__type_explorer=" + os.path.join(
self.remote_type_path,
self.context.remote_type_path,
cdist_type.explorer_path))
cmd.append("__object=" + os.path.join(
self.remote_object_path,
self.context.remote_object_path,
cdist_object.path))
cmd.append("__object_id=" + cdist_object.object_id)
cmd.append("__object_fq=" + cdist_object.name)
@ -67,7 +89,7 @@ class Explorer:
outputs = {}
for explorer in cdist_type.explorers:
remote_cmd = cmd + [os.path.join(self.remote_type_path,
remote_cmd = cmd + [os.path.join(self.context.remote_type_path,
cdist_type.explorer_path, explorer)]
outputs[explorer] = io.StringIO()
log.debug("%s exploring %s using %s storing to %s",
@ -77,23 +99,6 @@ class Explorer:
return outputs
def run_global_explorers(self):
"""Run global explorers"""
log.info("Running global explorers")
src_path = self.global_explorer_path
dst_path = self.remote_global_explorer_path
self.transfer_path(src_path, dst_path)
outputs = {}
for explorer in os.listdir(src_path):
outputs[explorer] = io.StringIO()
cmd = []
cmd.append("__explorer=" + remote_dst_path)
cmd.append(os.path.join(remote_dst_path, explorer))
cdist.exec.run_or_fail(cmd, stdout=outputs[explorer], remote_prefix=True)
def transfer_object_parameter(self, cdist_object):
"""Transfer the object parameter to the remote destination"""
src = os.path.join(self.object_base_path,