コード例 #1
0
def check_slice_blkdeviotune(vm, params, test):
    """
    Check block blkdeviotune on disk with slice attribute

    :param vm: one object representing VM
    :param params: wrapped parameters in dictionary format
    :param test: test assert object
    """
    device_target = params.get("target_dev")
    total_bytes_sec = params.get("total_bytes_sec")

    virsh.blkdeviotune(vm.name,
                       device_target,
                       " --total-bytes-sec %s" % total_bytes_sec,
                       ignore_status=False,
                       debug=True)
    blkdeviotune_raw_output = virsh.blkdeviotune(
        vm.name, device_target, ignore_status=False,
        debug=True).stdout_text.strip()
    blkdeviotune_dict = translate_raw_output_into_dict(blkdeviotune_raw_output,
                                                       default_delimiter=":")

    LOG.debug(blkdeviotune_dict)
    # Verify total_bytes_sec is the same with preset one
    if blkdeviotune_dict["total_bytes_sec"] != total_bytes_sec:
        test.fail("The gotten value: %s is not equal from preset one" %
                  blkdeviotune_dict["total_bytes_sec"])
コード例 #2
0
 def operations():
     """
     Do save | domstats | blkdeviotune operations
     """
     if self.operation == "save":
         virsh.save(self.vm_name, self.save_file, debug=True, timeout=self.operation_timeout)
     if self.operation == "domstats":
         virsh.domstats(self.vm_name, opertions=self.operation_option, debug=True, timeout=self.operation_timeout)
     if self.operation == "blkdeviotune":
         virsh.blkdeviotune(self.vm_name, self.disk_tgt, debug=True, timeout=self.operation_timeout)
コード例 #3
0
 def operations():
     """
     Do save | domstats | blkdeviotune operations
     """
     if self.operation == "save":
         virsh.save(self.vm_name, self.save_file, debug=True, timeout=self.operation_timeout)
     if self.operation == "domstats":
         virsh.domstats(self.vm_name, opertions=self.operation_option, debug=True, timeout=self.operation_timeout)
     if self.operation == "blkdeviotune":
         virsh.blkdeviotune(self.vm_name, self.disk_tgt, debug=True, timeout=self.operation_timeout)
コード例 #4
0
def get_blkdevio_parameter(params):
    """
    Get the blkdevio parameters
    @params: the parameter dictionary
    """
    vm_name = params.get("main_vm")
    options = params.get("blkdevio_options")
    device = params.get("blkdevio_device")

    result = virsh.blkdeviotune(vm_name, device, options=options)
    status = result.exit_status

    # Check status_error
    status_error = params.get("status_error", "no")

    if status_error == "yes":
        if status:
            logging.info("It's an expected %s", result.stderr)
        else:
            raise error.TestFail("Unexpected return code %d" % status)
    elif status_error == "no":
        if status:
            raise error.TestFail(result.stderr)
        else:
            logging.info(result.stdout)
コード例 #5
0
def set_blkdevio_parameter(params, test):
    """
    Set the blkdevio parameters
    @params: the parameter dictionary
    """
    vm_name = params.get("main_vm")
    device = params.get("device_name")
    options = params.get("blkdevio_options")

    blkdevio_params = {x[9:]: params.get(x) for x in params.keys()
                       if x.startswith('blkdevio_')}
    result = virsh.blkdeviotune(vm_name, device, options=options,
                                params=blkdevio_params, debug=True)
    logging.debug("Guest XML:\n%s", libvirt_xml.VMXML.new_from_dumpxml(vm_name))
    status = result.exit_status
    # Check status_error
    status_error = params.get("status_error", "no")

    if status_error == "yes":
        if status:
            logging.info("It's an expected %s", result.stderr)
        else:
            test.fail("Unexpected return code %d" % status)
    elif status_error == "no":
        if status:
            test.fail(result.stderr)
        else:
            if check_blkdeviotune(params):
                logging.info(result.stdout.strip())
            else:
                test.fail("The result is inconsistent between "
                          "test input and command/XML output")
