forked from ungleich-public/cdist
intermediate commit for cdist state
Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
parent
c8522af0d0
commit
e8f7fe3faa
2 changed files with 29 additions and 21 deletions
|
@ -53,6 +53,9 @@ class ConfigInstall(object):
|
||||||
self.explorer = cdist.explorer.Explorer(self.context)
|
self.explorer = cdist.explorer.Explorer(self.context)
|
||||||
#self.manifest = cdist.manifest.Mamifest()
|
#self.manifest = cdist.manifest.Mamifest()
|
||||||
|
|
||||||
|
self.manifest.initial_manifest()
|
||||||
|
self.manifest.type_manifest(cdist_object)
|
||||||
|
|
||||||
self.log = logging.getLogger(self.context.target_host)
|
self.log = logging.getLogger(self.context.target_host)
|
||||||
|
|
||||||
# Setup env to be used by others - FIXME
|
# Setup env to be used by others - FIXME
|
||||||
|
|
|
@ -40,11 +40,33 @@ class Explorer:
|
||||||
|
|
||||||
def __init__(self, context):
|
def __init__(self, context):
|
||||||
self.context = context
|
self.context = context
|
||||||
|
|
||||||
|
self.global_explorer_path = os.path.join(self.context.conf_path, "explorer")
|
||||||
|
|
||||||
|
self.
|
||||||
|
|
||||||
try:
|
try:
|
||||||
os.mkdir(self.context.global_explorer_out_path)
|
os.mkdir(self.context.global_explorer_out_path)
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
raise cdist.Error("Failed to create explorer out path: %s" % 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):
|
def run_type_explorer(self, cdist_object):
|
||||||
"""Run type specific explorers for objects"""
|
"""Run type specific explorers for objects"""
|
||||||
|
|
||||||
|
@ -52,12 +74,12 @@ class Explorer:
|
||||||
self.transfer_type_explorers(cdist_type)
|
self.transfer_type_explorers(cdist_type)
|
||||||
|
|
||||||
cmd = []
|
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(
|
cmd.append("__type_explorer=" + os.path.join(
|
||||||
self.remote_type_path,
|
self.context.remote_type_path,
|
||||||
cdist_type.explorer_path))
|
cdist_type.explorer_path))
|
||||||
cmd.append("__object=" + os.path.join(
|
cmd.append("__object=" + os.path.join(
|
||||||
self.remote_object_path,
|
self.context.remote_object_path,
|
||||||
cdist_object.path))
|
cdist_object.path))
|
||||||
cmd.append("__object_id=" + cdist_object.object_id)
|
cmd.append("__object_id=" + cdist_object.object_id)
|
||||||
cmd.append("__object_fq=" + cdist_object.name)
|
cmd.append("__object_fq=" + cdist_object.name)
|
||||||
|
@ -67,7 +89,7 @@ class Explorer:
|
||||||
|
|
||||||
outputs = {}
|
outputs = {}
|
||||||
for explorer in cdist_type.explorers:
|
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)]
|
cdist_type.explorer_path, explorer)]
|
||||||
outputs[explorer] = io.StringIO()
|
outputs[explorer] = io.StringIO()
|
||||||
log.debug("%s exploring %s using %s storing to %s",
|
log.debug("%s exploring %s using %s storing to %s",
|
||||||
|
@ -77,23 +99,6 @@ class Explorer:
|
||||||
|
|
||||||
return outputs
|
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):
|
def transfer_object_parameter(self, cdist_object):
|
||||||
"""Transfer the object parameter to the remote destination"""
|
"""Transfer the object parameter to the remote destination"""
|
||||||
src = os.path.join(self.object_base_path,
|
src = os.path.join(self.object_base_path,
|
||||||
|
|
Loading…
Reference in a new issue