From patchwork Mon Aug 23 08:52:11 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amos Kong X-Patchwork-Id: 123541 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 o7N9QZR3027645 for ; Mon, 23 Aug 2010 09:38:31 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752216Ab0HWItP (ORCPT ); Mon, 23 Aug 2010 04:49:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:19205 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751772Ab0HWItP (ORCPT ); Mon, 23 Aug 2010 04:49:15 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o7N8nFhY032425 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 23 Aug 2010 04:49:15 -0400 Received: from [0.0.0.190] (dhcp-91-190.nay.redhat.com [10.66.91.190]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o7N8nD3R008564; Mon, 23 Aug 2010 04:49:13 -0400 Subject: [PATCH v2 03/17] KVM Test: Add a function get_interface_name() to kvm_test_utils.py To: autotest@vger.kernel.org From: Amos Kong Cc: lmr@redhat.com, kvm@vger.kernel.org Date: Mon, 23 Aug 2010 16:52:11 +0800 Message-ID: <20100823085211.19173.1588.stgit@190> In-Reply-To: <20100823084745.19173.61655.stgit@190> References: <20100823084745.19173.61655.stgit@190> User-Agent: StGit/0.15 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 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]); Mon, 23 Aug 2010 09:38:33 +0000 (UTC) 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