|
|
@ -37,9 +37,7 @@ CODE_HEADER = "#!/bin/sh -e\n" |
|
|
|
class ConfigInstall: |
|
|
|
class ConfigInstall: |
|
|
|
"""Cdist main class to hold arbitrary data""" |
|
|
|
"""Cdist main class to hold arbitrary data""" |
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, target_host, |
|
|
|
def __init__(self, target_host, initial_manifest=False, |
|
|
|
initial_manifest=False, |
|
|
|
|
|
|
|
home=None, |
|
|
|
|
|
|
|
exec_path=sys.argv[0], |
|
|
|
exec_path=sys.argv[0], |
|
|
|
debug=False): |
|
|
|
debug=False): |
|
|
|
|
|
|
|
|
|
|
@ -51,30 +49,11 @@ class ConfigInstall: |
|
|
|
|
|
|
|
|
|
|
|
self.path = cdist.path.Path(self.target_host, |
|
|
|
self.path = cdist.path.Path(self.target_host, |
|
|
|
initial_manifest=initial_manifest, |
|
|
|
initial_manifest=initial_manifest, |
|
|
|
base_dir=home, |
|
|
|
|
|
|
|
debug=debug) |
|
|
|
debug=debug) |
|
|
|
|
|
|
|
|
|
|
|
def cleanup(self): |
|
|
|
def cleanup(self): |
|
|
|
self.path.cleanup() |
|
|
|
self.path.cleanup() |
|
|
|
|
|
|
|
|
|
|
|
def run_global_explorers(self): |
|
|
|
|
|
|
|
"""Run global explorers""" |
|
|
|
|
|
|
|
log.info("Running global explorers") |
|
|
|
|
|
|
|
explorers = self.path.list_global_explorers() |
|
|
|
|
|
|
|
if(len(explorers) == 0): |
|
|
|
|
|
|
|
raise cdist.Error("No explorers found in " + self.path.global_explorer_dir) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.path.transfer_global_explorers() |
|
|
|
|
|
|
|
for explorer in explorers: |
|
|
|
|
|
|
|
output = self.path.global_explorer_output_path(explorer) |
|
|
|
|
|
|
|
output_fd = open(output, mode='w') |
|
|
|
|
|
|
|
cmd = [] |
|
|
|
|
|
|
|
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=True) |
|
|
|
|
|
|
|
output_fd.close() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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""" |
|
|
|
|
|
|
|
|
|
|
@ -102,10 +81,7 @@ class ConfigInstall: |
|
|
|
cdist.exec.run_or_fail(remote_cmd, stdout=output_fd, remote_prefix=True) |
|
|
|
cdist.exec.run_or_fail(remote_cmd, stdout=output_fd, remote_prefix=True) |
|
|
|
output_fd.close() |
|
|
|
output_fd.close() |
|
|
|
|
|
|
|
|
|
|
|
def link_emulator(self): |
|
|
|
|
|
|
|
"""Link emulator to types""" |
|
|
|
|
|
|
|
cdist.emulator.link(self.exec_path, |
|
|
|
|
|
|
|
self.path.bin_dir, self.path.list_types()) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def run_initial_manifest(self): |
|
|
|
def run_initial_manifest(self): |
|
|
|
"""Run the initial manifest""" |
|
|
|
"""Run the initial manifest""" |
|
|
@ -226,6 +202,34 @@ class ConfigInstall: |
|
|
|
cdist.exec.run_or_fail([remote_remote_code], remote_prefix=True) |
|
|
|
cdist.exec.run_or_fail([remote_remote_code], remote_prefix=True) |
|
|
|
|
|
|
|
|
|
|
|
### Cleaned / check functions: Round 1 :-) ################################# |
|
|
|
### Cleaned / check functions: Round 1 :-) ################################# |
|
|
|
|
|
|
|
def link_emulator(self): |
|
|
|
|
|
|
|
"""Link emulator to types""" |
|
|
|
|
|
|
|
src = os.path.abspath(self.exec_path) |
|
|
|
|
|
|
|
for type in cdist.core.Type.list_types(): |
|
|
|
|
|
|
|
log.debug("Linking emulator: %s to %s", source, destination) |
|
|
|
|
|
|
|
dst = os.path.join(self.context.bin_dir, type.name) |
|
|
|
|
|
|
|
# FIXME: handle exception / make it more beautiful |
|
|
|
|
|
|
|
os.symlink(src, dst) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def run_global_explorers(self): |
|
|
|
|
|
|
|
"""Run global explorers""" |
|
|
|
|
|
|
|
log.info("Running global explorers") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src = cdist.core.GlobalExplorer.base_dir |
|
|
|
|
|
|
|
dst = cdist.core.GlobalExplorer.remote_base_dir |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.context.transfer_dir(src, dst) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for explorer in cdist.core.GlobalExplorer.list_explorers(): |
|
|
|
|
|
|
|
output_fd = open(explorer.out_path, mode='w') |
|
|
|
|
|
|
|
cmd = [] |
|
|
|
|
|
|
|
cmd.append("__explorer=" + cdist.core.GlobalExplorer.remote_base_dir) |
|
|
|
|
|
|
|
cmd.append(explorer.remote_path) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cdist.exec.run_or_fail(cmd, stdout=output_fd, remote_prefix=True) |
|
|
|
|
|
|
|
output_fd.close() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def stage_run(self): |
|
|
|
def stage_run(self): |
|
|
|
"""The final (and real) step of deployment""" |
|
|
|
"""The final (and real) step of deployment""" |
|
|
|
log.info("Generating and executing code") |
|
|
|
log.info("Generating and executing code") |
|
|
|