From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 57995A0032; Tue, 13 Sep 2022 19:04:54 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EBA1D4021E; Tue, 13 Sep 2022 19:04:53 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mails.dpdk.org (Postfix) with ESMTP id 295624021D for ; Tue, 13 Sep 2022 19:04:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1663088692; x=1694624692; h=date:from:to:cc:subject:message-id:references: content-transfer-encoding:in-reply-to:mime-version; bh=dyEGzwPdabckHDMVJEM7CtofSs/wGk6F5R9N2V8a+XM=; b=Rk9d7p1iaPc5ckmd5TIDmPs71pWoEc/CFE6rBgDShWVBJiaSS2hbipZ+ Pij+OmR0Gh20xiEO3hMqs84Z8860xi7yHvdANDggDa++BC8zEUa314Poy k9CbfPyQCjPabc3lA0+npYRoEA6po5Wx+FGwwcE41WGQ7wxUR5Rxw1Oii LEkivmeOvgdGZg6kS1u6WWcpt+/I3KivMOd49GN3nZ9GCfQYUiWlDquq5 JnhIQWcwj6XBiyvH5g6LQcvoMa9AufdTI8iqtecgeMtyCb2Qw6UM4IajH vMZQkByx+oZDYuP9y0hi1kRCr0jKxmVg50cmHryuUNptuLrhGjiLlwaK6 A==; X-IronPort-AV: E=McAfee;i="6500,9779,10469"; a="285216225" X-IronPort-AV: E=Sophos;i="5.93,313,1654585200"; d="scan'208";a="285216225" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Sep 2022 10:04:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,313,1654585200"; d="scan'208";a="649736840" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by orsmga001.jf.intel.com with ESMTP; 13 Sep 2022 10:04:38 -0700 Received: from orsmsx607.amr.corp.intel.com (10.22.229.20) by ORSMSX601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 13 Sep 2022 10:04:38 -0700 Received: from orsmsx607.amr.corp.intel.com (10.22.229.20) by ORSMSX607.amr.corp.intel.com (10.22.229.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 13 Sep 2022 10:04:38 -0700 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx607.amr.corp.intel.com (10.22.229.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31 via Frontend Transport; Tue, 13 Sep 2022 10:04:38 -0700 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (104.47.51.42) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2375.31; Tue, 13 Sep 2022 10:04:37 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=f+ogsTSL0aGyGfudFeSRN7QEysjgM+HPPeqqP38K+FiA+0q9KwIyG5jKlNfrE587Zqff1sxVCfMcOuDe2SDYeU6QG1GzF21TQjLFIfMLB0T4wxkxGEFsBQSPNkLG9gqDZcH9lQBcp5XlRjNKRdRsS5tPcMCo9kMGpUlo2kpRGgRRsTUdAtZGp+pNZqDqC4JaZ4JYubk5n6IrOsgHQG5s7409vDVDZBCva0EFm9FJmK8XHD7vojJpfbevPHlCOP/1gwrOJlfQdcI1M6f2HpSSuo9o7KMG0HvWjg7R8P7qXHD5gz75QBGjdZtuxWK+cKlqliun9jqSJGsXkTVR5m23sw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=c7fVtGfv8JV/uRlzCxh/uG09cKf0/Ve9v7CIjqCluMk=; b=oKMCcgh7iV4EDWzvD7VUMr8TZ4t4EwYMp/K34Uw64PonURhq9GuWMZxhrQlnJFZVu6qXTG40MpjU/2aouVMQ4dHMI7Omw+M5CcusCpSRtJUw0xdWuardsneDuCJjCmE4bb17eJMMuoJq2iqfl8J5dH9ESS4xPm0VxW9SnoUjHP1AvDfNRDhZBBI+EqOM+E1GTO3KaSxnkTFjTfqNnRyV678OhTbnKpguTv0weuORnfbaxBfywlk+uBegAORyrIJzNLEZvvXRZwYjQG3OLFBN/1uI6nDYlBZQftcRg/l2iTirBFqB7H21AOsR4EVl9MqDsp4ddXRDSO4f7ERg51omLw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from MWHPR11MB1629.namprd11.prod.outlook.com (2603:10b6:301:d::21) by CO1PR11MB4996.namprd11.prod.outlook.com (2603:10b6:303:90::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5612.14; Tue, 13 Sep 2022 17:04:36 +0000 Received: from MWHPR11MB1629.namprd11.prod.outlook.com ([fe80::13c:8120:d994:16d2]) by MWHPR11MB1629.namprd11.prod.outlook.com ([fe80::13c:8120:d994:16d2%6]) with mapi id 15.20.5612.022; Tue, 13 Sep 2022 17:04:36 +0000 Date: Tue, 13 Sep 2022 18:04:29 +0100 From: Bruce Richardson To: Juraj =?utf-8?Q?Linke=C5=A1?= CC: , , , , , , Subject: Re: [PATCH v4 5/9] dts: add ssh connection extension Message-ID: References: <20220728100044.1318484-1-juraj.linkes@pantheon.tech> <20220729105550.1382664-1-juraj.linkes@pantheon.tech> <20220729105550.1382664-6-juraj.linkes@pantheon.tech> Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220729105550.1382664-6-juraj.linkes@pantheon.tech> X-ClientProxiedBy: DB6PR0501CA0023.eurprd05.prod.outlook.com (2603:10a6:4:8f::33) To MWHPR11MB1629.namprd11.prod.outlook.com (2603:10b6:301:d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWHPR11MB1629:EE_|CO1PR11MB4996:EE_ X-MS-Office365-Filtering-Correlation-Id: 4457ee69-c9ba-43d0-5f78-08da95aa0931 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YQKqUuAb7EAPXA/eTfXz8An/woCHTCTOPhT6QTSnAKL9f3U3g/JBnEHiB5+UQ/gkr/sRBHMlgFBln5EvOXj9RELEoj2CRlolECNQT6ZglLRKa0GP+NulzL2Xz4Ies0LR7ZACHbyTK1MzZOLw+e8oJZKorfG7dsOgGu1vW8fyGr3Kizq/2l8z0t0t+hR/fZyDt6QwhtFMQx+elweLSnpdIE9CPjn4GqHHt9OqzdvZr1+l10+eQ+vLUvC02ndjKJs5t8wQbMLqcv4AIYIc8SSUwDwxvrFvmMNBcZKdLp1K9BV5GZKpyLznWZnsvWut6o+ouRi3jyKypb4/MvoGYq1xnXfy3j6FwxhiJJy320H2hWI4/nVL21+l1/FwQXejQZPaXlhVENurWpcOrhwfIvzj6vHOb4wcWhEApQmHfCXHDsTcb+MYC9OsYnSiyDjGWroptq/uwZ0YoFtJV9pymP3vVKKNk4N6YufYQ5RONbzU0KTubcp7axihC3fESX6uACeIopUXWFYNcaR1kbZq5S8NrhLBcgHku++iqJnYglKvHFL5NLH1Z+/gVMWq+JWyfN8nViiKubXl3vgaIjC9fxdsNALLGobUYnN5trra0hMmGPLt6tLHTi8BLdNXJ6Nd5LIAfrWdPqSfzy5WjYJ0j0Li7qhhtpw3KfuAG8C3/d+JaeuvCGtq8xkej3AhUTroUWOxL3Y5lVb7yPeGIfEcHJ0aZA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR11MB1629.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(396003)(376002)(136003)(366004)(39860400002)(346002)(451199015)(8936002)(66556008)(186003)(44832011)(66476007)(6666004)(38100700002)(66946007)(2906002)(6916009)(26005)(41300700001)(86362001)(83380400001)(6512007)(82960400001)(8676002)(4326008)(316002)(5660300002)(6486002)(6506007)(478600001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?Sm1mMlc4N0NXMFhZNjhHR2txYlc2VmNyREQxVDczN3ljMzc1OTVWdWx3ZUhh?= =?utf-8?B?eTJsM0d3djhBQXpiUWZ0T0c1VEExVnJBSnBYUjNXM2tpQlAvcGFZYXRwdno0?= =?utf-8?B?eFV5QUthZmZqNHh4MmovaUxpdnBxVnVuTHdmV3hObUZYanpWczRHZHhQWDZL?= =?utf-8?B?VlhmY2V5cDVxYzIyTS9taFF4K0xWenplWnJJS1dGWEluVUtlZTBOOUphNzlK?= =?utf-8?B?N2R0WENsamdIVHcxc2xGb2RxUTVGQ28yT29rb3hzN1U0OGpLSUxoTURlNWNo?= =?utf-8?B?enJ3T3hKbVRnK1dqVVBTK1JEYks3M1ZPbzJPVStwR3Y1OEd1VnlPTmtmVjRW?= =?utf-8?B?NE1WamtqVUFwZk5EY1FOVEFMNDVvSHI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?= =?utf-8?B?VGc9PQ==?= X-MS-Exchange-CrossTenant-Network-Message-Id: 4457ee69-c9ba-43d0-5f78-08da95aa0931 X-MS-Exchange-CrossTenant-AuthSource: MWHPR11MB1629.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2022 17:04:36.1149 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: hIfE7eudjyHZLbgMf5ouTG+wzqzxt2uptzPac2qtzQKQ+ysfR5LBBfxAyYNXOFHJqPzlWSOIdYR8hZnD65oGyyIqDkZZ23UWNdzoHt6OwC4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR11MB4996 X-OriginatorOrg: intel.com X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Fri, Jul 29, 2022 at 10:55:46AM +0000, Juraj Linkeš wrote: > The class adds logging and history records to existing pexpect methods. > > Signed-off-by: Owen Hilyard > Signed-off-by: Juraj Linkeš > --- > dts/framework/ssh_connection.py | 70 +++++++++++++++++++++++++++++++++ > 1 file changed, 70 insertions(+) > create mode 100644 dts/framework/ssh_connection.py > One comment inline below. /Bruce > diff --git a/dts/framework/ssh_connection.py b/dts/framework/ssh_connection.py > new file mode 100644 > index 0000000000..bbf7c8ef01 > --- /dev/null > +++ b/dts/framework/ssh_connection.py > @@ -0,0 +1,70 @@ > +# SPDX-License-Identifier: BSD-3-Clause > +# Copyright(c) 2010-2014 Intel Corporation > +# Copyright(c) 2022 PANTHEON.tech s.r.o. > +# Copyright(c) 2022 University of New Hampshire > +# > + > +import dataclasses > +from typing import Any, Optional > + > +from .logger import DTSLOG > +from .ssh_pexpect import SSHPexpect > + > + > +@dataclasses.dataclass(slots=True, frozen=True) > +class HistoryRecord: > + command: str > + name: str > + output: str | int > + > + > +class SSHConnection(object): > + """ > + Module for create session to node. > + """ > + > + name: str > + history: list[HistoryRecord] > + logger: DTSLOG > + session: SSHPexpect | Any > + > + def __init__( > + self, > + node: str, > + session_name: str, > + logger: DTSLOG, > + username: str, > + password: Optional[str] = "", > + ): > + self.session = SSHPexpect(node, username, password, logger) > + self.name = session_name > + self.history = [] > + self.logger = logger > + > + def send_expect( > + self, cmds: str, expected: str, timeout: float = 15, verify: bool = False > + ) -> str | int: > + self.logger.info(cmds) > + out = self.session.send_expect(cmds, expected, timeout, verify) > + if isinstance(out, str): > + self.logger.debug(out.replace(cmds, "")) > + self.history.append(HistoryRecord(command=cmds, name=self.name, output=out)) > + return out > + > + def send_command(self, cmds: str, timeout: float = 1) -> str: > + self.logger.info(cmds) > + out = self.session.send_command(cmds, timeout) > + self.logger.debug(out.replace(cmds, "")) > + self.history.append(HistoryRecord(command=cmds, name=self.name, output=out)) > + return out > + > + def get_session_before(self, timeout: float = 15) -> str: > + out = self.session.get_session_before(timeout) > + self.logger.debug(out) > + return out > + > + def close(self, force: bool = False) -> None: > + if getattr(self, "logger", None): > + self.logger.logger_exit() Two questions on this function: * Is the getattr() check not equivalent to "if self.logger:"? * Why the check for a non-none logger in this function, when other functions above always seem to call the logger directly without checking? > + > + self.session.close(force) > -- > 2.30.2 >