def iface_trans_begin(params, test): """ Take a snapshot of current network configuration :params: the parameter dictionary """ result = virsh.iface_begin() status = result.exit_status # Check status_error status_error = params.get("status_error", "no") 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: 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("an open", netcf_status) or \ not os.access(netcf_snap_dir, os.R_OK): test.fail("Failed to create snapshot for interface") logging.info("Succeed to create snapshot of current network") else: test.fail("The 'status_error' must be 'yes' or 'no': %s" % status_error)
def iface_trans_begin(params): """ Take a snapshot of current network configuration :params: the parameter dictionary """ result = virsh.iface_begin() status = result.exit_status # Check status_error status_error = params.get("status_error", "no") 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("an open", netcf_status) or \ not os.access(netcf_snap_dir, os.R_OK): raise error.TestFail("Failed to create snapshot for interface") logging.info("Succeed to create snapshot of current network") else: raise error.TestFail("The 'status_error' must be 'yes' or 'no': %s" % status_error)