forked from ungleich-public/cdist
exit, if there are no global explorers
Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
parent
11750515e1
commit
09c58e2327
1 changed files with 16 additions and 10 deletions
26
bin/cdist
26
bin/cdist
|
@ -30,7 +30,7 @@ def logger(type, *args):
|
||||||
print(*args)
|
print(*args)
|
||||||
|
|
||||||
def exit_error(*args):
|
def exit_error(*args):
|
||||||
logger(*args)
|
logger("error", *args)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
@ -50,13 +50,9 @@ def remote_run_or_fail(hostname, *args):
|
||||||
run_or_fail(newargs)
|
run_or_fail(newargs)
|
||||||
|
|
||||||
|
|
||||||
def cdist_deploy_to(hostname):
|
|
||||||
"""Mimic the old deploy to: Deploy to one host"""
|
|
||||||
logger("info", "Deploying to host", hostname)
|
|
||||||
init_deploy(hostname)
|
|
||||||
|
|
||||||
def base_directory():
|
def base_directory():
|
||||||
"""Returns the directory in which all cdist stuff is based in"""
|
"""Returns the directory in which all cdist stuff is based in"""
|
||||||
|
print("Going to", __file__, os.path.join(os.path.dirname(__file__), os.pardir))
|
||||||
os.chdir(os.path.join(os.path.dirname(__file__), os.pardir))
|
os.chdir(os.path.join(os.path.dirname(__file__), os.pardir))
|
||||||
return os.getcwd()
|
return os.getcwd()
|
||||||
|
|
||||||
|
@ -70,10 +66,14 @@ def global_explorer_directory():
|
||||||
|
|
||||||
def list_global_explorers():
|
def list_global_explorers():
|
||||||
"""Return list of available explorers"""
|
"""Return list of available explorers"""
|
||||||
os.listdir(path=global_explorer_directory())
|
return os.listdir(global_explorer_directory())
|
||||||
|
|
||||||
def explore(hostname, type=''):
|
def global_explore(hostname):
|
||||||
"""Run explorers"""
|
"""Run global explorers"""
|
||||||
|
explorer = list_global_explorers()
|
||||||
|
if(len(explorer) == 0):
|
||||||
|
exit_error("No explorers found in", global_explorer_directory())
|
||||||
|
|
||||||
|
|
||||||
def init_deploy(hostname):
|
def init_deploy(hostname):
|
||||||
logger("info", "Creating clean directory structure")
|
logger("info", "Creating clean directory structure")
|
||||||
|
@ -90,10 +90,16 @@ def init_deploy(hostname):
|
||||||
# Link configuraion source directory - consistent with remote
|
# Link configuraion source directory - consistent with remote
|
||||||
run_or_fail(["ln -sf", "$__cdist_conf_dir", "$__cdist_local_base_dir/$__cdist_name_conf_dir"])
|
run_or_fail(["ln -sf", "$__cdist_conf_dir", "$__cdist_local_base_dir/$__cdist_name_conf_dir"])
|
||||||
|
|
||||||
|
def cdist_deploy_to(hostname):
|
||||||
|
"""Mimic the old deploy to: Deploy to one host"""
|
||||||
|
logger("info", "Deploying to host", hostname)
|
||||||
|
init_deploy(hostname)
|
||||||
|
global_explore(hostname)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
hostname=sys.argv[1]
|
hostname=sys.argv[1]
|
||||||
logger("info", "cdist", __cdist_version, ": Configuring host", hostname)
|
logger("info", "cdist", __cdist_version, ": Configuring host", hostname)
|
||||||
cdist_deploy_to(hostname)
|
cdist_deploy_to(hostname)
|
||||||
print(global_explorer_directory())
|
print(list_global_explorers())
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue