From 85df71c9fa511b583076d500df25ab6cf384dc81 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 8 Sep 2011 03:23:18 +0200 Subject: [PATCH] executing explorers works Signed-off-by: Nico Schottelius --- bin/cdist | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/bin/cdist b/bin/cdist index 7d28d112..d2a0abd9 100755 --- a/bin/cdist +++ b/bin/cdist @@ -30,14 +30,15 @@ def logger(type, *args): print(*args) def exit_error(*args): - logger("error", *args) + logger("error", args) sys.exit(1) def run_or_fail(*args): - newargs = ["echo"] + # newargs = ["echo"] newargs = [] newargs.extend(*args) + print(newargs) try: subprocess.check_call(newargs) @@ -45,9 +46,9 @@ def run_or_fail(*args): exit_error("Command failed:", newargs) def remote_run_or_fail(hostname, *args): + """Run something on the remote side and fail is something breaks""" newargs = ["ssh", "root@" + hostname] newargs.extend(*args) - run_or_fail(newargs) def remove_remote_dir(hostname, destination): @@ -82,6 +83,10 @@ def remote_global_explorer_directory(): """Returns path to the remote directory containing the global explorers""" return os.path.join(remote_conf_directory(), "explorer") +def remote_global_explorer_path(explorer): + """Returns path to the remote explorer""" + return os.path.join(remote_global_explorer_directory(), explorer) + def list_global_explorers(): """Return list of available explorers""" return os.listdir(global_explorer_directory()) @@ -91,11 +96,14 @@ def transfer_global_explorers(hostname): def global_explore(hostname): """Run global explorers""" - explorer = list_global_explorers() - if(len(explorer) == 0): + explorers = list_global_explorers() + if(len(explorers) == 0): exit_error("No explorers found in", global_explorer_directory()) transfer_global_explorers(hostname) + for explorer in explorers: + remote_run_or_fail(hostname, [remote_global_explorer_path(explorer)]) + def init_deploy(hostname): logger("info", "Creating clean directory structure")