[virt-tools-list] Fw: [PATCH] support username and password in prepareLocation

Mark Hamzy hamzy at us.ibm.com
Sun Apr 1 13:36:10 UTC 2018


If --location is an ftp url with a username and password
then virt-install fails to install with an error:
ERROR Error validating install location: Opening URL u failed: 530 Login 
incorrect..
---
 virtinst/urlfetcher.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/virtinst/urlfetcher.py b/virtinst/urlfetcher.py
index da59a476..b87279bb 100644
--- a/virtinst/urlfetcher.py
+++ b/virtinst/urlfetcher.py
@@ -209,8 +209,14 @@ class _FTPURLFetcher(_URLFetcher):
         try:
             parsed = urllib.parse.urlparse(self.location)
             self._ftp = ftplib.FTP()
+            from urllib import unquote
+            username = parsed.username or ''
+            username = unquote(username).decode('utf8')
+            password = parsed.password or ''
+            password = unquote(password).decode('utf8')
+            self._ftp = ftplib.FTP(parsed.hostname, username, password)
             self._ftp.connect(parsed.hostname, parsed.port or 0)
-            self._ftp.login()
+            self._ftp.login(username, password)
             # Force binary mode
             self._ftp.voidcmd("TYPE I")
         except Exception as e:
-- 
2.14.3




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/virt-tools-list/attachments/20180401/53a809ac/attachment.htm>


More information about the virt-tools-list mailing list