コード例 #6
0
def get_blkdevio_parameter(params):
    """
    Get the blkdevio parameters
    @params: the parameter dictionary
    """
    vm_name = params.get("main_vm")
    options = params.get("blkdevio_options")
    device = params.get("blkdevio_device")

    result = virsh.blkdeviotune(vm_name, device, options=options, debug=True)
    status = result.exit_status

    # Check status_error
    status_error = params.get("status_error", "no")

    if status_error == "yes":
        if status:
            logging.info("It's an expected %s", result.stderr)
        else:
            raise error.TestFail("Unexpected return code %d" % status)
    elif status_error == "no":
        if status:
            raise error.TestFail(result.stderr)
        else:
            logging.info(result.stdout)
コード例 #7
0
def check_blkdeviotune(params):
    """
    Check block device I/O parameters
    """
    vm_name = params.get("main_vm")
    vm = params.get("vm")
    options = params.get("blkdevio_options")
    device = params.get("device_name", "")
    result = virsh.blkdeviotune(vm_name, device)
    dicts = {}
    # Parsing command output and putting them into python dictionary.
    cmd_output = result.stdout.strip().splitlines()
    for l in cmd_output:
        k, v = l.split(':')
        if v.strip().isdigit():
            dicts[k.strip()] = int(v.strip())
        else:
            dicts[k.strip()] = v.strip()

    logging.debug("The arguments are from test input %s", dicts)

    virt_xml_obj = libvirt_xml.vm_xml.VMXML(virsh_instance=virsh)

    if options and "config" in options and vm.is_alive():
        blkdev_xml = virt_xml_obj.get_blkdevio_params(vm_name, "--inactive")
    else:
        blkdev_xml = virt_xml_obj.get_blkdevio_params(vm_name)

    logging.debug("The parameters are from XML parser %s", blkdev_xml)

    blkdevio_list = ["total_bytes_sec", "read_bytes_sec", "write_bytes_sec",
                     "total_iops_sec", "read_iops_sec", "write_iops_sec",
                     "total_bytes_sec_max", "total_iops_sec_max", "group_name"]

    if vm.is_alive() and (not options or "config" not in options):
        for k in blkdevio_list:
            arg_from_test_input = params.get("blkdevio_" + k)
            arg_from_cmd_output = dicts.get(k)
            logging.debug("output type:%s, output=%s", type(arg_from_cmd_output), arg_from_cmd_output)
            logging.debug("input type:%s, input=%s", type(arg_from_test_input), arg_from_test_input)

            if arg_from_test_input:
                if isinstance(arg_from_cmd_output, int):
                    arg_from_cmd_output = str(arg_from_cmd_output)

                if arg_from_test_input != arg_from_cmd_output:
                    logging.error("To expect <%s=%s>",
                                  arg_from_test_input, arg_from_cmd_output)
                    return False
    else:
        for k in blkdevio_list:
            arg_from_test_input = params.get("blkdevio_" + k)
            arg_from_xml_output = blkdev_xml.get(k)
            if (arg_from_test_input and
                    int(arg_from_test_input) != arg_from_xml_output):
                logging.error("To expect <%s=%s>",
                              arg_from_test_input, arg_from_xml_output)
                return False
    return True
