예제 #1
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)
예제 #2
0
    def test_destroy_wrong_group(self):
        """Test destroying a pool with wrong server group.

        Test Steps:
        Two servers run with different group names, daos_server_a and
        daos_server_b. A pool is created on daos_server_a. Try destroying this
        pool specifying daos_server_b.

        We create a third dmg config file and specify the wrong server name in
        the name field and the right hostlist as below.

        daos_control_a.yml
        hostlist:
        - wolf-a
        name: daos_server_a

        daos_control_b.yml
        hostlist:
        - wolf-b
        name: daos_server_b

        daos_control_c.yml
        hostlist:
        - wolf-a
        name: daos_server_b

        We'll use daos_control_c.yml during dmg pool destroy and verify that it
        fails. It should show something like:
        "request system does not match running system (daos_server_b !=
        daos_server_a)"

        :avocado: tags=all,full_regression
        :avocado: tags=vm
        :avocado: tags=pool,pool_destroy
        :avocado: tags=pool_destroy_wrong_group
        """
        server_group_a = self.server_group + "_a"
        server_group_b = self.server_group + "_b"

        # Prepare and configure dmg config files for a and b.
        dmg_config_file_a = get_default_config_file(name="control_a")
        dmg_config_temp_a = self.get_config_file(name=server_group_a,
                                                 command="dmg",
                                                 path=self.test_dir)
        dmg_config_file_b = get_default_config_file(name="control_b")
        dmg_config_temp_b = self.get_config_file(name=server_group_b,
                                                 command="dmg",
                                                 path=self.test_dir)

        # Prepare server group info with corresponding dmg config file.
        group_info_a = self.get_group_info(hosts=[self.hostlist_servers[0]],
                                           dmg_config_file=dmg_config_file_a,
                                           dmg_config_temp=dmg_config_temp_a)
        group_info_b = self.get_group_info(hosts=[self.hostlist_servers[1]],
                                           dmg_config_file=dmg_config_file_b,
                                           dmg_config_temp=dmg_config_temp_b)

        # Put everything into a dictionary and start server a and b.
        server_groups_a_b = {
            server_group_a: group_info_a,
            server_group_b: group_info_b
        }
        self.start_servers(server_groups=server_groups_a_b)

        self.add_pool(connect=False)

        # Get dmg_c instance that uses daos_control_c.yml. Server group is b.
        cert_dir = os.path.join(os.sep, "etc", "daos", "certs")
        dmg_config_file_c = get_default_config_file(name="control_c")
        dmg_config_temp_c = self.get_config_file(name=server_group_b,
                                                 command="dmg",
                                                 path=self.test_dir)
        dmg_c = get_dmg_command(group=server_group_b,
                                cert_dir=cert_dir,
                                bin_dir=self.bin,
                                config_file=dmg_config_file_c,
                                config_temp=dmg_config_temp_c)

        # Update the third server manager's hostlist from "localhost" to
        # daos_server_a's hostname.
        dmg_c.hostlist = self.hostlist_servers[:1]

        # Try destroying the pool in server a with dmg_c. Should fail because
        # of the group name mismatch.
        case_c = "Pool is in a, hostlist is a, and name is b."
        self.validate_pool_destroy(hosts=[self.hostlist_servers[0]],
                                   case=case_c,
                                   exception_expected=True,
                                   new_dmg=dmg_c)

        # Try destroying the pool in server a with the dmg that uses
        # daos_control_b.yml. Should fail because the pool doesn't exist in b.
        case_b = "Pool is in a, hostlist is b, and name is b."
        self.validate_pool_destroy(hosts=[self.hostlist_servers[0]],
                                   case=case_b,
                                   exception_expected=True,
                                   new_dmg=self.server_managers[1].dmg)

        # Try destroying the pool in server a with the dmg that uses
        # daos_control_a.yml. Should pass.
        case_a = "Pool is in a, hostlist is a, and name is a."
        self.validate_pool_destroy(hosts=[self.hostlist_servers[0]],
                                   case=case_a,
                                   exception_expected=False,
                                   new_dmg=self.server_managers[0].dmg)
예제 #3
0
파일: destroy.py 프로젝트: kjacque/daos
    def test_destroy_invalid_group(self):
        """Test destroying a pool with invalid server group.

        Test Steps:
        Run a server with group name "daos_server_a" and create a pool on it.
        Try destroying this pool specifying daos_server_i. "i" for invalid.

        We create a second dmg config file and specify the invalid server name
        in the name field and the right hostlist as below.

        daos_control_a.yml
        hostlist:
        - wolf-a
        name: daos_server_a

        daos_control_i.yml
        hostlist:
        - wolf-a
        name: daos_server_i

        We'll use daos_control_i.yml during dmg pool destroy and verify that it
        fails. It should show something like:
        "request system does not match running system (daos_server_i !=
        daos_server_a)"

        :avocado: tags=all,full_regression
        :avocado: tags=pool,destroy,destroy_invalid_group
        """
        server_group_a = self.server_group + "_a"
        server_group_i = self.server_group + "_i"

        # Prepare and configure dmg config files for a.
        dmg_config_file_a = get_default_config_file(name="control_a")
        dmg_config_temp_a = self.get_config_file(name=server_group_a,
                                                 command="dmg",
                                                 path=self.test_dir)

        # Prepare server group info with corresponding dmg config file.
        group_info_a = self.get_group_info(hosts=[self.hostlist_servers[0]],
                                           dmg_config_file=dmg_config_file_a,
                                           dmg_config_temp=dmg_config_temp_a)

        # Put everything into a dictionary and start server a.
        server_groups_a = {
            server_group_a: group_info_a,
        }
        self.start_servers(server_groups=server_groups_a)

        self.add_pool(connect=False)

        # Get dmg_i instance that uses daos_control_i.yml. Server group is i.
        cert_dir = os.path.join(os.sep, "etc", "daos", "certs")
        dmg_config_file_i = get_default_config_file(name="control_i")
        dmg_config_temp_i = self.get_config_file(name=server_group_i,
                                                 command="dmg",
                                                 path=self.test_dir)
        dmg_i = get_dmg_command(group=server_group_i,
                                cert_dir=cert_dir,
                                bin_dir=self.bin,
                                config_file=dmg_config_file_i,
                                config_temp=dmg_config_temp_i)

        # Update the second server manager's hostlist from "localhost" to
        # daos_server_a's hostname.
        dmg_i.hostlist = self.hostlist_servers[0]

        # Try destroying the pool in server a with dmg_i. Should fail because
        # of the group name mismatch.
        case_i = "Pool is in a, hostlist is a, and name is i."
        self.validate_pool_destroy(hosts=[self.hostlist_servers[0]],
                                   case=case_i,
                                   exception_expected=True,
                                   new_dmg=dmg_i)

        # Try destroying the pool in server a with the dmg that uses
        # daos_control_a.yml. Should pass.
        case_a = "Pool is in a, hostlist is a, and name is a."
        self.validate_pool_destroy(hosts=[self.hostlist_servers[0]],
                                   case=case_a,
                                   exception_expected=False,
                                   new_dmg=self.server_managers[0].dmg)