forked from ungleich-public/cdist
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)
|
print(*args)
|
||||||
|
|
||||||
def exit_error(*args):
|
def exit_error(*args):
|
||||||
logger("error", *args)
|
logger("error", args)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
def run_or_fail(*args):
|
def run_or_fail(*args):
|
||||||
newargs = ["echo"]
|
# newargs = ["echo"]
|
||||||
newargs = []
|
newargs = []
|
||||||
newargs.extend(*args)
|
newargs.extend(*args)
|
||||||
|
print(newargs)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
subprocess.check_call(newargs)
|
subprocess.check_call(newargs)
|
||||||
|
@ -45,9 +46,9 @@ def run_or_fail(*args):
|
||||||
exit_error("Command failed:", newargs)
|
exit_error("Command failed:", newargs)
|
||||||
|
|
||||||
def remote_run_or_fail(hostname, *args):
|
def remote_run_or_fail(hostname, *args):
|
||||||
|
"""Run something on the remote side and fail is something breaks"""
|
||||||
newargs = ["ssh", "root@" + hostname]
|
newargs = ["ssh", "root@" + hostname]
|
||||||
newargs.extend(*args)
|
newargs.extend(*args)
|
||||||
|
|
||||||
run_or_fail(newargs)
|
run_or_fail(newargs)
|
||||||
|
|
||||||
def remove_remote_dir(hostname, destination):
|
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"""
|
"""Returns path to the remote directory containing the global explorers"""
|
||||||
return os.path.join(remote_conf_directory(), "explorer")
|
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():
|
def list_global_explorers():
|
||||||
"""Return list of available explorers"""
|
"""Return list of available explorers"""
|
||||||
return os.listdir(global_explorer_directory())
|
return os.listdir(global_explorer_directory())
|
||||||
|
@ -91,11 +96,14 @@ def transfer_global_explorers(hostname):
|
||||||
|
|
||||||
def global_explore(hostname):
|
def global_explore(hostname):
|
||||||
"""Run global explorers"""
|
"""Run global explorers"""
|
||||||
explorer = list_global_explorers()
|
explorers = list_global_explorers()
|
||||||
if(len(explorer) == 0):
|
if(len(explorers) == 0):
|
||||||
exit_error("No explorers found in", global_explorer_directory())
|
exit_error("No explorers found in", global_explorer_directory())
|
||||||
|
|
||||||
transfer_global_explorers(hostname)
|
transfer_global_explorers(hostname)
|
||||||
|
for explorer in explorers:
|
||||||
|
remote_run_or_fail(hostname, [remote_global_explorer_path(explorer)])
|
||||||
|
|
||||||
|
|
||||||
def init_deploy(hostname):
|
def init_deploy(hostname):
|
||||||
logger("info", "Creating clean directory structure")
|
logger("info", "Creating clean directory structure")
|
||||||
|
|
Loading…
Reference in a new issue