executing explorers works
Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
parent
ef925714d5
commit
85df71c9fa
1 changed files with 13 additions and 5 deletions
18
bin/cdist
18
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")
|
||||
|
|
Loading…
Reference in a new issue