From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id E0A13C63C for ; Wed, 24 Jun 2015 09:47:23 +0200 (CEST) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP; 24 Jun 2015 00:47:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,671,1427785200"; d="scan'208";a="593762771" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga003.jf.intel.com with ESMTP; 24 Jun 2015 00:47:22 -0700 Received: from shecgisg003.sh.intel.com (shecgisg003.sh.intel.com [10.239.29.90]) by shvmail01.sh.intel.com with ESMTP id t5O7lK2W004638; Wed, 24 Jun 2015 15:47:20 +0800 Received: from shecgisg003.sh.intel.com (localhost [127.0.0.1]) by shecgisg003.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id t5O7lIQj022343; Wed, 24 Jun 2015 15:47:20 +0800 Received: (from yliu84x@localhost) by shecgisg003.sh.intel.com (8.13.6/8.13.6/Submit) id t5O7lHUI022339; Wed, 24 Jun 2015 15:47:17 +0800 From: Yong Liu To: dts@dpdk.org Date: Wed, 24 Jun 2015 15:47:16 +0800 Message-Id: <1435132036-22307-1-git-send-email-yong.liu@intel.com> X-Mailer: git-send-email 1.7.4.1 Subject: [dts] [PATCH v2] covert DUT hostname into ipaddress for qemu tcp forward X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Jun 2015 07:47:24 -0000 From: Marvin Liu v2 changes: import re in settings module fix typo issue in qemu_kvm module Signed-off-by: Marvin Liu diff --git a/framework/qemu_kvm.py b/framework/qemu_kvm.py index 434c32d..d149524 100644 --- a/framework/qemu_kvm.py +++ b/framework/qemu_kvm.py @@ -36,6 +36,7 @@ import os from virt_base import VirtBase from exception import StartVMFailedException +from settings import get_host_ip # This name is derictly defined in the qemu guest serivce # So you can not change it except it is changed by the service @@ -408,7 +409,8 @@ class QEMUKvm(VirtBase): # get the host addr host_addr = field(opt_hostfwd, 1) if not host_addr: - host_addr = str(self.host_dut.get_ip_address()) + addr = str(self.host_dut.get_ip_address()) + host_addr = get_host_ip(addr) # get the host port in the option host_port = field(opt_hostfwd, 2).split('-')[0] diff --git a/framework/settings.py b/framework/settings.py index d3cdf80..9923b0c 100644 --- a/framework/settings.py +++ b/framework/settings.py @@ -31,6 +31,9 @@ """ Folders for framework running enviornment. """ +import re +import socket + FOLDERS = { 'Framework': 'framework', 'Testscripts': 'tests', @@ -200,3 +203,16 @@ def get_netdev(crb, pci): return vf return None + +def get_host_ip(address): + ip_reg = r'\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}' + m = re.match(ip_reg, address) + if m: + return address + else: + try: + result=socket.gethostbyaddr(address) + return result[2][0] + except: + print "couldn't look up %s" % address + return '' -- 1.9.3