def exit_on_error(error_text): colorprint.error(error_text) colorprint.error( "\nIf you want to cleanup your runway installation, run " "'{}'".format(os.path.join(RUNWAY_DIR, "bin", "cleanup_runway.sh")) ) sys.exit(1)
def exit_with_error(error_text): colorprint.error(error_text) sys.exit(1)
no_snap = no_install or \ man.get_config_option('no_snapshot') # starting from a base image doesn't work if the base image # has fewer drives than the current manifest you're loading run_command( "./make_base_container.py " "{} {} {} {} {}".format(distro, container_name, vol_size, vol_count, base_image), RUNWAY_DIR) setup_and_run_ansible_on_guest.setup_and_run_ansible( container_name, debug=debug, drive_count=vol_count, tiny_install=tiny_deploy) if not no_install: run_command("./generic_installer.py {}".format(container_name), RUNWAY_DIR) if not no_snap: run_command( "./snapshot_created_container.sh " "{} {}{}".format(container_name, base_image, debug_string), RUNWAY_DIR) except Exception as e: colorprint.error(str(e)) sys.exit(1) colorprint.success("Container '{}' successfully " "created.\n".format(container_name))
def retrieve_components(self): logfile_path = os.path.abspath( os.path.join(self.workspace_dir, DOWNLOAD_LOG_FILE_NAME)) for section in self.sections: colorprint.info("Getting {}...".format(section), logfile_path) section_options = self.components_options[section] dest_path = self.get_absolute_dest_path_for_section(section) component_exists = os.path.isdir(dest_path) # Run any needed command BEFORE cloning if not component_exists and "pre_cmd" in section_options: run_command( section_options["pre_cmd"], cwd=self.workspace_dir, logfile_path=logfile_path, ) if not section_options["local"]: if not component_exists: self.git_clone_component(section, logfile_path=logfile_path) # Git checkout + pull in case "sha" or "tag" option is present # or if the component directory already existed. if (component_exists or "sha" in section_options or "tag" in section_options): self.git_checkout_and_pull_component( section, dest_path, logfile_path=logfile_path) self.git_submodule_update(dest_path, logfile_path=logfile_path) current_sha = self.get_current_sha(dest_path) if current_sha: colorprint.normal( "Using SHA {} for {}\n".format(current_sha, section), logfile_path, ) else: colorprint.error( "Couldn't get the SHA for the current commit. The SHA is only " "printed for informational purposes, but not being able to " "get it might be a symptom of something bad happening.\n" ) else: if not component_exists: colorprint.warning( "Component '{}' has been marked as " "local, but it doesn't exist. You'll " "most probably want to add it before " "doing anything else.".format(section), logfile_path, ) else: colorprint.normal( "Component '{}' is locally managed.".format(section), logfile_path, ) # Run any needed command AFTER cloning if not component_exists and "post_cmd" in section_options: run_command( section_options["post_cmd"], cwd=self.workspace_dir, logfile_path=logfile_path, ) # Just print a new line to keep components' output separated colorprint.normal("", logfile_path)
def exit_with_error(error_text, logfile_path): colorprint.error(error_text, logfile_path) sys.exit(1)
for entry in os.scandir(workspace_path): if entry.is_dir() and entry.name not in excluded_components and \ os.path.isfile('{}/{}/install.sh'.format(workspace_path, entry.name)): commands.append(os.path.join(entry.name, "install.sh")) return commands if __name__ == "__main__": container_name = sys.argv[1] if len(sys.argv) > 2: workspace_name = sys.argv[2] else: workspace_name = container_name workspace_path = workspaces.get_workspace_path(workspace_name) logfile_path = os.path.abspath( os.path.join(workspace_path, INSTALL_LOG_FILE_NAME)) manifest = get_manifest(workspace_name, logfile_path) install_commands = get_install_commands(manifest, workspace_path, logfile_path) for install_command in install_commands: cmd = 'lxc exec {} -- /bin/bash /home/swift/code/{}'.format( container_name, install_command) try: run_command(cmd, logfile_path=logfile_path) except Exception as e: colorprint.error(str(e), logfile_path) sys.exit(1)