From patchwork Tue Jul 20 01:35:06 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amos Kong X-Patchwork-Id: 112923 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o6K1ZBWA029556 for ; Tue, 20 Jul 2010 01:35:26 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761054Ab0GTBfN (ORCPT ); Mon, 19 Jul 2010 21:35:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33704 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760997Ab0GTBfM (ORCPT ); Mon, 19 Jul 2010 21:35:12 -0400 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o6K1ZATf015193 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 19 Jul 2010 21:35:10 -0400 Received: from [127.0.1.1] (dhcp-91-133.nay.redhat.com [10.66.91.133]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o6K1Z7ka019918; Mon, 19 Jul 2010 21:35:08 -0400 Subject: [RFC PATCH 02/14] KVM Test: Add a function get_interface_name() to kvm_net_utils.py To: lmr@redhat.com From: Amos Kong Cc: autotest@test.kernel.org, qemu-devel@nongnu.org, kvm@vger.kernel.org Date: Tue, 20 Jul 2010 09:35:06 +0800 Message-ID: <20100720013506.2212.7371.stgit@z> In-Reply-To: <20100720013414.2212.13476.stgit@z> References: <20100720013414.2212.13476.stgit@z> User-Agent: StGit/0.15 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Tue, 20 Jul 2010 01:35:26 +0000 (UTC) diff --git a/client/tests/kvm/kvm_net_utils.py b/client/tests/kvm/kvm_net_utils.py new file mode 100644 index 0000000..ede4965 --- /dev/null +++ b/client/tests/kvm/kvm_net_utils.py @@ -0,0 +1,18 @@ +import re + +def get_linux_ifname(session, mac_address): + """ + Get 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