[virt-tools-list] Fw: [PATCH] support username and password in prepareLocation
Mark Hamzy
hamzy at us.ibm.com
Sat Mar 31 16:12:34 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 | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/virtinst/urlfetcher.py b/virtinst/urlfetcher.py
index da59a476..8bf24e08 100644
--- a/virtinst/urlfetcher.py
+++ b/virtinst/urlfetcher.py
@@ -207,13 +207,20 @@ class _FTPURLFetcher(_URLFetcher):
return
try:
- parsed = urllib.parse.urlparse(self.location)
- self._ftp = ftplib.FTP()
- self._ftp.connect(parsed.hostname, parsed.port or 0)
- self._ftp.login()
- # Force binary mode
- self._ftp.voidcmd("TYPE I")
- except Exception as e:
+ parsed = urllib.parse.urlparse(self.location)
+ self._ftp = ftplib.FTP()
+ from urllib2 import unquote
+ parsed = urlparse.urlparse(self.location)
+ 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(username, password)
+ # Force binary mode
+ self._ftp.voidcmd("TYPE I")
+ except Exception as e:
raise ValueError(_("Opening URL %s failed: %s.") %
(self.location, str(e)))
--
2.14.3
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/virt-tools-list/attachments/20180331/f1d48542/attachment.htm>
More information about the virt-tools-list
mailing list