Beispiel #1
0
def iface_trans_rollback(params):
    """
    Rollback network configuration to last snapshot if one exist
    :params: the parameter dictionary
    """
    result = virsh.iface_rollback()
    status = result.exit_status

    # Check status_error
    status_error = params.get("status_error", "no")
    iface_cfg = params.get("iface_cfg")
    netcf_snap_dir = params.get("netcf_snap_dir",
                                "/var/lib/netcf/network-snapshot")

    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):
                raise error.TestFail("Failed to rollback network to "
                                     "last snapshot")

            if os.access(netcf_snap_dir, os.R_OK):
                raise error.TestFail("%s exists" % netcf_snap_dir)

            if os.access(iface_cfg, os.R_OK):
                raise error.TestFail("%s exists" % iface_cfg)

            logging.info("Succeed to rollback network to last snapshot")
    else:
        raise error.TestFail("The 'status_error' must be 'yes' or 'no': %s" %
                             status_error)
Beispiel #2
0
def iface_trans_rollback(params):
    """
    Rollback network configuration to last snapshot if one exist
    :params: the parameter dictionary
    """
    result = virsh.iface_rollback()
    status = result.exit_status

    # Check status_error
    status_error = params.get("status_error", "no")
    iface_cfg = params.get("iface_cfg")
    netcf_snap_dir = params.get("netcf_snap_dir",
                                "/var/lib/netcf/network-snapshot")

    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):
                raise error.TestFail("Failed to rollback network to "
                                     "last snapshot")

            if os.access(netcf_snap_dir, os.R_OK):
                raise error.TestFail("%s exists" % netcf_snap_dir)

            if os.access(iface_cfg, os.R_OK):
                raise error.TestFail("%s exists" % iface_cfg)

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