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 E047AB62 for ; Wed, 2 Dec 2015 07:13:12 +0100 (CET) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP; 01 Dec 2015 22:13:10 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,371,1444719600"; d="scan'208";a="852021709" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga001.fm.intel.com with ESMTP; 01 Dec 2015 22:13:09 -0800 Received: from fmsmsx102.amr.corp.intel.com (10.18.124.200) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 1 Dec 2015 22:13:09 -0800 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by FMSMSX102.amr.corp.intel.com (10.18.124.200) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 1 Dec 2015 22:13:09 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.42]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.83]) with mapi id 14.03.0248.002; Wed, 2 Dec 2015 14:13:07 +0800 From: "Tu, LijuanX A" To: "Liu, Yong" , "dts@dpdk.org" Thread-Topic: [dts] [PATCH] framework: support create addtional sessions on crb Thread-Index: AQHRLBWw0IVp8TmpEEaEjqXPZr3z6p63L8SA Date: Wed, 2 Dec 2015 06:13:06 +0000 Message-ID: <38D041F150D4184C8114E499040E62340723E7BE@shsmsx102.ccr.corp.intel.com> References: <1448959904-23907-1-git-send-email-yong.liu@intel.com> In-Reply-To: <1448959904-23907-1-git-send-email-yong.liu@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dts] [PATCH] framework: support create addtional sessions on crb 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, 02 Dec 2015 06:13:13 -0000 Hi yong, =09 There are no logs when sending cmds. I hope see logs as master session. > -----Original Message----- > From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Yong Liu > Sent: Tuesday, December 01, 2015 4:52 PM > To: dts@dpdk.org > Subject: [dts] [PATCH] framework: support create addtional sessions on > crb >=20 > Add session create/destroy functions in crb module. > Suite can create addtional session in dut by this function. > When session useless, suite should close the session definitely. > Below is sample code addtional session: >=20 > session =3D self.dut.new_session() > session.send_expect("ls -al", "# ") > self.dut.close_session(session=3Dsession) >=20 > Signed-off-by: Marvin Liu >=20 > diff --git a/framework/crb.py b/framework/crb.py index 3c158ec..68fe399 > 100644 > --- a/framework/crb.py > +++ b/framework/crb.py > @@ -56,6 +56,7 @@ class Crb(object): > self.skip_setup =3D False > self.serializer =3D serializer > self.ports_info =3D None > + self.sessions =3D [] >=20 > self.logger =3D getLogger(name) > self.session =3D SSHConnection(self.get_ip_address(), name, @@ - > 81,6 +82,24 @@ class Crb(object): >=20 > return self.session.send_expect(cmds, expected, timeout, > verify) >=20 > + def create_session(self, name=3D""): > + """ > + Create new session for addtional useage. This session will not > enable log. > + """ > + session =3D SSHConnection(self.get_ip_address(), name, > + self.get_password()) > + self.sessions.append(session) > + return session.session > + > + def destroy_session(self, session=3DNone): > + """ > + Destroy addtional session. > + """ > + for save_session in self.sessions: > + if save_session.session =3D=3D session: > + save_session.close() > + self.sessions.remove(save_session) > + > def send_command(self, cmds, timeout=3DTIMEOUT, alt_session=3DFalse)= : > """ > Send commands to crb and return string before timeout. > diff --git a/framework/dut.py b/framework/dut.py index c75f325..2cea7fb > 100644 > --- a/framework/dut.py > +++ b/framework/dut.py > @@ -41,6 +41,7 @@ from crb import Crb > from net_device import NetDevice > from virt_resource import VirtResource > from utils import RED > +from uuid import uuid4 >=20 >=20 > class Dut(Crb): > @@ -85,6 +86,21 @@ class Dut(Crb): > self.host_session.init_log(self.logger) > self.host_init_flag =3D True >=20 > + def new_session(self): > + """ > + Create new session for dut instance. Session name will be > unique. > + """ > + session_name =3D str(uuid4()) > + session =3D self.create_session(name=3Dsession_name) > + session.send_expect("cd %s" % self.base_dir, "# ") > + return session > + > + def close_session(self, session): > + """ > + close new session in dut instance > + """ > + self.destroy_session(session) > + > def change_config_option(self, target, parameter, value): > """ > This function change option in the config file > -- > 1.9.3