aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/ssh.py
AgeCommit message (Collapse)AuthorFilesLines
2019-02-06Debugging information when dpdk bind fails should be improvedDanielMartinBuckley1-0/+2
JIRA: YARDSTICK-1585 When dpdk-devbind.py is failing, the information provided is poor, making it difficult to debug. At least the exact command used should be printed, ideally with the returned error. As of today, the more interesting line is DpdkBindHelperException: /opt/nsb_bin/dpdk-devbind.py command failed with rc=1 Change-Id: I7831c81ffa9e1f4695480eb140fa97a58ff88f8c Signed-off-by: Daniel Martin Buckley <daniel.m.buckley@intel.com>
2019-02-06Merge "Improve SSH to Open/Close interactive terminal"Volodymyr Mytnyk1-0/+80
2019-01-18Remove redundant commentEmma Foley1-8/+0
Change-Id: I6f301b0a3d77a692aa06d570eaa6ef3e820973d7 Signed-off-by: Emma Foley <emma.l.foley@intel.com>
2019-01-14Improve SSH to Open/Close interactive terminaltreyad1-0/+80
Support Open/Close interactive terminal on a SSH channel. Support Execute command on interactive terminal. JIRA: YARDSTICK-1482 Change-Id: I0d1588707c3fb3e5e65fb72115f27e713d4b4828 Signed-off-by: treyad <treyad@viosoft.com>
2018-08-02Change AutoConnectSSH to return error code by defaultMytnyk, Volodymyr1-1/+1
AutoConnectSSH execute method always returns exception when remote command returns non 0 ret code. This behavior has been introduced by https://gerrit.opnfv.org/gerrit/#/c/58579/ changes which break the NSB functionality. There are 200+ places where return code (event non zoro) is expected to be returned by AutoConnectSSH.execute() method. Right now the method returns always exception in case of remote command return not zero which causes the problem. Changed execute() method to have previous behavior (raise_on_error is always False by default) and the exception is raised only in case if raise_on_error=True is set explicitly. Added UT. JIRA: YARDSTICK-1365 Change-Id: Ib067583ea5eb704b9174084b45b920c24eb307ac Signed-off-by: Mytnyk, Volodymyr <volodymyrx.mytnyk@intel.com>
2018-07-31Fix remote command execution in common.utilsMiikka Koistinen1-2/+3
yardstick.common.utils get_port_mac and get_port_ip both raise a RuntimeError on positive remote command exit status. This commit fixes them to use the error raising mechanism in yardstick.ssh.SSH. Additionally, the class AutoConnectSSH class needed an additional argument to allow the raising mechanism to work correctly. JIRA: YARDSTICK-1240 Change-Id: Idad125ebbd668cef10a6149eb3e601a437a8d40d Signed-off-by: Miikka Koistinen <miikka.koistinen@nokia.com>
2018-06-19Refactor remote command execution in pktgenMiikka Koistinen1-5/+7
Some remote commands in Pktgen are executed without checking the exit status. This patch makes all remote commands check exit value, and removes unused variables that are captured from remote command executions. JIRA: YARDSTICK-1166 Change-Id: I42a667ebd22d086887d61e1671bc569b03c59d33 Signed-off-by: Miikka Koistinen <miikka.koistinen@nokia.com>
2018-06-01Convert SSH custom exceptions to Yardstick exceptionsRodolfo Alonso Hernandez1-24/+25
JIRA: YARDSTICK-1215 Change-Id: I5ecfd3dccd91b07cd8de5309dfa1a372eff16ed0 Signed-off-by: Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
2018-03-01NSB: move interface probe to VNF, and attempt driver-only probe firstRoss Brattain1-21/+47
If no devices are present we can't detect MAC address so we can't match Heat ports to interfaces. If only the driver is missing we can try to probe the driver using lspci. We can use lspci to ask the kernel what driver it should use for the PCI device. If we can't probe at all because the device is already bound, we can use dpkd-devind to find all the PCI address we care about and create a map with PCI device and real kernel driver. Then we can dpdk force rebind to the kernel driver. Once we have rebound to the kernel driver we can detect MAC address and all the other attributes that are required. Fix VnfSshHelper to allow override of wait timeout And a bunch of other refactors that got swept up in this JIRA: YARDSTICK-835 Change-Id: I14cb657ed289a77941d048345d06ced5b5d5da52 Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
2017-12-25Add get function in ssh.pyJingLu51-0/+6
JIRA: YARDSTICK-904 This task is about to implement a get function in ssh.py to fetch desired files/folder in a remote VM to a local path. In some test cases, test tools will produce results in files. We want retain the original result files and archive them in Yardstick docker for future usage. Change-Id: Ifd333eb044ce31cffa6f5b2a8f6a46648a8858d1 Signed-off-by: JingLu5 <lvjing5@huawei.com>
2017-09-15Generate pod.yaml from current contextRoss Brattain1-0/+9
We want to generate pod.yaml from Heat contexts so we can re-use the context without destroying it. But we don't have node role information and it doesn't make sense in this case, so make the role optional. Since we changed Heat to use pkey instead of key_filename, we can embed the pkey into the pod.yaml, but we have to make sure to convert the pkey to string, in case it is a RSAKey object Change-Id: Ibefcfbd8236e68013a704c39964cb870da825da8 Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
2017-09-13ssh fix, always waitRoss Brattain1-1/+2
Change-Id: I1c529eeb0ef47752ed15e3e7941f57f7793ebfd4 Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
2017-08-21ssh: add new get_file_obj method to fetch remote filesRoss Brattain1-0/+10
We can either cat remote files, or we can just sftp get them. use sftp get for /proc/cpuinfo since it can be so very large on systems with 88+ cores. Change-Id: I420b8c5eefdce8bb3e3b13dcc8257583dee537c1 Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
2017-08-08NSB updateDeepak S1-18/+129
Refactored main NSB VNF classes accroding to class diagram https://wiki.opnfv.org/display/yardstick/NSB+class+diagram All the SampleVNFs have been separated and placed under the SampleVNF class. Added AutoConnectSSH to automatically create SSH conneciton on demand. Added VnfdHelper class to wrap the VNFD dictionary in prepartion for class-based modeling. Extracted DpdkVnfSetupEnvHelper for DPDK based VNF setup. Extracted Stats and other client config to ResourceHelper Had to replace dict_key_flatten with deepgetitem due to Python 2.7 Jinja2 infinite recursion. Change-Id: Ia8840e9c44cdbdf39aab6b02e6d2176b31937dc9 Signed-off-by: Deepak S <deepak.s@linux.intel.com> Signed-off-by: Edward MacGillivray <edward.s.macgillivray@intel.com> Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
2017-04-11standardize ssh authRoss Brattain1-2/+24
we need to be following defautl paramiko rules, first use pkey, then key_filenames (autodetecting ~/.ssh/ keys), then password We have too much boilerplate redudant code everywhere, we need to standardize on a factory function that takes a node dict. Using Python3 ChainMap we can layer overrides and defaults. VNF descriptors have to default key_filename, password to Python None. The only way to do this is to omit key values if the variable is not defined, this way the dict will not have the value and it will default to Python None Add python2 chainmap backport Updated unittest mocking to use ssh.SSH.from_node Change-Id: I80b0cb606e593b33e317c9e5e8ed0b74da591514 Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
2017-01-19Verify stdin data before doing encodeutils safe_encodeDeepak S1-2/+5
Process running via ssh can return "None" or emtpy data from the application. To avoid encodutils raise NoneType issue. Check the data before encode. JIRA: YARDSTICK-539 Change-Id: I7e86e6a17c0adc95d41714f6fec463dfadc2b81b Signed-off-by: Deepak S <deepak.s@linux.intel.com>
2017-01-12Add support for Python 3Ross Brattain1-5/+10
Porting to Python3 using Openstack guidelines: https://wiki.openstack.org/wiki/Python3 This passes unittests on Python 3.5 and passes opnfv_smoke suite Updates: use six for urlparse and urlopen fix exception.message attribute removal run unittests on python3 use unitest.mock on python 3 fix open mock for vsperf fix float division by using delta/eplison comparison use unicode in StringIO use plugin/sample_config.yaml relative path from test case fixed apexlake unittests upgraded to mock 2.0.0 to match python3 unittest.mock features fixed flake8 issues implement safe JSON decode with oslo_serialization.jsonutils.dump_as_bytes() implement safe unicode encode/decode with oslo_utils.encodeutils heat: convert pub key file from bytes to unicode pkg_resources returns raw bytes, in python3 we have to decode this to utf-8 unicode so JSON can encode it for heat template JIRA: YARDSTICK-452 Change-Id: Ib80dd1d0c0eb0592acd832b82f6a7f8f7c20bfda Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
2016-12-20ssh: don't quote ~ in remotepathsRoss Brattain1-6/+10
~ is not expanded in double quotes, so we have a dilemma. We need to quote in order to preserve filenames with spaces, but we have to make sure we don't quote the ~ so it can be expanded. To resolve this we use a regex to search for tidle-prefixes and excluded them from quotes. Added unittests for the cases: path with tilde path with space path with tilde and space see bash man page for details of tidle expansion Tilde Expansion If a word begins with an unquoted tilde character (`~'), all of the characters preceding the first unquoted slash (or all characters, if there is no unquoted slash) are considered a tilde-prefix. If none of the characters in the tilde-prefix are quoted, the characters in the tilde-prefix following the tilde are treated as a possible login name. If this login name is the null string, the tilde is replaced with the value of the shell parameter HOME. If HOME is unset, the home directory of the user executing the shell is substituted instead. Otherwise, the tilde-prefix is replaced with the home directory associated with the specified login name. JIRA: YARDSTICK-501 Change-Id: I324be20aba0dbd50434fbd8081685c598ebd8a84 Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
2016-12-20BugFix: remotepath cannot be foundJingLu51-3/+3
JIRA: YARDSTICK-501 An redundant pair of quotation in ssh.py causes remotepath cannot be found. Change-Id: I2df8ab59830fd28d8ad8882a93a8efbd4d1f7cb7 Signed-off-by: JingLu5 <lvjing5@huawei.com>
2016-12-08ssh.py: add flag to request for a pseudo terminal (pty) for ssh connectionDeepak S1-3/+9
For some VNFs we may want to send periodic commands, for example to print statistics etc. When you open a SSH connection, request a pseudo terminal (pty) which allows passing of control characters to the connection. JIRA: YARDSTICK-453 Change-Id: Ibfd4164e745f005d0e29f6efdc63076e1e220b60 Signed-off-by: Deepak S <deepak.s@linux.intel.com>
2016-12-05Merge "fix SSH object examples to use correct context manager form"Rex Lee1-8/+13
2016-12-05Merge "import new _put_file_shell method from upstream rally"Rex Lee1-0/+34
2016-12-01Merge "ssh.py: add flag to keep stdin open"Rex Lee1-10/+18
2016-11-30switch logging to proper usageRoss Brattain1-4/+4
The logging methods do string interpolation themselves From the reference: https://docs.python.org/2/library/logging.html#logging.Logger.debug Logger.debug(msg, *args, **kwargs) Logs a message with level DEBUG on this logger. The msg is the message format string, and the args are the arguments which are merged into msg using the string formatting operator. (Note that this means that you can use keywords in the format string, together with a single dictionary argument.) There are two keyword arguments in kwargs which are inspected: exc_info which, if it does not evaluate as false, causes exception information to be added to the logging message. If an exception tuple (in the format returned by sys.exc_info()) is provided, it is used; otherwise, sys.exc_info() is called to get the exception informatio The reason logging does string interpolation itselfs is to implement deferred interpolation. String interpolation involves evaluating arguments, so it can introduce significant computation. The logging module tries to be smart about deferring interpolation until the last possible moment. The logging methods check isEnabledFor for the log level and won't interpolate if the level is not enabled. https://github.com/python/cpython/blob/2.7/Lib/logging/__init__.py#L1178 def warning(self, msg, *args, **kwargs): if self.isEnabledFor(WARNING): self._log(WARNING, msg, args, **kwargs) logging actually waits to interpolate the string in LogRecord.getMessage() https://github.com/python/cpython/blob/2.7/Lib/logging/__init__.py#L328 if self.args: msg = msg % self.args Change-Id: Ie09efe0a66881e19bd8119caa376075e605627a2 Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
2016-11-30import new _put_file_shell method from upstream rallyRoss Brattain1-0/+34
upstream openstack rally added new _put_file_* methods we should use these https://github.com/openstack/rally/blob/0.7.0/rally/common/sshutils.py#L270 Updates: imported rally test__put_file_shell unittests quote to prevent word split use -- guard only chmod on cat success Change-Id: I357d1a66b5beddad8042958f4e55d67fc68929f6 Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
2016-11-29centralize logging into root loggerRoss Brattain1-7/+18
If we setup root logger correctly and have each module logger propogate we shouldn't need individual logger configuration updates: lower paramiko to WARN level dispatcher/file.py was missing logging.handlers import purge all existing handlers and add our own handlers move everything back into yardstick/__init__.py so API can use it make _LOG_STREAM_HDLR global, so we can set loglevel on it whenever added api/server.py call to _init_logging removed old LOG_FORMATTER from cli.py only setLevel on yardstick logger Change-Id: If000799590379d3407655a7d54378481a96ea3d4 Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
2016-11-29fix SSH object examples to use correct context manager formRoss Brattain1-8/+13
change PseudoFile example to use io.RawIOBase baseclass Change-Id: Ib5e3c844a0514274e5098061beb0ee6f8af97977 Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
2016-11-21ssh.py: add flag to keep stdin openRoss Brattain1-10/+18
For some VNFs we may want to send periodic commands, for example to print statistics, but otherwise not write anything for long periods of time. Currently when we can no longer read from stdin we close it. A workaround is to constantly spam stdin with newlines to keep forcing stdin open. We don't want to have to do this, so add an enable flag to keep stdin open. If the caller wants to close stdin at some point it can. Change-Id: I9496022295dfd19804572e484fe4f170ca7d4ac3 Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
2016-11-10add option to connect to non-standard ssh portRoss Brattain1-2/+5
not all enviroments have port 22 enabled for SSH. In particular for network isolation NAT and port forwarding may be used. example pod.yaml: nodes: - ip: 10.2.45.145 name: node1 password: '' role: Controller ssh_port: 5000 user: root - ip: 10.2.45.145 name: node2 password: '' role: Controller ssh_port: 5001 user: root - ip: 10.2.45.145 name: node3 password: '' role: Controller ssh_port: 5002 user: root JIRA: YARDSTICK-407 Change-Id: I8f9d6e388f31d291dd15cb900d7f71f347e41ef6 Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
2016-08-15bug fix: ssh authentiation error when run compass scenario in fuelrexlee87761-1/+3
JIRA: YARDSTICK-319 Change-Id: I25ee9a2582c751024b30e91eabf77aebb14a02f7 Signed-off-by: rexlee8776 <limingjiang@huawei.com>
2016-08-12[Yardstick-233]latency measurment by using pktgen-dpdkwu.zhihui1-0/+5
VM A runs pktgen-dpdk as a traffic generator and is connected back-to-back with VM B running testpmd for forwarding packets. 1. use linux expect to fetch the latency statics data. 2. fetch 10 samples of latency and calculate avg_latency. 3. use screen to keep test scripts running in the background. 4. add a function send_command() for screen in ssh.py JIRA:YARDSTICK-233 Change-Id: I90ae64b3d198c79f159275ae35715eb284f05080 Signed-off-by: wu.zhihui <wu.zhihui1@zte.com.cn>
2016-01-10Support run cyclictest on BareMetalQiLiang1-0/+7
JIRA: YARDSTICK-122 Change-Id: I8144215059a9abea08314a4c1e6a733dcdf0df53 Signed-off-by: QiLiang <liangqi1@huawei.com>
2015-05-20add ssh moduleHans Feldt1-0/+256
The ssh module is used when executing benchmark scenarios using remote login to a VM. ssh.py originates from rally but is stripped down and slightly modified (some dependencies removed). Change-Id: I0dc479fa1cb06e7469c20e24d3124f020b97a73c JIRA: - Signed-off-by: Hans Feldt <hans.feldt@ericsson.com>