示例#1
0
文件: server_utils.py 项目: liw/daos
def get_server_command(group, cert_dir, bin_dir, config_file, config_temp=None):
    """Get the daos_server command object to manage.

    Args:
        group (str): daos_server group name
        cert_dir (str): directory in which to copy certificates
        bin_dir (str): location of the daos_server executable
        config_file (str): configuration file name and path
        config_temp (str, optional): file name and path to use to generate the
            configuration file locally and then copy it to all the hosts using
            the config_file specification. Defaults to None, which creates and
            utilizes the file specified by config_file.

    Returns:
        DaosServerCommand: the daos_server command object

    """
    transport_config = DaosServerTransportCredentials(cert_dir)
    common_config = CommonConfig(group, transport_config)
    config = DaosServerYamlParameters(config_file, common_config)
    command = DaosServerCommand(bin_dir, config)
    if config_temp:
        # Setup the DaosServerCommand to write the config file data to the
        # temporary file and then copy the file to all the hosts using the
        # assigned filename
        command.temporary_file = config_temp
    return command
示例#2
0
文件: server_utils.py 项目: liw/daos
    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)
示例#3
0
    def add_server_manager(self,
                           config_file=None,
                           dmg_config_file=None,
                           common_cfg=None,
                           timeout=20):
        """Add a new daos server manager object to the server manager list.

        When adding multiple server managers unique yaml config file names
        and common config setting (due to the server group name) should be used.

        Args:
            config_file (str, optional): daos server config file name. Defaults
                to None, which will use a default file name.
            dmg_config_file (str, optional): dmg config file name. Defaults
                to None, which will use a default file name.
            common_cfg (CommonConfig, optional): daos server config file
                settings shared between the agent and server. Defaults to None,
                which uses the class CommonConfig.
            timeout (int, optional): number of seconds to wait for the daos
                server to start before reporting an error. Defaults to 60.
        """
        self.log.info("--- ADDING SERVER MANAGER ---")

        # Setup defaults
        if config_file is None:
            config_file = self.get_config_file("daos", "server")
        if common_cfg is None:
            common_cfg = CommonConfig(
                self.server_group,
                DaosServerTransportCredentials(self.workdir))

        if dmg_config_file is None:
            dmg_config_file = self.get_config_file("daos", "dmg")
        transport_dmg = DmgTransportCredentials(self.workdir)
        dmg_cfg = DmgYamlParameters(dmg_config_file, self.server_group,
                                    transport_dmg)
        # Create a ServerCommand to manage with a new ServerManager object
        server_cfg = DaosServerYamlParameters(config_file, common_cfg)
        server_cmd = DaosServerCommand(self.bin, server_cfg, timeout)
        self.server_managers.append(
            DaosServerManager(server_cmd, self.manager_class, dmg_cfg))