def get_manifest(workspace_name, logfile_path): if workspace_name is None: workspace_name = workspaces.get_last_workspace_name() if workspace_name is None: exit_with_error("No workspace found.", logfile_path) workspace_path = workspaces.get_workspace_path(workspace_name) manifest_path = workspaces.get_manifest_path(workspace_name) if not os.path.isfile(manifest_path): colorprint.warning( "Error: could not find manifest at {}. While it's " "not mandatory, it's highly recommended to use one." " Read 'README_MANIFEST.md' for more " "information.".format(manifest_path), logfile_path) return None else: try: return Manifest(manifest_path, workspace_path) except Exception as e: exit_with_error(e.message, logfile_path)
if os.geteuid() != 0: exit_with_error("This script must be run as root.") if workspace_name is None: workspace_name = workspaces.get_last_workspace_name() manifest = get_manifest(workspace_name) if vol_size is None: vol_size = manifest.get_config_option("drive_size") family = manifest.get_config_option("family") if family is not None: if base_image != DEFAULT_BASE_IMAGE: colorprint.warning("You provided a base image name, but a family " "name is specified in the manifest. Your base " "image name will not be used.") base_image = family if container_name is None: container_name = workspace_name swift = manifest.get_config_option('swift') vol_count = int(manifest.get_config_option('drive_count')) tiny = manifest.get_config_option('tiny') proxyfs = manifest.get_config_option('proxyfs') if proxyfs and vol_count != PROXYFS_MANDATORY_VOL_COUNT: exit_with_error("ProxyFS configuration assumes {} drives are used. It " "will not work properly with current {} drives " "configuration.".format(PROXYFS_MANDATORY_VOL_COUNT,
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)
if workspace_name is None: workspace_name = workspaces.get_last_workspace_name() provided_workspace_name = False else: provided_workspace_name = True manifest = get_manifest(workspace_name) vol_size = manifest.get_config_option("drive_size") vol_count = int(manifest.get_config_option("drive_count")) # Vagrant up if os.environ.get("CONTROLLER_NAME") is None: colorprint.warning( "WARNING: CONTROLLER_NAME env var hasn't been set. " "If you fail to 'vagrant up' your VM, open " "VirtualBox, check the name of your SCSI " "Controller and provide it in the CONTROLLER_NAME " "env var." ) vagrant_env_vars = { "VOL_SIZE": "{}".format(vol_size_in_mebibytes(vol_size)), "VOL_COUNT": "{}".format(vol_count), } try: run_command("vagrant up", cwd=RUNWAY_DIR, env=vagrant_env_vars) colorprint.success("VM successfully created.") colorprint.info("VM needs to be rebooted before container creation.") run_command("vagrant reload", cwd=RUNWAY_DIR) colorprint.info("Creating container...") create_container_cmd = "./create_container.sh -d {}".format(distro) if container_name is not None: