From: "Chen, Zhaoyan" <zhaoyan.chen@intel.com>
To: "Ma, LihongX" <lihongx.ma@intel.com>, "dts@dpdk.org" <dts@dpdk.org>
Cc: "Chen, Zhaoyan" <zhaoyan.chen@intel.com>
Subject: Re: [dts] [PATCH V1 2/4] framework/ssh: add params to ssh scp function
Date: Thu, 2 Jan 2020 03:23:39 +0000 [thread overview]
Message-ID: <9DEEADBC57E43F4DA73B571777FECECA41E76C4D@SHSMSX104.ccr.corp.intel.com> (raw)
In-Reply-To: <1577404987-1369-2-git-send-email-lihongx.ma@intel.com>
Acked-by: Zhaoyan Chen <zhaoyan.chen@intel.com>
Regards,
Zhaoyan Chen
> -----Original Message-----
> From: Ma, LihongX <lihongx.ma@intel.com>
> Sent: Friday, December 27, 2019 8:03 AM
> To: dts@dpdk.org
> Cc: Chen, Zhaoyan <zhaoyan.chen@intel.com>; Ma, LihongX <lihongx.ma@intel.com>
> Subject: [dts][PATCH V1 2/4] framework/ssh: add params to ssh scp function
>
> add parameter crb_session to copy_file_from/to, when the parameter is not None,
> will copy file from/to the crb session, otherwise will copy file from/to current dts
> env.
>
> Signed-off-by: lihong <lihongx.ma@intel.com>
> ---
> framework/ssh_connection.py | 8 ++++----
> framework/ssh_pexpect.py | 27 +++++++++++++++++----------
> 2 files changed, 21 insertions(+), 14 deletions(-)
>
> diff --git a/framework/ssh_connection.py b/framework/ssh_connection.py index
> 312139e..afeef1c 100644
> --- a/framework/ssh_connection.py
> +++ b/framework/ssh_connection.py
> @@ -108,8 +108,8 @@ class SSHConnection(object):
>
> return True
>
> - def copy_file_from(self, src, dst=".", password=''):
> - self.session.copy_file_from(src, dst, password)
> + def copy_file_from(self, src, dst=".", password='', crb_session=None):
> + self.session.copy_file_from(src, dst, password, crb_session)
>
> - def copy_file_to(self, src, dst="~/", password=''):
> - self.session.copy_file_to(src, dst, password)
> + def copy_file_to(self, src, dst="~/", password='', crb_session=None):
> + self.session.copy_file_to(src, dst, password, crb_session)
> diff --git a/framework/ssh_pexpect.py b/framework/ssh_pexpect.py index
> df8da8a..979327c 100644
> --- a/framework/ssh_pexpect.py
> +++ b/framework/ssh_pexpect.py
> @@ -163,7 +163,7 @@ class SSHPexpect(object):
> def isalive(self):
> return self.session.isalive()
>
> - def copy_file_from(self, src, dst=".", password=''):
> + def copy_file_from(self, src, dst=".", password='', crb_session=None):
> """
> Copies a file from a remote place into local.
> """
> @@ -172,11 +172,11 @@ class SSHPexpect(object):
> command = 'scp -v -P {0} -o NoHostAuthenticationForLocalhost=yes
> {1}@{2}:{3} {4}'.format(
> str(self.port), self.username, self.ip, src, dst)
> if password == '':
> - self._spawn_scp(command, self.password)
> + self._spawn_scp(command, self.password, crb_session)
> else:
> - self._spawn_scp(command, password)
> + self._spawn_scp(command, password, crb_session)
>
> - def copy_file_to(self, src, dst="~/", password=''):
> + def copy_file_to(self, src, dst="~/", password='', crb_session=None):
> """
> Sends a local file to a remote place.
> """
> @@ -188,16 +188,23 @@ class SSHPexpect(object):
> command = 'scp -v {0} {1}@{2}:{3}'.format(
> src, self.username, self.host, dst)
> if password == '':
> - self._spawn_scp(command, self.password)
> + self._spawn_scp(command, self.password, crb_session)
> else:
> - self._spawn_scp(command, password)
> + self._spawn_scp(command, password, crb_session)
>
> - def _spawn_scp(self, scp_cmd, password):
> + def _spawn_scp(self, scp_cmd, password, crb_session):
> """
> Transfer a file with SCP
> """
> self.logger.info(scp_cmd)
> - p = pexpect.spawn(scp_cmd)
> + # if crb_session is not None, copy file from/to crb env
> + # if crb_session is None, copy file from/to current dts env
> + if crb_session is not None:
> + crb_session.session.clean_session()
> + crb_session.session.__sendline(scp_cmd)
> + p = crb_session.session.session
> + else:
> + p = pexpect.spawn(scp_cmd)
> time.sleep(0.5)
> ssh_newkey = 'Are you sure you want to continue connecting'
> i = p.expect([ssh_newkey, '[pP]assword', "# ", pexpect.EOF, @@ -212,5 +219,5
> @@ class SSHPexpect(object):
> p.expect("Exit status 0", 60)
> if i == 4:
> self.logger.error("SCP TIMEOUT error %d" % i)
> -
> - p.close()
> + if crb_session is None:
> + p.close()
> --
> 2.7.4
next prev parent reply other threads:[~2020-01-02 3:23 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-27 0:03 [dts] [PATCH V1 1/4] conf/crbs: add param which can config the dpdk tar side lihong
2019-12-27 0:03 ` [dts] [PATCH V1 2/4] framework/ssh: add params to ssh scp function lihong
2020-01-02 3:23 ` Chen, Zhaoyan [this message]
2019-12-27 0:03 ` [dts] [PATCH V1 3/4] framework/config: read config value of snapshot_load_side lihong
2020-01-02 3:23 ` Chen, Zhaoyan
2019-12-27 0:03 ` [dts] [PATCH V1 4/4] framework/project_dpdk: add judge of the value about snapshot_load_side lihong
2020-01-02 3:23 ` Chen, Zhaoyan
2019-12-31 6:43 ` [dts] [PATCH V1 1/4] conf/crbs: add param which can config the dpdk tar side Chen, Zhaoyan
2020-01-02 3:28 ` Tu, Lijuan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9DEEADBC57E43F4DA73B571777FECECA41E76C4D@SHSMSX104.ccr.corp.intel.com \
--to=zhaoyan.chen@intel.com \
--cc=dts@dpdk.org \
--cc=lihongx.ma@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).