コード例 #1
0
ファイル: dmg_utils.py プロジェクト: fschlimb/daos
def storage_reset(hosts, user=None, hugepages="4096", insecure=True):
    """Execute prepare reset command through dmg tool to servers provided.

    Args:
        hosts (list): list of servers to run prepare on.
        user (str, optional): User with priviledges. Defaults to False.
        hugepages (str, optional): Hugepages to allocate. Defaults to "4096".

    Returns:
        Avocado CmdResult object that contains exit status, stdout information.

    """
    # Create and setup the command
    dmg = DmgCommand(get_file_path("bin/dmg"))
    dmg.insecure.value = insecure
    dmg.hostlist.value = hosts
    dmg.request.value = "storage"
    dmg.action.value = "prepare"
    dmg.get_action_command()
    dmg.action_command.nvmeonly.value = True
    dmg.action_command.targetuser.value = getpass.getuser() \
        if user is None else user
    dmg.action_command.hugepages.value = hugepages
    dmg.action_command.reset.value = True
    dmg.action_command.force.value = True

    try:
        result = dmg.run()
    except CommandFailure as details:
        print("<dmg> command failed: {}".format(details))
        return None

    return result
コード例 #2
0
def unittest_runner(self, unit_testname):
    """
    Common unitetest runner function.

    Unit tests needs to be run on local machine incase of server start required
    For other unit tests, which does not required to start server,it needs to be
    run on server where /mnt/daos mounted.

    Args:
        unit_testname: unittest name.
    return:
        None
    """
    name = self.params.get("testname",
                           '/run/UnitTest/{0}/'.format(unit_testname))
    server = self.params.get("test_machines", "/run/hosts/*")
    bin_path = get_file_path(name, "install/bin")

    cmd = ("ssh {} {}".format(server[0], bin_path[0]))

    return_code = process.system(cmd,
                                 ignore_status=True,
                                 allow_output_check="both")

    if return_code != 0:
        self.fail("{0} unittest failed with return code={1}.\n".format(
            unit_testname, return_code))
コード例 #3
0
ファイル: dmg_utils.py プロジェクト: fschlimb/daos
def storage_format(hosts, insecure=True):
    """ Execute format command through dmg tool to servers provided.

    Args:
        hosts (list): list of servers to run format on.

    Returns:
        Avocado CmdResult object that contains exit status, stdout information.

    """
    # Create and setup the command
    dmg = DmgCommand(get_file_path("bin/dmg"))
    dmg.insecure.value = insecure
    dmg.hostlist.value = hosts
    dmg.request.value = "storage"
    dmg.action.value = "format"
    dmg.get_action_command()
    dmg.action_command.force.value = True

    try:
        result = dmg.run(sudo=True)
    except CommandFailure as details:
        print("<dmg> command failed: {}".format(details))
        return None

    return result
コード例 #4
0
def storage_prepare(hosts, user, device_type):
    """Prepare storage on servers using the DAOS server's yaml settings file.

    Args:
        hosts (str): a string of comma-separated host names
        user (str): username for file permissions
        device_type (str): storage type - scm or nvme

    Raises:
        ServerFailed: if server failed to prepare storage

    """
    # Get the daos_server from the install path. Useful for testing
    # with daos built binaries.
    dev_param = ""
    device_args = ""
    daos_srv_bin = get_file_path("bin/daos_server")
    if device_type == "dcpm":
        dev_param = "-s"
    elif device_type == "dcpm_nvme":
        device_args = " --hugepages=4096"
    elif device_type == "ram_nvme" or device_type == "nvme":
        dev_param = "-n"
        device_args = " --hugepages=4096"
    else:
        raise ServerFailed("Invalid device type")
    cmd = ("sudo {} storage prepare {} -u \"{}\" {} -f".format(
        daos_srv_bin[0], dev_param, user, device_args))
    result = pcmd(hosts, cmd, timeout=120)
    if len(result) > 1 or 0 not in result:
        raise ServerFailed("Error preparing NVMe storage")
コード例 #5
0
def storage_reset(hosts):
    """
    Reset the Storage on servers using the DAOS server's yaml settings file.
    Args:
        hosts (str): a string of comma-separated host names
    Raises:
        ServerFailed: if server failed to reset storage
    """
    daos_srv_bin = get_file_path("bin/daos_server")
    cmd = "sudo {} storage prepare -n --reset -f".format(daos_srv_bin[0])
    result = pcmd(hosts, cmd)
    if len(result) > 1 or 0 not in result:
        raise ServerFailed("Error resetting NVMe storage")
コード例 #6
0
def storage_prepare(hosts, user):
    """
    Prepare the storage on servers using the DAOS server's yaml settings file.
    Args:
        hosts (str): a string of comma-separated host names
    Raises:
        ServerFailed: if server failed to prepare storage
    """
    daos_srv_bin = get_file_path("bin/daos_server")
    cmd = ("sudo {} storage prepare -n -u \"{}\" --hugepages=4096 -f"
           .format(daos_srv_bin[0], user))
    result = pcmd(hosts, cmd, timeout=120)
    if len(result) > 1 or 0 not in result:
        raise ServerFailed("Error preparing NVMe storage")
コード例 #7
0
ファイル: Unittest.py プロジェクト: daos-stack/daos
    def unittest_runner(self, unit_testname):
        """
        Common unitetest runner function.
        Args:
            unit_testname: unittest name.
        return:
            None
        """
        name = self.params.get("testname", '/run/UnitTest/{0}/'
                               .format(unit_testname))
        bin_path = get_file_path(name, "install/bin")

        cmd = ("{0}".format(bin_path[0]))
        return_code = process.system(cmd)
        if return_code is not 0:
            self.fail("{0} unittest failed with return code={1}.\n"
                      .format(unit_testname, return_code))
コード例 #8
0
ファイル: Unittest.py プロジェクト: morsiee/daos
    def unittest_runner(self, unit_testname):
        """
        Common unitetest runner function.
        Args:
            unit_testname: unittest name.
        return:
            None
        """
        name = self.params.get("testname", '/run/UnitTest/{0}/'
                               .format(unit_testname))
        bin_path = get_file_path(name, "install/bin")

        cmd = ("{0}".format(bin_path[0]))
        return_code = process.system(cmd)
        if return_code is not 0:
            self.fail("{0} unittest failed with return code={1}.\n"
                      .format(unit_testname, return_code))
コード例 #9
0
def storage_reset(hosts):
    """Reset the Storage on servers using the DAOS server's yaml settings file.

    NOTE: Don't enhance this method to reset SCM. SCM will not be in a useful
    state for running next tests.

    Args:
        hosts (str): a string of comma-separated host names

    Raises:
        ServerFailed: if server failed to reset storage

    """
    daos_srv_bin = get_file_path("bin/daos_server")
    cmd = "sudo {} storage prepare -n --reset -f".format(daos_srv_bin[0])
    result = pcmd(hosts, cmd)
    if len(result) > 1 or 0 not in result:
        raise ServerFailed("Error resetting NVMe storage")