[virt-tools-list] [virt-manager] [PATCHv2] urlfetcher: Add support for FTP authentication

Cole Robinson crobinso at redhat.com
Tue Apr 24 16:19:56 UTC 2018


On 04/18/2018 09:23 AM, Radostin Stoyanov wrote:
> From: Mark Hamzy <hamzy at us.ibm.com>
> 
> 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..
> ---
> This is a tweaked version of Mark Hamzy's patch
> https://www.redhat.com/archives/virt-tools-list/2018-April/msg00000.html
> Changes from v1: Set username and password to empty string by default.
> This avoids the error: 'NoneType' is not iterable
> 
>  virtinst/urlfetcher.py | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/virtinst/urlfetcher.py b/virtinst/urlfetcher.py
> index fe410805..afc461b0 100644
> --- a/virtinst/urlfetcher.py
> +++ b/virtinst/urlfetcher.py
> @@ -224,8 +224,10 @@ class _FTPURLFetcher(_URLFetcher):
>          try:
>              parsed = urllib.parse.urlparse(self.location)
>              self._ftp = ftplib.FTP()
> +            username = urllib.parse.unquote(parsed.username or '')
> +            password = urllib.parse.unquote(parsed.password or '')
>              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! pushed now

- Cole




More information about the virt-tools-list mailing list