commit previously missed change

Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
Nico Schottelius 2011-10-06 16:52:56 +02:00
parent 54fb9e6c3f
commit 1c8a143397

View file

@ -34,27 +34,22 @@ log = logging.getLogger(__name__)
CODE_HEADER = "#!/bin/sh -e\n"
class ConfigInstall:
"""Class to hold install and config methods"""
"""Cdist main class to hold arbitrary data"""
def __init__(self, target_host,
initial_manifest=False,
remote_user="root",
home=None,
exec_path=sys.argv[0],
debug=False):
self.target_host = target_host
self.debug = debug
self.remote_user = remote_user
self.exec_path = exec_path
os.environ['target_host'] = target_host
# FIXME: broken - construct elsewhere!
self.remote_prefix = ["ssh", self.remote_user + "@" + self.target_host]
self.debug = debug
self.exec_path = exec_path
self.path = cdist.path.Path(self.target_host,
initial_manifest=initial_manifest,
remote_user=self.remote_user,
remote_prefix=self.remote_prefix,
base_dir=home,
debug=debug)
@ -63,12 +58,12 @@ class ConfigInstall:
def cleanup(self):
self.path.cleanup()
def run_global_explorers(self):
def run_global_explores(self):
"""Run global explorers"""
log.info("Running global explorers")
explorers = self.path.list_global_explorers()
if(len(explorers) == 0):
raise CdistError("No explorers found in ", self.path.global_explorer_dir)
raise CdistError("No explorers found in", self.path.global_explorer_dir)
self.path.transfer_global_explorers()
for explorer in explorers:
@ -78,10 +73,9 @@ class ConfigInstall:
cmd.append("__explorer=" + cdist.path.REMOTE_GLOBAL_EXPLORER_DIR)
cmd.append(self.path.remote_global_explorer_path(explorer))
cdist.exec.run_or_fail(cmd, stdout=output_fd, remote_prefix=self.remote_prefix)
cdist.exec.run_or_fail(cmd, stdout=output_fd, remote_prefix=True)
output_fd.close()
# FIXME: where to call this from?
def run_type_explorer(self, cdist_object):
"""Run type specific explorers for objects"""
@ -98,7 +92,6 @@ class ConfigInstall:
# Need to transfer at least the parameters for objects to be useful
self.path.transfer_object_parameter(cdist_object)
# FIXME: Broken due to refactoring into type.py
explorers = self.path.list_type_explorers(type)
for explorer in explorers:
remote_cmd = cmd + [os.path.join(self.path.remote_type_explorer_dir(type), explorer)]
@ -107,7 +100,7 @@ class ConfigInstall:
log.debug("%s exploring %s using %s storing to %s",
cdist_object, explorer, remote_cmd, output)
cdist.exec.run_or_fail(remote_cmd, stdout=output_fd, remote_prefix=self.remote_prefix)
cdist.exec.run_or_fail(remote_cmd, stdout=output_fd, remote_prefix=True)
output_fd.close()
def link_emulator(self):
@ -205,7 +198,6 @@ class ConfigInstall:
outfile_fd = open(outfile, "w")
# Need to flush to ensure our write is done before stdout write
# FIXME: CODE_HEADER needed in our sh -e scenario?
outfile_fd.write(CODE_HEADER)
outfile_fd.flush()
@ -238,13 +230,12 @@ class ConfigInstall:
remote_remote_code = os.path.join(remote_dir, "code-remote")
if os.path.isfile(local_remote_code):
self.path.transfer_file(local_remote_code, remote_remote_code)
# FIXME: remote_prefix
cdist.exec.run_or_fail([remote_remote_code], remote_prefix=self.remote_prefix)
cdist.exec.run_or_fail([remote_remote_code], remote_prefix=True)
def stage_prepare(self):
"""Do everything for a deploy, minus the actual code stage"""
self.init_deploy()
self.run_global_explorers()
self.run_global_explores()
self.run_initial_manifest()
log.info("Running object manifests and type explorers")
@ -260,17 +251,6 @@ class ConfigInstall:
log.debug("Skipping rerun of object %s", cdist_object)
continue
else:
# FIXME: run_type_explorer:
# object can return type
# type has explorers
# path knows about where to save explorer output
# type = self.path.objects[object].type()
# self.path.types['type'].explorers()
# for explorer in explorers:
# output = cdist.exec.run_debug_or_fail_shell(explorer)
# if output:
# write_output_to(output, os.path.join(self.path.objects[object].explorer_dir(),explorer) )
#
self.run_type_explorer(cdist_object)
self.run_type_manifest(cdist_object)
self.objects_prepared.append(cdist_object)
@ -299,8 +279,3 @@ class ConfigInstall:
log.info("Finished run of %s in %s seconds",
self.target_host,
duration.total_seconds())
def deploy_and_cleanup(self):
"""Do what is most often done: deploy & cleanup"""
self.deploy_to()
self.cleanup()