def ssh_exec_script(vm_name, script_path): ssh.vm_scp_to_vm(vm_name, script_path) remote_path = hf.strip_top_dir(conf.top_dir, script_path) logger.info("Start %s", remote_path) script_name = os.path.splitext(os.path.basename(script_path))[0] prefix = host.get_next_prefix(conf.log_dir, "auto") log_name = "{}_{}.auto".format(prefix, script_name) log_path = os.path.join(conf.log_dir, log_name) try: ssh.vm_ssh(vm_name, "bash {} && rm -vf {}".format(remote_path, remote_path), log_file=log_path) except EnvironmentError: logger.error("Script failure: %s", script_name) sys.exit(1) logger.info(" done")
def _autostart_queue(src_rel_path, target_name=None): src_path = join(conf.scripts_dir, src_rel_path) src_name = basename(src_path) if not target_name: target_name = src_name if target_name.endswith(".sh"): prefix = host.get_next_prefix(conf.autostart_dir, "sh", 2) target_name = "{}_{}".format(prefix, target_name) if src_name == target_name: logger.info("\t%s", src_name) else: logger.info("\t%s -> %s", src_name, target_name) from shutil import copyfile copyfile(src_path, join(conf.autostart_dir, target_name)) if conf.wbatch: wbatch.wbatch_cp_auto(src_path, join(conf.autostart_dir, target_name))