[Libguestfs] [PATCH v2 3/3] v2v: -o rhv-upload: Add a test.

Richard W.M. Jones rjones at redhat.com
Tue Nov 20 17:49:21 UTC 2018


On Tue, Nov 20, 2018 at 05:04:15PM +0000, Richard W.M. Jones wrote:
> >From 9aca67b9875ab31bea7f3aeec411dad3ed990f17 Mon Sep 17 00:00:00 2001
> From: "Richard W.M. Jones" <rjones at redhat.com>
> Date: Tue, 20 Nov 2018 17:00:33 +0000
> Subject: [PATCH] v2v: -o rhv-upload: Fix test so it doesn't fail if
>  Content-Length header missing.
> 
> If the Content-Length header was missing from the headers returned by
> the server then the test would fail with:
> 
> KeyError: 'content-length'
> 
> This happens on RHEL 7.6 in particular.  We can fix this by using an
> alternate method to fetch the header, which will return None instead
> of throwing an exception if the header doesn't exist.  See:
> https://stackoverflow.com/a/19255675
> ---
>  v2v/test-v2v-o-rhv-upload-module/ovirtsdk4/__init__.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/v2v/test-v2v-o-rhv-upload-module/ovirtsdk4/__init__.py b/v2v/test-v2v-o-rhv-upload-module/ovirtsdk4/__init__.py
> index 84b9d56aa..8d1058d67 100644
> --- a/v2v/test-v2v-o-rhv-upload-module/ovirtsdk4/__init__.py
> +++ b/v2v/test-v2v-o-rhv-upload-module/ovirtsdk4/__init__.py
> @@ -146,7 +146,7 @@ class RequestHandler(BaseHTTPRequestHandler):
>          self.end_headers()
>  
>      def discard_request(self):
> -        length = self.headers['Content-Length']
> +        length = self.headers.get('Content-Length')
>          if length:
>              length = int(length)
>              content = self.rfile.read(length)
> -- 
> 2.19.0.rc0

FYI I have tested this patch on Fedora 29 & RHEL 7 and the test now
succeeds on both.  Previously the test failed on RHEL 7.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://people.redhat.com/~rjones/virt-top




More information about the Libguestfs mailing list