From: "Liu, Yong" <yong.liu@intel.com>
To: "Qiu, Michael" <michael.qiu@intel.com>, "dts@dpdk.org" <dts@dpdk.org>
Subject: Re: [dts] [PATCH 3/6] framework: Add login password support
Date: Wed, 14 Jan 2015 01:18:25 +0000 [thread overview]
Message-ID: <86228AFD5BCD8E4EBFD2B90117B5E81E10D4C242@SHSMSX103.ccr.corp.intel.com> (raw)
In-Reply-To: <1421156540-25810-4-git-send-email-michael.qiu@intel.com>
That's good idea. DTS should support both with password and without password.
> -----Original Message-----
> From: Qiu, Michael
> Sent: Tuesday, January 13, 2015 9:42 PM
> To: dts@dpdk.org
> Cc: Liu, Yong; Qiu, Michael
> Subject: [PATCH 3/6] framework: Add login password support
>
> DTS login dut and tester machine via ssh service while
> public and private keys are needed.
>
> That means it can't use the user:password to login, which
> should not always be a good idea.
>
> Add login with password for another choice.
>
> Signed-off-by: Michael Qiu <michael.qiu@intel.com>
> ---
> framework/crbs.py | 1 +
> framework/dut.py | 12 ++++++++++--
> framework/etgen.py | 7 ++++++-
> framework/ssh_connection.py | 4 ++--
> framework/ssh_pexpect.py | 23 ++++++++++++-----------
> framework/tester.py | 12 ++++++++++--
> 6 files changed, 41 insertions(+), 18 deletions(-)
>
> diff --git a/framework/crbs.py b/framework/crbs.py
> index 77446c3..6aa5435 100644
> --- a/framework/crbs.py
> +++ b/framework/crbs.py
> @@ -10,6 +10,7 @@ crbs = [
> 'user': '',
> 'pass': '',
> 'tester IP': '',
> + 'tester pass': '',
> IXIA: None,
> 'memory channels': 4,
> 'bypass core0': True},
> diff --git a/framework/dut.py b/framework/dut.py
> index 4def144..d7099ef 100644
> --- a/framework/dut.py
> +++ b/framework/dut.py
> @@ -59,9 +59,11 @@ class Dut(Crb):
> super(Dut, self).__init__(crb, serializer)
> self.NAME = 'dut'
> self.logger = getLogger(self.NAME)
> - self.session = SSHConnection(self.get_ip_address(), self.NAME)
> + self.session = SSHConnection(self.get_ip_address(), self.NAME,
> + self.get_password())
> self.session.init_log(self.logger)
> - self.alt_session = SSHConnection(self.get_ip_address(), self.NAME)
> + self.alt_session = SSHConnection(self.get_ip_address(), self.NAME,
> + self.get_password())
> self.alt_session.init_log(self.logger)
> self.number_of_cores = 0
> self.tester = None
> @@ -120,6 +122,12 @@ class Dut(Crb):
> """
> return self.crb['IP']
>
> + def get_password(self):
> + """
> + Get DUT's login password.
> + """
> + return self.crb['pass']
> +
> def dut_prerequisites(self):
> """
> Prerequest function should be called before execute any test case.
> diff --git a/framework/etgen.py b/framework/etgen.py
> index fe7100c..2f2e975 100644
> --- a/framework/etgen.py
> +++ b/framework/etgen.py
> @@ -137,7 +137,9 @@ class IxiaPacketGenerator(SSHConnection):
> self.tester = tester
> self.NAME = 'ixia'
> self.logger = getLogger(self.NAME)
> - super(IxiaPacketGenerator, self).__init__(self.get_ip_address(),
> self.NAME)
> + super(IxiaPacketGenerator, self).__init__(self.get_ip_address(),
> + self.NAME,
> + self.get_password())
> super(IxiaPacketGenerator, self).init_log(self.logger)
>
> self.tcl_cmds = []
> @@ -170,6 +172,9 @@ class IxiaPacketGenerator(SSHConnection):
> def get_ip_address(self):
> return self.tester.get_ip_address()
>
> + def get_password(self):
> + return self.tester.get_password()
> +
> def add_tcl_cmd(self, cmd):
> """
> Add one tcl command into command list.
> diff --git a/framework/ssh_connection.py b/framework/ssh_connection.py
> index be1fb76..4306162 100644
> --- a/framework/ssh_connection.py
> +++ b/framework/ssh_connection.py
> @@ -40,8 +40,8 @@ class SSHConnection(object):
> Implement send_expect/copy function upper SSHPexpet module.
> """
>
> - def __init__(self, host, session_name):
> - self.session = SSHPexpect(host, USERNAME)
> + def __init__(self, host, session_name, password = ''):
> + self.session = SSHPexpect(host, USERNAME, password)
> self.name = session_name
>
> def init_log(self, logger):
> diff --git a/framework/ssh_pexpect.py b/framework/ssh_pexpect.py
> index 8fb441b..9c353e7 100644
> --- a/framework/ssh_pexpect.py
> +++ b/framework/ssh_pexpect.py
> @@ -12,12 +12,14 @@ Aslo support transfer files to tester or DUT.
>
> class SSHPexpect(object):
>
> - def __init__(self, host, username):
> + def __init__(self, host, username, password):
> try:
> self.session = pxssh.pxssh()
> self.username = username
> self.host = host
> - self.session.login(self.host, self.username)
> + self.password = password
> + self.session.login(self.host, self.username,
> + self.password, original_prompt='[$#>]')
> self.send_expect('stty -echo', '# ', timeout=2)
> except Exception:
> raise SSHConnectionException(host)
> @@ -69,21 +71,20 @@ class SSHPexpect(object):
> Copies a file from a remote place into local.
> """
> command = 'scp {0}@{1}:{2} .'.format(self.username, self.host, filename)
> - self._spawn_scp(command, password)
> + if password == '':
> + self._spawn_scp(command, self.password)
> + else:
> + self._spawn_scp(command, password)
>
> def copy_file_to(self, filename, password=''):
> """
> Sends a local file to a remote place.
> """
> command = 'scp {0} {1}@{2}:'.format(filename, self.username, self.host)
> - self._spawn_scp(command, password)
> -
> - def copy_file_from(self, filename, password=''):
> - """
> - copy a remote file to a local place.
> - """
> - command = 'scp {1}@{2}:{0} .'.format(filename, self.username, self.host)
> - self._spawn_scp(command, password)
> + if password == '':
> + self._spawn_scp(command, self.password)
> + else:
> + self._spawn_scp(command, password)
>
> def _spawn_scp(self, scp_cmd, password):
> """
> diff --git a/framework/tester.py b/framework/tester.py
> index d69503a..0ebe29a 100644
> --- a/framework/tester.py
> +++ b/framework/tester.py
> @@ -61,9 +61,11 @@ class Tester(Crb):
> self.NAME = 'tester'
>
> self.logger = getLogger(self.NAME)
> - self.session = SSHConnection(self.get_ip_address(), self.NAME)
> + self.session = SSHConnection(self.get_ip_address(),
> + self.NAME, self.get_password())
> self.session.init_log(self.logger)
> - self.alt_session = SSHConnection(self.get_ip_address(), self.NAME)
> + self.alt_session = SSHConnection(self.get_ip_address(),
> + self.NAME, self.get_password())
> self.alt_session.init_log(self.logger)
>
> self.ports_map = []
> @@ -88,6 +90,12 @@ class Tester(Crb):
> """
> return self.crb['tester IP']
>
> + def get_password(self):
> + """
> + Get tester login password of tester CRB.
> + """
> + return self.crb['tester pass']
> +
> def has_external_traffic_generator(self):
> """
> Check whether performance test will base on IXIA equipment.
> --
> 1.9.3
next prev parent reply other threads:[~2015-01-14 1:22 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-13 13:42 [dts] [PATCH 0/6] DTS enhancement and clean up Michael Qiu
2015-01-13 13:42 ` [dts] [PATCH 1/6] framework/tester: Fix NoneType Error of port_map Michael Qiu
2015-01-14 1:15 ` Liu, Yong
2015-01-25 1:07 ` Liu, Yong
2015-01-13 13:42 ` [dts] [PATCH 2/6] framework/crbs: Info clean up of crbs Michael Qiu
2015-01-25 1:07 ` Liu, Yong
2015-01-13 13:42 ` [dts] [PATCH 3/6] framework: Add login password support Michael Qiu
2015-01-14 1:18 ` Liu, Yong [this message]
2015-01-25 1:07 ` Liu, Yong
2015-01-13 13:42 ` [dts] [PATCH 4/6] framework/ssh: Add verify ability for command execution Michael Qiu
2015-01-14 1:24 ` Liu, Yong
2015-01-27 5:22 ` [dts] [PATCH v2] " Michael Qiu
2015-02-15 5:05 ` Liu, Yong
2015-01-13 13:42 ` [dts] [PATCH 5/6] framework: Fix ifname not found error Michael Qiu
2015-01-14 1:35 ` Liu, Yong
2015-01-13 13:42 ` [dts] [PATCH 6/6] framework/crb: rework restore_interfaces() Michael Qiu
2015-01-14 1:35 ` Liu, Yong
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=86228AFD5BCD8E4EBFD2B90117B5E81E10D4C242@SHSMSX103.ccr.corp.intel.com \
--to=yong.liu@intel.com \
--cc=dts@dpdk.org \
--cc=michael.qiu@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).