From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 49D922BE5 for ; Fri, 11 Mar 2016 10:15:18 +0100 (CET) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP; 11 Mar 2016 01:15:17 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,320,1455004800"; d="scan'208";a="921632988" Received: from unknown (HELO dpdk-fedora20.icx.intel.com) ([10.238.55.12]) by fmsmga001.fm.intel.com with ESMTP; 11 Mar 2016 01:08:59 -0800 From: Lijuan Tu To: dts@dpdk.org, yong.liu@intel.com Date: Fri, 11 Mar 2016 17:04:36 +0800 Message-Id: <1457687076-86691-1-git-send-email-lijuanx.a.tu@intel.com> X-Mailer: git-send-email 1.9.3 Subject: [dts] [PATCH]framework: Delete NetDevice object after virtual machine shutdown 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: Fri, 11 Mar 2016 09:15:18 -0000 Signed-off-by: Lijuan Tu --- framework/virt_dut.py | 16 ++++++++++++++++ nics/net_device.py | 15 +++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/framework/virt_dut.py b/framework/virt_dut.py index 9bf75dc..019a9f2 100644 --- a/framework/virt_dut.py +++ b/framework/virt_dut.py @@ -39,6 +39,7 @@ from settings import NICS, LOG_NAME_SEP, get_netdev from project_dpdk import DPDKdut from dut import Dut from net_device import GetNicObj +from net_device import RemoveNicObj class VirtDut(DPDKdut): @@ -75,10 +76,25 @@ class VirtDut(DPDKdut): self.logger.config_suite(self.host_dut.test_classname, 'virtdut') def close(self): + # Close ssh session if self.session: self.session.close() + self.session = None if self.alt_session: self.alt_session.close() + self.alt_session = None + + # Remove Network object + vf_ports = self.get_vf_net_divce() + RemoveNicObj(self, vf_ports) + + def get_vf_net_divce(self): + vf_port = [] + for port_info in self.host_dut.ports_info: + if 'vfs_port' in port_info.keys(): + for port in port_info['vfs_port']: + vf_port.append(port) + return vf_port def set_nic_type(self, nic_type): """ diff --git a/nics/net_device.py b/nics/net_device.py index 73750f5..8c967ae 100644 --- a/nics/net_device.py +++ b/nics/net_device.py @@ -830,6 +830,14 @@ def get_from_list(host, bus_id, devfun_id): return nic['port'] return None +def remove_from_list(host, obj): + """ + Remove network device object from global structure + Parameter will by host ip, netdevice object + """ + for nic in NICS_LIST: + if host == nic['host']: + NICS_LIST.remove(nic) def GetNicObj(crb, bus_id, devfun_id): """ @@ -862,3 +870,10 @@ def GetNicObj(crb, bus_id, devfun_id): add_to_list(crb.crb['My IP'], obj) return obj + +def RemoveNicObj(crb, objs): + """ + Remove network device object. + """ + for obj in objs: + remove_from_list(crb.crb['My IP'], obj) -- 2.5.0