コード例 #8
0
def check_blkdeviotune(params):
    """
    Check block device I/O parameters
    """
    vm_name = params.get("main_vm")
    vm = params.get("vm")
    options = params.get("blkdevio_options")
    device = params.get("blkdevio_device", "")
    result = virsh.blkdeviotune(vm_name, device)
    dicts = {}
    # Parsing command output and putting them into python dictionary.
    cmd_output = result.stdout.strip().splitlines()
    for l in cmd_output:
        k, v = l.split(':')
        if v.strip().isdigit():
            dicts[k.strip()] = int(v.strip())
        else:
            dicts[k.strip()] = v.strip()

    logging.debug("The arguments are from test input %s", dicts)

    virt_xml_obj = libvirt_xml.vm_xml.VMXML(virsh_instance=virsh)

    if "config" in options and vm.is_alive():
        blkdev_xml = virt_xml_obj.get_blkdevio_params(vm_name, "--inactive")
    else:
        blkdev_xml = virt_xml_obj.get_blkdevio_params(vm_name)

    logging.debug("The parameters are from XML parser %s", blkdev_xml)

    blkdevio_list = ["total_bytes_sec", "read_bytes_sec", "write_bytes_sec",
                     "total_iops_sec", "read_iops_sec", "write_iops_sec"]

    if vm.is_alive() and "config" not in options:
        for k in blkdevio_list:
            arg_from_test_input = params.get("blkdevio_" + k)
            arg_from_cmd_output = dicts.get(k)
            if (arg_from_test_input and
                    int(arg_from_test_input) != arg_from_cmd_output):
                logging.error("To expect <%s=%s>",
                              arg_from_test_input, arg_from_cmd_output)
                return False
    else:
        for k in blkdevio_list:
            arg_from_test_input = params.get("blkdevio_" + k)
            arg_from_xml_output = blkdev_xml.get(k)
            if (arg_from_test_input and
                    int(arg_from_test_input) != arg_from_xml_output):
                logging.error("To expect <%s=%s>",
                              arg_from_test_input, arg_from_xml_output)
                return False
    return True
コード例 #9
0
def set_blkdevio_parameter(params):
    """
    Set the blkdevio parameters
    @params: the parameter dictionary
    """
    vm_name = params.get("main_vm")
    total_bytes_sec = params.get("blkdevio_total_bytes_sec")
    read_bytes_sec = params.get("blkdevio_read_bytes_sec")
    write_bytes_sec = params.get("blkdevio_write_bytes_sec")
    total_iops_sec = params.get("blkdevio_total_iops_sec")
    read_iops_sec = params.get("blkdevio_read_iops_sec")
    write_iops_sec = params.get("blkdevio_write_iops_sec")
    device = params.get("blkdevio_device")
    options = params.get("blkdevio_options")

    result = virsh.blkdeviotune(vm_name,
                                device,
                                options,
                                total_bytes_sec,
                                read_bytes_sec,
                                write_bytes_sec,
                                total_iops_sec,
                                read_iops_sec,
                                write_iops_sec,
                                debug=True)
    status = result.exit_status

    # Check status_error
    status_error = params.get("status_error", "no")

    if status_error == "yes":
        if status:
            logging.info("It's an expected %s", result.stderr)
        else:
            raise error.TestFail("Unexpected return code %d" % status)
    elif status_error == "no":
        if status:
            raise error.TestFail(result.stderr)
        else:
            if check_blkdeviotune(params):
                logging.info(result.stdout)
            else:
                raise error.TestFail("The result is inconsistent between "
                                     "test input and command/XML output")
コード例 #10
0
def set_blkdevio_parameter(params):
    """
    Set the blkdevio parameters
    @params: the parameter dictionary
    """
    vm_name = params.get("main_vm")
    total_bytes_sec = params.get("blkdevio_total_bytes_sec")
    read_bytes_sec = params.get("blkdevio_read_bytes_sec")
    write_bytes_sec = params.get("blkdevio_write_bytes_sec")
    total_iops_sec = params.get("blkdevio_total_iops_sec")
    read_iops_sec = params.get("blkdevio_read_iops_sec")
    write_iops_sec = params.get("blkdevio_write_iops_sec")
    device = params.get("blkdevio_device")
    options = params.get("blkdevio_options")

    result = virsh.blkdeviotune(
        vm_name,
        device,
        options,
        total_bytes_sec,
        read_bytes_sec,
        write_bytes_sec,
        total_iops_sec,
        read_iops_sec,
        write_iops_sec,
    )
    status = result.exit_status

    # Check status_error
    status_error = params.get("status_error", "no")

    if status_error == "yes":
        if status:
            logging.info("It's an expected %s", result.stderr)
        else:
            raise error.TestFail("Unexpected return code %d" % status)
    elif status_error == "no":
        if status:
            raise error.TestFail(result.stderr)
        else:
            if check_blkdeviotune(params):
                logging.info(result.stdout)
            else:
                raise error.TestFail("The result is inconsistent between " "test input and command/XML output")