Esempio n. 1
0
def iface_trans_commit(params, test):
    """
    Commit the new network configuration
    :params: the parameter dictionary
    """
    result = virsh.iface_commit()
    status = result.exit_status

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

    if status_error == "yes":
        if status:
            logging.info("It's an expected error")
        else:
            test.fail("%d not a expected command" "return value" % status)
    elif status_error == "no":
        if status:
            test.fail(result.stderr)
        else:
            netcf_status = netcf_trans_control(test)
            logging.debug("%s", netcf_status)

            if not re.search("No open", netcf_status) or \
                    not os.access(iface_cfg, os.R_OK):
                test.fail("Failed to commit snapshot")

            logging.info("Succeed to commit snapshot of current network")
    else:
        test.fail("The 'status_error' must be 'yes' or 'no': %s" %
                  status_error)
Esempio n. 2
0
def iface_trans_commit(params):
    """
    Commit the new network configuration
    :params: the parameter dictionary
    """
    result = virsh.iface_commit()
    status = result.exit_status

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

    if status_error == "yes":
        if status:
            logging.info("It's an expected error")
        else:
            raise error.TestFail("%d not a expected command"
                                 "return value" % status)
    elif status_error == "no":
        if status:
            raise error.TestFail(result.stderr)
        else:
            netcf_status = netcf_trans_control()
            logging.debug("%s", netcf_status)

            if not re.search("No open", netcf_status) or \
                    not os.access(iface_cfg, os.R_OK):
                raise error.TestFail("Failed to commit snapshot")

            logging.info("Succeed to commit snapshot of current network")
    else:
        raise error.TestFail("The 'status_error' must be 'yes' or 'no': %s"
                             % status_error)