transfer_dir() added

Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
Nico Schottelius 2011-09-08 02:46:09 +02:00
parent 09c58e2327
commit 6e3c228a6f

View file

@ -36,6 +36,7 @@ def exit_error(*args):
def run_or_fail(*args): def run_or_fail(*args):
newargs = ["echo"] newargs = ["echo"]
newargs = []
newargs.extend(*args) newargs.extend(*args)
try: try:
@ -49,6 +50,8 @@ def remote_run_or_fail(hostname, *args):
run_or_fail(newargs) run_or_fail(newargs)
def transfer_dir(hostname, source, destination):
run_or_fail(["scp", "-r", source, hostname + ":" + destination])
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"""
@ -64,17 +67,23 @@ def global_explorer_directory():
"""Returns path to directory containing the global explorers""" """Returns path to directory containing the global explorers"""
return os.path.join(conf_directory(), "explorer") return os.path.join(conf_directory(), "explorer")
def remote_global_explorer_directory():
"""Returns path to directory containing the global explorers"""
return os.path.join(conf_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())
def transfer_global_explorers(hostname):
transfer_dir(hostname, global_explorer_directory(), remote_global_explorer_directory())
def global_explore(hostname): def global_explore(hostname):
"""Run global explorers""" """Run global explorers"""
explorer = list_global_explorers() explorer = list_global_explorers()
if(len(explorer) == 0): if(len(explorer) == 0):
exit_error("No explorers found in", global_explorer_directory()) 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")