The function get_interface_name is used to get the interface name of linux guest through the macaddress of specified macaddress. Signed-off-by: Jason Wang <jasowang@xxxxxxxxxx> Signed-off-by: Amos Kong <akong@xxxxxxxxxx> --- 0 files changed, 0 insertions(+), 0 deletions(-) diff --git a/client/tests/kvm/kvm_test_utils.py b/client/tests/kvm/kvm_test_utils.py index 53c11ae..8cd7acd 100644 --- a/client/tests/kvm/kvm_test_utils.py +++ b/client/tests/kvm/kvm_test_utils.py @@ -481,3 +481,20 @@ def run_autotest(vm, session, control_path, timeout, outputdir): e_msg = ("Tests %s failed during control file execution" % " ".join(bad_results)) raise error.TestFail(e_msg) + + +def get_linux_ifname(session, mac_address): + """ + Return the interface name through the mac address. + + @param session: session to the virtual machine + @mac_address: the macaddress of nic + """ + output = session.get_command_output("ifconfig -a") + + try: + ethname = re.findall("(\w+)\s+Link.*%s" % mac_address, output, + re.IGNORECASE)[0] + return ethname + except: + return None -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html