Merge remote-tracking branch 'telmich/master'
This commit is contained in:
commit
80087d4f59
2 changed files with 51 additions and 43 deletions
|
@ -115,6 +115,7 @@ def configinstall(args, mode):
|
||||||
time_start = time.time()
|
time_start = time.time()
|
||||||
|
|
||||||
for host in args.host:
|
for host in args.host:
|
||||||
|
# Setup Local/Remote
|
||||||
context = cdist.context.Context(
|
context = cdist.context.Context(
|
||||||
target_host=host,
|
target_host=host,
|
||||||
initial_manifest=args.manifest,
|
initial_manifest=args.manifest,
|
||||||
|
|
|
@ -67,7 +67,6 @@ class ConfigInstall(object):
|
||||||
# Setup env to be used by others - FIXME
|
# Setup env to be used by others - FIXME
|
||||||
self.__init_env()
|
self.__init_env()
|
||||||
|
|
||||||
|
|
||||||
def __init_remote_paths(self):
|
def __init_remote_paths(self):
|
||||||
"""Initialise remote directory structure"""
|
"""Initialise remote directory structure"""
|
||||||
self.exec_wrapper.remove_remote_path(self.context.remote_base_path)
|
self.exec_wrapper.remove_remote_path(self.context.remote_base_path)
|
||||||
|
@ -85,13 +84,9 @@ class ConfigInstall(object):
|
||||||
os.mkdir(self.context.out_path)
|
os.mkdir(self.context.out_path)
|
||||||
os.mkdir(self.context.bin_path)
|
os.mkdir(self.context.bin_path)
|
||||||
|
|
||||||
# FIXME: remove this function, only expose ENV
|
# os.environ['__target_host'] = self.context.target_host
|
||||||
# explicitly!
|
# if self.context.debug:
|
||||||
def __init_env(self):
|
# os.environ['__debug'] = "yes"
|
||||||
"""Environment usable for other stuff"""
|
|
||||||
os.environ['__target_host'] = self.context.target_host
|
|
||||||
if self.context.debug:
|
|
||||||
os.environ['__debug'] = "yes"
|
|
||||||
|
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
self.log.debug("Saving " + self.context.out_path + " to " + self.context.cache_path)
|
self.log.debug("Saving " + self.context.out_path + " to " + self.context.cache_path)
|
||||||
|
@ -99,6 +94,53 @@ class ConfigInstall(object):
|
||||||
shutil.rmtree(self.context.cache_path)
|
shutil.rmtree(self.context.cache_path)
|
||||||
shutil.move(self.context.out_path, self.context.cache_path)
|
shutil.move(self.context.out_path, self.context.cache_path)
|
||||||
|
|
||||||
|
def deploy_to(self):
|
||||||
|
"""Mimic the old deploy to: Deploy to one host"""
|
||||||
|
self.log.info("Deploying to " + self.context.target_host)
|
||||||
|
self.stage_prepare()
|
||||||
|
self.stage_run()
|
||||||
|
|
||||||
|
def deploy_and_cleanup(self):
|
||||||
|
"""Do what is most often done: deploy & cleanup"""
|
||||||
|
start_time = time.time()
|
||||||
|
self.deploy_to()
|
||||||
|
self.cleanup()
|
||||||
|
self.log.info("Finished run of %s in %s seconds",
|
||||||
|
self.context.target_host, time.time() - start_time)
|
||||||
|
|
||||||
|
def stage_prepare(self):
|
||||||
|
"""Do everything for a deploy, minus the actual code stage"""
|
||||||
|
self.link_emulator()
|
||||||
|
self.global_explorer_run()
|
||||||
|
self.run_initial_manifest()
|
||||||
|
|
||||||
|
self.log.info("Running object manifests and type explorers")
|
||||||
|
|
||||||
|
# Continue process until no new objects are created anymore
|
||||||
|
new_objects_created = True
|
||||||
|
while new_objects_created:
|
||||||
|
new_objects_created = False
|
||||||
|
for cdist_object in cdist.core.Object.list_objects(self.object_base_path,
|
||||||
|
self.context.type_base_path):
|
||||||
|
if cdist_object.prepared:
|
||||||
|
self.log.debug("Skipping rerun of object %s", cdist_object)
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
self.object_prepare(cdist_object)
|
||||||
|
new_objects_created = True
|
||||||
|
|
||||||
|
|
||||||
|
def self.global_explorer_run()
|
||||||
|
"""Run global explorers and save output"""
|
||||||
|
|
||||||
|
output = self.global_explorer.run()
|
||||||
|
|
||||||
|
for explorer in output:
|
||||||
|
outfile = os.path.join(self.context.global_explorer_out_path,
|
||||||
|
explorer)
|
||||||
|
outfile_fd = open(outfile, "w")
|
||||||
|
outfile_fd.write()
|
||||||
|
|
||||||
def object_prepare(self, cdist_object):
|
def object_prepare(self, cdist_object):
|
||||||
"""Prepare object: Run type explorer + manifest"""
|
"""Prepare object: Run type explorer + manifest"""
|
||||||
self.log.debug("Preparing object: " + cdist_object.name)
|
self.log.debug("Preparing object: " + cdist_object.name)
|
||||||
|
@ -186,41 +228,6 @@ class ConfigInstall(object):
|
||||||
# FIXME: handle exception / make it more beautiful / Steven: raise except :-)
|
# FIXME: handle exception / make it more beautiful / Steven: raise except :-)
|
||||||
os.symlink(src, dst)
|
os.symlink(src, dst)
|
||||||
|
|
||||||
def deploy_to(self):
|
|
||||||
"""Mimic the old deploy to: Deploy to one host"""
|
|
||||||
self.log.info("Deploying to " + self.context.target_host)
|
|
||||||
self.stage_prepare()
|
|
||||||
self.stage_run()
|
|
||||||
|
|
||||||
def deploy_and_cleanup(self):
|
|
||||||
"""Do what is most often done: deploy & cleanup"""
|
|
||||||
start_time = time.time()
|
|
||||||
self.deploy_to()
|
|
||||||
self.cleanup()
|
|
||||||
self.log.info("Finished run of %s in %s seconds",
|
|
||||||
self.context.target_host, time.time() - start_time)
|
|
||||||
|
|
||||||
def stage_prepare(self):
|
|
||||||
"""Do everything for a deploy, minus the actual code stage"""
|
|
||||||
self.link_emulator()
|
|
||||||
self.explorer.run_global_explorers()
|
|
||||||
self.run_initial_manifest()
|
|
||||||
|
|
||||||
self.log.info("Running object manifests and type explorers")
|
|
||||||
|
|
||||||
# Continue process until no new objects are created anymore
|
|
||||||
new_objects_created = True
|
|
||||||
while new_objects_created:
|
|
||||||
new_objects_created = False
|
|
||||||
for cdist_object in cdist.core.Object.list_objects(self.object_base_path,
|
|
||||||
self.context.type_base_path):
|
|
||||||
if cdist_object.prepared:
|
|
||||||
self.log.debug("Skipping rerun of object %s", cdist_object)
|
|
||||||
continue
|
|
||||||
else:
|
|
||||||
self.object_prepare(cdist_object)
|
|
||||||
new_objects_created = True
|
|
||||||
|
|
||||||
def stage_run(self):
|
def stage_run(self):
|
||||||
"""The final (and real) step of deployment"""
|
"""The final (and real) step of deployment"""
|
||||||
self.log.info("Generating and executing code")
|
self.log.info("Generating and executing code")
|
||||||
|
|
Loading…
Reference in a new issue