Bug 1086554

Summary: Error info is not clear when network install vm with url "ftp://"
Product: Red Hat Enterprise Linux 7 Reporter: zhengqin <zsong>
Component: virt-managerAssignee: Giuseppe Scrivano <gscrivan>
Status: CLOSED UPSTREAM QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.0CC: codong, dyuan, gscrivan, lcui, mzhan, tzheng
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1086561 (view as bug list) Environment:
Last Closed: 2014-04-14 13:21:50 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:
Bug Depends On:    
Bug Blocks: 1086561    

Description zhengqin 2014-04-11 06:23:41 UTC
Description of problem:
For Network Install VM, If you just input install url with "ftp://", the error message shows: "Unable to complete install: NoneType object has no attribute 'sendall'"

Version-Release number of selected component:
virt-manager-0.10.0-20.el7.noarch

How reproducible:
100%

Steps to Reproduce:
1. Start virt-manager.

2. Create a new vm by "Network Install" until "step 2 of 5" on New VM window, just input a install URL with "ftp://"

3. Forward the New VM window util "Step 5 of 5" window, and click "Finish" button



Actual result:
1. Error message shows: "Unable to complete install: NoneType object has no attribute 'sendall'", and this error is not clear.


Expected results:
1. An error will be shown if you input install url with "http://", "Unable to complete install: Invalid install location: Opening URL http:// failed"


Additional info:
1. This issue does not occur with install url "http://" or "nfs:"
2. If set a wrong ftp url eg:ftp://test, the error info is also unclear:Unable to complete install: '[Errno -2] Name or service not known'
3. This issue also occurs on latest rhel6u5.

Comment 1 Giuseppe Scrivano 2014-04-14 13:14:21 UTC
both the cryptic error message and the exception come from the python ftplib.FTP class, where the exception message is not clear.  Reproducer:

>>> ftp = FTP('foo')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.7/ftplib.py", line 117, in __init__
    self.connect(host)
  File "/usr/lib64/python2.7/ftplib.py", line 132, in connect
    self.sock = socket.create_connection((self.host, self.port), self.timeout)
  File "/usr/lib64/python2.7/socket.py", line 553, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
socket.gaierror: [Errno -2] Name or service not known


>>> ftp = FTP('')
>>> ftp.login()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.7/ftplib.py", line 387, in login
    resp = self.sendcmd('USER ' + user)
  File "/usr/lib64/python2.7/ftplib.py", line 243, in sendcmd
    self.putcmd(cmd)
  File "/usr/lib64/python2.7/ftplib.py", line 178, in putcmd
    self.putline(line)
  File "/usr/lib64/python2.7/ftplib.py", line 173, in putline
    self.sock.sendall(line)
AttributeError: 'NoneType' object has no attribute 'sendall'


patch proposed upstream:

https://www.redhat.com/archives/virt-tools-list/2014-April/msg00079.html

Comment 2 Giuseppe Scrivano 2014-04-15 04:56:05 UTC
fixed by:

commit 1d312a520e92e89da1b4d958b9de0270eecc6b4b
Author: Giuseppe Scrivano <gscrivan>
Date:   Mon Apr 14 14:49:21 2014 +0200

    virtinst: early detect ftp connection errors
    
    It fixes two problems:
    
    i) "ftp://" was accepted as valid URL but then it causes this
    exception:
    
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/usr/lib64/python2.7/ftplib.py", line 387, in login
        resp = self.sendcmd('USER ' + user)
      File "/usr/lib64/python2.7/ftplib.py", line 243, in sendcmd
        self.putcmd(cmd)
      File "/usr/lib64/python2.7/ftplib.py", line 178, in putcmd
        self.putline(line)
      File "/usr/lib64/python2.7/ftplib.py", line 173, in putline
        self.sock.sendall(line)
    AttributeError: 'NoneType' object has no attribute 'sendall'
    
    ii) only a cryptic error message "Unable to complete install: '[Errno
    -2] Name or service not known'" was showed to users when the DNS
    lookup failed.  The exception is now intercepted and decorated with
    more information.
    
    Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1086554
    
    Signed-off-by: Giuseppe Scrivano <gscrivan>