def copy_configuration(self, hosts): """Copy the yaml configuration file to the hosts. If defined self.temporary_file is copied to hosts using the path/file specified by the YamlParameters.filename. Args: hosts (list): hosts to which to copy the configuration file. Raises: CommandFailure: if there is an error copying the configuration file """ if isinstance(self.yaml, YamlParameters): if self.temporary_file and hosts: self.log.info("Copying %s yaml configuration file to %s on %s", self.temporary_file, self.yaml.filename, hosts) try: distribute_files(hosts, self.temporary_file, self.yaml.filename, verbose=False, sudo=True) except DaosTestError as error: raise CommandFailure( "ERROR: Copying yaml configuration file to {}: " "{}".format(hosts, error))
def update_config_file_from_file(self, dst_hosts, test_dir, generated_yaml): """Update config file and object. Create and place the new config file in /etc/daos/daos_server.yml Then update SCM-related data in engine_params so that those disks will be wiped. Args: dst_hosts (list): Destination server hostnames to place the new config file. test_dir (str): Directory where the server config data from generated_yaml will be written. generated_yaml (YAMLObject): New server config data. """ # Create a temporary file in test_dir and write the generated config. temp_file_path = os.path.join(test_dir, "temp_server.yml") try: with open(temp_file_path, 'w') as write_file: yaml.dump(generated_yaml, write_file, default_flow_style=False) except Exception as error: raise CommandFailure( "Error writing the yaml file! {}: {}".format(temp_file_path, error)) from error # Copy the config from temp dir to /etc/daos of the server node. default_server_config = get_default_config_file("server") try: distribute_files( dst_hosts, temp_file_path, default_server_config, verbose=False, sudo=True) except DaosTestError as error: raise CommandFailure( "ERROR: Copying yaml configuration file to {}: " "{}".format(dst_hosts, error)) from error # Before restarting daos_server, we need to clear SCM. Unmount the mount # point, wipefs the disks, etc. This clearing step is built into the # server start steps. It'll look at the engine_params of the # server_manager and clear the SCM set there, so we need to overwrite it # before starting to the values from the generated config. self.log.info("Resetting engine_params") self.manager.job.yaml.engine_params = [] engines = generated_yaml["engines"] for i, engine in enumerate(engines): self.log.info("engine %d", i) for storage_tier in engine["storage"]: if storage_tier["class"] != "dcpm": continue self.log.info("scm_mount = %s", storage_tier["scm_mount"]) self.log.info("class = %s", storage_tier["class"]) self.log.info("scm_list = %s", storage_tier["scm_list"]) per_engine_yaml_parameters = DaosServerYamlParameters.PerEngineYamlParameters(i) per_engine_yaml_parameters.scm_mount.update(storage_tier["scm_mount"]) per_engine_yaml_parameters.scm_class.update(storage_tier["class"]) per_engine_yaml_parameters.scm_size.update(None) per_engine_yaml_parameters.scm_list.update(storage_tier["scm_list"]) per_engine_yaml_parameters.reset_yaml_data_updated() self.manager.job.yaml.engine_params.append( per_engine_yaml_parameters)
def copy_fault_files(self, hosts): """Copy the fault injection file to all test hosts. Args: hosts (list): list of hosts to copy the fault injection file """ if self._fault_list: self._hosts = hosts distribute_files(self._hosts, self.fault_file, self.fault_file)
def copy_certificates(self, source, hosts): """Copy certificates files from the source to the destination hosts. Args: source (str): source of the certificate files. hosts (list): list of the destination hosts. """ names = set() yaml = self.yaml while yaml is not None and hasattr(yaml, "other_params"): if hasattr(yaml, "get_certificate_data"): self.log.debug("Copying certificates for %s:", self._command) data = yaml.get_certificate_data( yaml.get_attribute_names(LogParameter)) for name in data: create_directory(hosts, name, verbose=False, raise_exception=False) for file_name in data[name]: src_file = os.path.join(source, file_name) dst_file = os.path.join(name, file_name) self.log.debug(" %s -> %s", src_file, dst_file) result = distribute_files(hosts, src_file, dst_file, mkdir=False, verbose=False, raise_exception=False, sudo=True, owner=self.certificate_owner) if result.exit_status != 0: self.log.info( " WARNING: %s copy failed on %s:\n%s", dst_file, hosts, result) names.add(name) yaml = yaml.other_params # debug to list copy of cert files if names: self.log.debug("Copied certificates for %s (in %s):", self._command, ", ".join(names)) for line in get_file_listing(hosts, names).stdout_text.splitlines(): self.log.debug(" %s", line)