Bug 976504

Summary: pxssh.py wrong timeout
Product: Red Hat Enterprise Linux 6 Reporter: Benjamin <bkruell>
Component: pexpectAssignee: Marek Grac <mgrac>
Status: CLOSED WONTFIX QA Contact: BaseOS QE - Apps <qe-baseos-apps>
Severity: low Docs Contact:
Priority: unspecified    
Version: 6.3CC: apevec, cluster-maint, mgrac
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-08-19 07:52:31 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Benjamin 2013-06-20 17:15:44 UTC
Description of problem:
cannot use pxssh.py which is part of pexpect, always running into timeout:



Version-Release number of selected component (if applicable):
pexpect-2.3-6.el6.noarch

How reproducible:
echo <<EOF > ssh.py
import pxssh
s = pxssh.pxssh()
if not s.login ('localhost', 'myuser', 'mypass'):
    print "SSH session failed on login."
    print str(s)
else:
    print "SSH session login successful"
    s.sendline ('ls -l')
    s.prompt()         # match the prompt
    print s.before     # print everything before the prompt.
    s.logout()
EOF

Steps to Reproduce:
1. python ssh.py
2. see error msg

Actual results:
Traceback (most recent call last):
  File "ssh.py", line 3, in <module>
    if not s.login ('localhost', 'myuser', 'mypassword'):
  File "/usr/lib/python2.6/site-packages/pxssh.py", line 243, in login
    if not self.synch_original_prompt():
  File "/usr/lib/python2.6/site-packages/pxssh.py", line 134, in synch_original_prompt
    self.read_nonblocking(size=10000,timeout=1) # GAS: Clear out the cache before getting the prompt
  File "/usr/lib/python2.6/site-packages/pexpect.py", line 815, in read_nonblocking
    r,w,e = self.__select([self.child_fd], [], [], timeout)
  File "/usr/lib/python2.6/site-packages/pexpect.py", line 1549, in __select
    return select.select (iwtd, owtd, ewtd, timeout)


Expected results:
Output of ssh command "ls -l"

Additional info:
Fix:
132a133,134
>         self.sendline()
>         time.sleep(0.5)

add this before line 134, and it works as expected.
This should also affect rhel5 pexpect package, but not verified.

Comment 2 Marek Grac 2013-06-24 09:30:22 UTC
@Benjamin:

Thanks for bugreport. According to my research it is enough to just add 

self.sendline()

can you confirm it too? I would prefer not to add additional delays if it is not necessary.

Comment 6 Marek Grac 2014-04-30 14:05:41 UTC
@Alan: 

pexpect-u ->
it requires python3 which will be in rhel7 only partially and fence-agents were not tested with it at all

package renaming -> it was obtained from fedora and no-one complained, otherwise it will be fixed; this way we have to wait for rhel8