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

Cole Robinson crobinso at redhat.com
Tue Apr 3 16:21:47 UTC 2018


On 04/01/2018 09:36 AM, Mark Hamzy wrote:
> 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:

Thanks for the patch, but did you test on virt-manager git? It fails for
me, like Radostin said on python3 unquote has moved so the import fails.
Please make sure you are testing with latest virt-manager which is
python3 only

Thanks,
Cole




More information about the virt-tools-list mailing list