Re: [Libguestfs] [PATCH] v2v: -o rhv-upload: Optimize http request sending
On Mon, Jun 18, 2018 at 09:58:23PM +0300, Nir Soffer wrote: > On Mon, Jun 18, 2018 at 9:23 PM Richard W.M. Jones > wrote: > > > On Mon, Jun 18, 2018 at 08:55:13PM +0300, Nir Soffer wrote: > > > On Mon, Jun 18, 2018 at 1:37 PM Richard W.M. Jones > > > wrote: > > > > > > > On Thu, Jun 14, 2018 at 09:24:48PM +0300, Nir Soffer wrote: > > > > > On Thu, Jun 14, 2018 at 9:16 PM Nir Soffer wrote: > > > > > > +headers = {"Content-Type": "application/json", > > > > > > + "Content-Length", str(len(buf))} > > > > > > > > There were a few Python syntax errors such as this one. They > > > > can be found by running: > > > > > > > > make -C v2v check TESTS=test-v2v-python-syntax.sh > > > > > > > > > > Cool. Why not include this in "make check"? > > > > It is! That command is just if you want to run the single test. > > > > Strange, I did run "make check" but it did not fail on checking > the rhv plugin. It was failing because of unralted c-api test. > > Maybe make aborted before running the v2v tests? Right, it runs the tests in subdirectories in order and aborts at the first subdirectory which fails (this is just how make / automake works, it's nothing special to libguestfs): $ make print-subdirs | fold -72 -s common/mlstdutils generator tests/qemu test-data gnulib/lib gnulib/tests common/errnostring common/protocol common/qemuopts common/utils common/structs lib docs examples po common/mlutils common/mlaugeas common/mlpcre daemon tests/daemon appliance tests/c-api tests/tmpdirs tests/protocol tests/events tests/parallel tests/create tests/disks tests/discard tests/mountable tests/network tests/lvm tests/luks tests/md tests/selinux tests/relabel tests/ntfs tests/btrfs tests/xfs tests/charsets tests/xml tests/mount-local tests/9p tests/rsync tests/bigdirs tests/disk-labels tests/hotplug tests/nbd tests/http tests/syslinux tests/journal tests/relative-paths tests/gdisk tests/regressions tests/tsk tests/yara common/edit common/options common/parallel common/progress common/visit common/windows test-tool fish align cat diff df edit format inspector make-fs rescue common/miniexpect p2v bash perl perl/examples ocaml ocaml/examples python python/examples ruby ruby/examples java java/examples php erlang erlang/examples lua lua/examples gobject csharp common/mlgettext common/mlprogress common/mlvisit common/mlxml common/mltools customize builder builder/templates get-kernel resize sparsify sysprep v2v v2v/test-harness dib tools fuse utils/boot-analysis utils/boot-benchmark utils/max-disks utils/qemu-boot utils/qemu-speed-test po-docs If you want it to continue after the first failure (this also applies to every automake-using program) then do: make check -k less `find -name test-suite.log | xargs grep -l ^FAIL:` Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-builder quickly builds VMs from scratch http://libguestfs.org/virt-builder.1.html ___ Libguestfs mailing list Libguestfs@redhat.com https://www.redhat.com/mailman/listinfo/libguestfs
Re: [Libguestfs] [PATCH] v2v: -o rhv-upload: Optimize http request sending
On Mon, Jun 18, 2018 at 9:23 PM Richard W.M. Jones wrote: > On Mon, Jun 18, 2018 at 08:55:13PM +0300, Nir Soffer wrote: > > On Mon, Jun 18, 2018 at 1:37 PM Richard W.M. Jones > > wrote: > > > > > On Thu, Jun 14, 2018 at 09:24:48PM +0300, Nir Soffer wrote: > > > > On Thu, Jun 14, 2018 at 9:16 PM Nir Soffer wrote: > > > > > +headers = {"Content-Type": "application/json", > > > > > + "Content-Length", str(len(buf))} > > > > > > There were a few Python syntax errors such as this one. They > > > can be found by running: > > > > > > make -C v2v check TESTS=test-v2v-python-syntax.sh > > > > > > > Cool. Why not include this in "make check"? > > It is! That command is just if you want to run the single test. > Strange, I did run "make check" but it did not fail on checking the rhv plugin. It was failing because of unralted c-api test. Maybe make aborted before running the v2v tests? > > > > Not really. In fact we don't have any unit tests for -o rhv-upload > > > functionality because there's no way to simulate the imageio server. > > > > > > > Actually it is easy to use real imageio server for testing. > > > > 1. install ovirt-imageio-daemon > > Yup, problem is this part. > > However I'll look to see if we can make the tests run optionally _if_ > someone has installed ovirt-imageio-daemon or has a local copy of the > sources, so the rest of the instructions are useful. I think this > method looks most promising, but as you say I'd have to see about > mocking the other engine methods: > There is also: https://github.com/kevin1024/vcrpy I don't like these mocking libraries very much, but this may be useful. After you run the tests once with a real system it can record all the interactions, and the next time you run the tests it will use recorded data. See https://il.pycon.org/2018/schedule/presentation/37/ > > > Another option is to start the server from your tests like this. This > > is how we run our tests. > > > > from ovirt_imageio_daemon import server > > from ovirt_imageio_daemon import config > > > > config.daemon.pki_dir = test/pki > > config.daemon.poll_interval = 0.1 > > config.images.port = 9876 > > config.tickets.socket = "/tmp/ovirt-imageio-daemon.sock" > > > > server.start(config) > > > > # run your test here... > > > > server.stop() > > [...] > > However you can run virt-v2v locally against an oVirt instance without > > > needing VMware. The command is rather lengthy, but here it is: > > > > > > $ virt-builder fedora-27 > > > $ ./run virt-v2v -i disk /var/tmp/fedora-27.img \ > > > -o rhv-upload \ > > > -oc https://ovirt-engine.example.com/ovirt-engine/api \ > > > -os ovirt-data \ > > > -op /tmp/password \ > > > -of raw \ > > > -oo rhv-cafile=/tmp/ca.pem \ > > > -oo rhv-direct > > > > > > /tmp/password should contain the oVirt admin password. > > > /tmp/ca.pem should contain the oVirt CA cert. > > > > > > This will create a guest called ‘fedora-27’ which you'll need to > > > delete (on oVirt) afterwards. You can add ‘-on name’ to name it > > > something else. > > > > > > > Should we document this? > > It's just the normal way to run virt-v2v, eg as documented here: > > http://libguestfs.org/virt-v2v.1.html#convert-from-vmware-to-rhv-ovirt > > ... except that I've changed the input side to use a local disk. > > We did consider having an ‘-i builder’ input method (just for testing). > > Rich. > > -- > Richard Jones, Virtualization Group, Red Hat > http://people.redhat.com/~rjones > Read my programming and virtualization blog: http://rwmj.wordpress.com > virt-builder quickly builds VMs from scratch > http://libguestfs.org/virt-builder.1.html > ___ Libguestfs mailing list Libguestfs@redhat.com https://www.redhat.com/mailman/listinfo/libguestfs
Re: [Libguestfs] [PATCH] v2v: -o rhv-upload: Optimize http request sending
On Mon, Jun 18, 2018 at 08:55:13PM +0300, Nir Soffer wrote: > On Mon, Jun 18, 2018 at 1:37 PM Richard W.M. Jones > wrote: > > > On Thu, Jun 14, 2018 at 09:24:48PM +0300, Nir Soffer wrote: > > > On Thu, Jun 14, 2018 at 9:16 PM Nir Soffer wrote: > > > > +headers = {"Content-Type": "application/json", > > > > + "Content-Length", str(len(buf))} > > > > There were a few Python syntax errors such as this one. They > > can be found by running: > > > > make -C v2v check TESTS=test-v2v-python-syntax.sh > > > > Cool. Why not include this in "make check"? It is! That command is just if you want to run the single test. > > Not really. In fact we don't have any unit tests for -o rhv-upload > > functionality because there's no way to simulate the imageio server. > > > > Actually it is easy to use real imageio server for testing. > > 1. install ovirt-imageio-daemon Yup, problem is this part. However I'll look to see if we can make the tests run optionally _if_ someone has installed ovirt-imageio-daemon or has a local copy of the sources, so the rest of the instructions are useful. I think this method looks most promising, but as you say I'd have to see about mocking the other engine methods: > Another option is to start the server from your tests like this. This > is how we run our tests. > > from ovirt_imageio_daemon import server > from ovirt_imageio_daemon import config > > config.daemon.pki_dir = test/pki > config.daemon.poll_interval = 0.1 > config.images.port = 9876 > config.tickets.socket = "/tmp/ovirt-imageio-daemon.sock" > > server.start(config) > > # run your test here... > > server.stop() [...] > However you can run virt-v2v locally against an oVirt instance without > > needing VMware. The command is rather lengthy, but here it is: > > > > $ virt-builder fedora-27 > > $ ./run virt-v2v -i disk /var/tmp/fedora-27.img \ > > -o rhv-upload \ > > -oc https://ovirt-engine.example.com/ovirt-engine/api \ > > -os ovirt-data \ > > -op /tmp/password \ > > -of raw \ > > -oo rhv-cafile=/tmp/ca.pem \ > > -oo rhv-direct > > > > /tmp/password should contain the oVirt admin password. > > /tmp/ca.pem should contain the oVirt CA cert. > > > > This will create a guest called ‘fedora-27’ which you'll need to > > delete (on oVirt) afterwards. You can add ‘-on name’ to name it > > something else. > > > > Should we document this? It's just the normal way to run virt-v2v, eg as documented here: http://libguestfs.org/virt-v2v.1.html#convert-from-vmware-to-rhv-ovirt ... except that I've changed the input side to use a local disk. We did consider having an ‘-i builder’ input method (just for testing). Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-builder quickly builds VMs from scratch http://libguestfs.org/virt-builder.1.html ___ Libguestfs mailing list Libguestfs@redhat.com https://www.redhat.com/mailman/listinfo/libguestfs
Re: [Libguestfs] [PATCH] v2v: -o rhv-upload: Optimize http request sending
On Mon, Jun 18, 2018 at 1:37 PM Richard W.M. Jones wrote: > On Thu, Jun 14, 2018 at 09:24:48PM +0300, Nir Soffer wrote: > > On Thu, Jun 14, 2018 at 9:16 PM Nir Soffer wrote: > > > +headers = {"Content-Type": "application/json", > > > + "Content-Length", str(len(buf))} > > There were a few Python syntax errors such as this one. They > can be found by running: > > make -C v2v check TESTS=test-v2v-python-syntax.sh > Cool. Why not include this in "make check"? > > However I have now fixed them. > Thanks! > > > Do we have an easy way to test the plugin without running the entire > > virt-v2v pipeline? > > Not really. In fact we don't have any unit tests for -o rhv-upload > functionality because there's no way to simulate the imageio server. > Actually it is easy to use real imageio server for testing. 1. install ovirt-imageio-daemon 2. configure it for testing # /etc/ovirt-imageio-daemon/daemon.conf [daemon] # directory with this structure # certs/ # vdsmcert.pem # keys # vdsmkey.pem pki_dir = test/pki poll_interval = 0.1 [images] port = 9876 [tickets] socket = /tmp/ovirt-imageio-daemon.sock 3. Now you can run it /usr/bin/ovirt-imageio-daemon To upload, without real engine, you can install your own ticket like this: 1. Create a ticket json: $ cat ticket.json { "uuid": "test", "size": 1073741824, "url": "file:///var/tmp/sd-uukd/vol-uuid", "timeout": 3000, "ops": ["read", "write"] } 2. Install the ticket $ curl --unix-socket /tmp/vdsm/ovirt-imageio-daemon.sock \ -X PUT \ --upload-file ticket.json \ http://localhost/tickets/test 3. Create the image: file: touch /var/tmp/sd-uuuid/vol-uuid (note that the file system must support direct I/O) block: lvcreate -n vol-uuid -L 1g sd-uuid At this point you can upload or download using this transfer_url: https://localhost:9876/images/test We can make it even easier by supporting command line options so you don't need to change /etc/ovirt-imageio-daemon, or even install the package. For example: git clone https://github.com/oVirt/ovirt-imageio.git src/ovirt-image/daemon/ovirt-imageio-daemon -f my-test.conf Another option is to start the server from your tests like this. This is how we run our tests. from ovirt_imageio_daemon import server from ovirt_imageio_daemon import config config.daemon.pki_dir = test/pki config.daemon.poll_interval = 0.1 config.images.port = 9876 config.tickets.socket = "/tmp/ovirt-imageio-daemon.sock" server.start(config) # run your test here... server.stop() Note that we did not complete the port to python 3 yest, so upload tests will work only with python 2. The missing part is how to test without real engine. I think the best way would be to monkeypatch the ovirtsdk module so it does not send any requests, and instead return fake responses. This add risk of having incorrect mocked response, or not detecting wrong calls, but will make testing very easy, which make it easy for random contributors. However you can run virt-v2v locally against an oVirt instance without > needing VMware. The command is rather lengthy, but here it is: > > $ virt-builder fedora-27 > $ ./run virt-v2v -i disk /var/tmp/fedora-27.img \ > -o rhv-upload \ > -oc https://ovirt-engine.example.com/ovirt-engine/api \ > -os ovirt-data \ > -op /tmp/password \ > -of raw \ > -oo rhv-cafile=/tmp/ca.pem \ > -oo rhv-direct > > /tmp/password should contain the oVirt admin password. > /tmp/ca.pem should contain the oVirt CA cert. > > This will create a guest called ‘fedora-27’ which you'll need to > delete (on oVirt) afterwards. You can add ‘-on name’ to name it > something else. > Should we document this? > > In any case I have fixed and verified this patch and will push it > soon, thanks. > > Rich. > > -- > Richard Jones, Virtualization Group, Red Hat > http://people.redhat.com/~rjones > Read my programming and virtualization blog: http://rwmj.wordpress.com > virt-builder quickly builds VMs from scratch > http://libguestfs.org/virt-builder.1.html > ___ Libguestfs mailing list Libguestfs@redhat.com https://www.redhat.com/mailman/listinfo/libguestfs
Re: [Libguestfs] [PATCH] v2v: -o rhv-upload: Optimize http request sending
On Thu, Jun 14, 2018 at 09:24:48PM +0300, Nir Soffer wrote: > On Thu, Jun 14, 2018 at 9:16 PM Nir Soffer wrote: > > +headers = {"Content-Type": "application/json", > > + "Content-Length", str(len(buf))} There were a few Python syntax errors such as this one. They can be found by running: make -C v2v check TESTS=test-v2v-python-syntax.sh However I have now fixed them. > Do we have an easy way to test the plugin without running the entire > virt-v2v pipeline? Not really. In fact we don't have any unit tests for -o rhv-upload functionality because there's no way to simulate the imageio server. However you can run virt-v2v locally against an oVirt instance without needing VMware. The command is rather lengthy, but here it is: $ virt-builder fedora-27 $ ./run virt-v2v -i disk /var/tmp/fedora-27.img \ -o rhv-upload \ -oc https://ovirt-engine.example.com/ovirt-engine/api \ -os ovirt-data \ -op /tmp/password \ -of raw \ -oo rhv-cafile=/tmp/ca.pem \ -oo rhv-direct /tmp/password should contain the oVirt admin password. /tmp/ca.pem should contain the oVirt CA cert. This will create a guest called ‘fedora-27’ which you'll need to delete (on oVirt) afterwards. You can add ‘-on name’ to name it something else. In any case I have fixed and verified this patch and will push it soon, thanks. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-builder quickly builds VMs from scratch http://libguestfs.org/virt-builder.1.html ___ Libguestfs mailing list Libguestfs@redhat.com https://www.redhat.com/mailman/listinfo/libguestfs
Re: [Libguestfs] [PATCH] v2v: -o rhv-upload: Optimize http request sending
On Thu, 14 Jun 2018 21:16:01 +0300 Nir Soffer wrote: > When sending request with small or no payload, it is simpler and > possibly more efficient to use the high level HTTPSConnection.request(), > instead of the lower level APIs. > > The only reason to use the lower level APIs is to avoid copying the > payload, or on python 2, to use a bigger buffer size when streaming a > file-like object. > --- > v2v/rhv-upload-plugin.py | 35 --- > 1 file changed, 16 insertions(+), 19 deletions(-) FWIW LGTM ___ Libguestfs mailing list Libguestfs@redhat.com https://www.redhat.com/mailman/listinfo/libguestfs
Re: [Libguestfs] [PATCH] v2v: -o rhv-upload: Optimize http request sending
On Thu, Jun 14, 2018 at 10:19 PM Richard W.M. Jones wrote: > On Thu, Jun 14, 2018 at 09:16:01PM +0300, Nir Soffer wrote: > > When sending request with small or no payload, it is simpler and > > possibly more efficient to use the high level HTTPSConnection.request(), > > instead of the lower level APIs. > > > > The only reason to use the lower level APIs is to avoid copying the > > payload, or on python 2, to use a bigger buffer size when streaming a > > file-like object. > > Change seems quite straightforward. I'll have to test this out on my > own oVirt system first before I can properly verify it. > I tested the same change with imageio example upload script, and it *doubled* the throughput. See https://gerrit.ovirt.org/#/c/92275/ Thanks, Rich. > > > v2v/rhv-upload-plugin.py | 35 --- > > 1 file changed, 16 insertions(+), 19 deletions(-) > > > > diff --git a/v2v/rhv-upload-plugin.py b/v2v/rhv-upload-plugin.py > > index ed99cc7a9..3fad865f6 100644 > > --- a/v2v/rhv-upload-plugin.py > > +++ b/v2v/rhv-upload-plugin.py > > @@ -263,12 +263,12 @@ def pread(h, count, offset): > > transfer = h['transfer'] > > transfer_service = h['transfer_service'] > > > > -http.putrequest("GET", h['path']) > > +headers = {"Range", "bytes=%d-%d" % (offset, offset+count-1)} > > # Authorization is only needed for old imageio. > > if h['needs_auth']: > > -http.putheader("Authorization", transfer.signed_ticket) > > -http.putheader("Range", "bytes=%d-%d" % (offset, offset+count-1)) > > -http.endheaders() > > +headers["Authorization"] = transfer.signed_ticket > > + > > +http.request("GET", h['path'], headers=headers) > > > > r = http.getresponse() > > # 206 = HTTP Partial Content. > > @@ -319,11 +319,10 @@ def zero(h, count, offset, may_trim): > >'size': count, > >'flush': False}).encode() > > > > -http.putrequest("PATCH", h['path']) > > -http.putheader("Content-Type", "application/json") > > -http.putheader("Content-Length", len(buf)) > > -http.endheaders() > > -http.send(buf) > > +headers = {"Content-Type": "application/json", > > + "Content-Length", str(len(buf))} > > + > > +http.request("PATCH", h['path'], body=buf, headers=headers) > > > > r = http.getresponse() > > if r.status != 200: > > @@ -368,11 +367,10 @@ def trim(h, count, offset): > >'size': count, > >'flush': False}).encode() > > > > -http.putrequest("PATCH", h['path']) > > -http.putheader("Content-Type", "application/json") > > -http.putheader("Content-Length", len(buf)) > > -http.endheaders() > > -http.send(buf) > > +headers = {"Content-Type": "application/json", > > + "Content-Length", str(len(buf))} > > + > > +http.request("PATCH", h['path'], body=buf, headers=headers) > > > > r = http.getresponse() > > if r.status != 200: > > @@ -387,11 +385,10 @@ def flush(h): > > # Construct the JSON request for flushing. > > buf = json.dumps({'op': "flush"}).encode() > > > > -http.putrequest("PATCH", h['path']) > > -http.putheader("Content-Type", "application/json") > > -http.putheader("Content-Length", len(buf)) > > -http.endheaders() > > -http.send(buf) > > +headers = {"Content-Type": "application/json", > > + "Content-Length", str(len(buf))} > > + > > +http.request("PATCH", h['path'], body=buf, headers=headers) > > > > r = http.getresponse() > > if r.status != 200: > > -- > > 2.17.1 > > -- > 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 > ___ Libguestfs mailing list Libguestfs@redhat.com https://www.redhat.com/mailman/listinfo/libguestfs
Re: [Libguestfs] [PATCH] v2v: -o rhv-upload: Optimize http request sending
On Thu, Jun 14, 2018 at 9:16 PM Nir Soffer wrote: > When sending request with small or no payload, it is simpler and > possibly more efficient to use the high level HTTPSConnection.request(), > instead of the lower level APIs. > > The only reason to use the lower level APIs is to avoid copying the > payload, or on python 2, to use a bigger buffer size when streaming a > file-like object. > --- > v2v/rhv-upload-plugin.py | 35 --- > 1 file changed, 16 insertions(+), 19 deletions(-) > > diff --git a/v2v/rhv-upload-plugin.py b/v2v/rhv-upload-plugin.py > index ed99cc7a9..3fad865f6 100644 > --- a/v2v/rhv-upload-plugin.py > +++ b/v2v/rhv-upload-plugin.py > @@ -263,12 +263,12 @@ def pread(h, count, offset): > transfer = h['transfer'] > transfer_service = h['transfer_service'] > > -http.putrequest("GET", h['path']) > +headers = {"Range", "bytes=%d-%d" % (offset, offset+count-1)} > # Authorization is only needed for old imageio. > if h['needs_auth']: > -http.putheader("Authorization", transfer.signed_ticket) > -http.putheader("Range", "bytes=%d-%d" % (offset, offset+count-1)) > -http.endheaders() > +headers["Authorization"] = transfer.signed_ticket > + > +http.request("GET", h['path'], headers=headers) > > r = http.getresponse() > # 206 = HTTP Partial Content. > @@ -319,11 +319,10 @@ def zero(h, count, offset, may_trim): >'size': count, >'flush': False}).encode() > > -http.putrequest("PATCH", h['path']) > -http.putheader("Content-Type", "application/json") > -http.putheader("Content-Length", len(buf)) > -http.endheaders() > -http.send(buf) > +headers = {"Content-Type": "application/json", > + "Content-Length", str(len(buf))} > + > +http.request("PATCH", h['path'], body=buf, headers=headers) > > r = http.getresponse() > if r.status != 200: > @@ -368,11 +367,10 @@ def trim(h, count, offset): >'size': count, >'flush': False}).encode() > > -http.putrequest("PATCH", h['path']) > -http.putheader("Content-Type", "application/json") > -http.putheader("Content-Length", len(buf)) > -http.endheaders() > -http.send(buf) > +headers = {"Content-Type": "application/json", > + "Content-Length", str(len(buf))} > + > +http.request("PATCH", h['path'], body=buf, headers=headers) > > r = http.getresponse() > if r.status != 200: > @@ -387,11 +385,10 @@ def flush(h): > # Construct the JSON request for flushing. > buf = json.dumps({'op': "flush"}).encode() > > -http.putrequest("PATCH", h['path']) > -http.putheader("Content-Type", "application/json") > -http.putheader("Content-Length", len(buf)) > -http.endheaders() > -http.send(buf) > +headers = {"Content-Type": "application/json", > + "Content-Length", str(len(buf))} > + > +http.request("PATCH", h['path'], body=buf, headers=headers) > > r = http.getresponse() > if r.status != 200: > -- > 2.17.1 > WARNING: this is not tested, but I tested similar code here: https://github.com/oVirt/ovirt-imageio/blob/master/examples/upload (which need the same change). Do we have an easy way to test the plugin without running the entire virt-v2v pipeline? Ideally, a way to run nbdkit with the plugin against an existing ovirt system, and then use qemu-img to convert a file to the nbdkit nbd socket. Nir ___ Libguestfs mailing list Libguestfs@redhat.com https://www.redhat.com/mailman/listinfo/libguestfs
Re: [Libguestfs] [PATCH] v2v: -o rhv-upload: Optimize http request sending
On Thu, Jun 14, 2018 at 09:16:01PM +0300, Nir Soffer wrote: > When sending request with small or no payload, it is simpler and > possibly more efficient to use the high level HTTPSConnection.request(), > instead of the lower level APIs. > > The only reason to use the lower level APIs is to avoid copying the > payload, or on python 2, to use a bigger buffer size when streaming a > file-like object. Change seems quite straightforward. I'll have to test this out on my own oVirt system first before I can properly verify it. Thanks, Rich. > v2v/rhv-upload-plugin.py | 35 --- > 1 file changed, 16 insertions(+), 19 deletions(-) > > diff --git a/v2v/rhv-upload-plugin.py b/v2v/rhv-upload-plugin.py > index ed99cc7a9..3fad865f6 100644 > --- a/v2v/rhv-upload-plugin.py > +++ b/v2v/rhv-upload-plugin.py > @@ -263,12 +263,12 @@ def pread(h, count, offset): > transfer = h['transfer'] > transfer_service = h['transfer_service'] > > -http.putrequest("GET", h['path']) > +headers = {"Range", "bytes=%d-%d" % (offset, offset+count-1)} > # Authorization is only needed for old imageio. > if h['needs_auth']: > -http.putheader("Authorization", transfer.signed_ticket) > -http.putheader("Range", "bytes=%d-%d" % (offset, offset+count-1)) > -http.endheaders() > +headers["Authorization"] = transfer.signed_ticket > + > +http.request("GET", h['path'], headers=headers) > > r = http.getresponse() > # 206 = HTTP Partial Content. > @@ -319,11 +319,10 @@ def zero(h, count, offset, may_trim): >'size': count, >'flush': False}).encode() > > -http.putrequest("PATCH", h['path']) > -http.putheader("Content-Type", "application/json") > -http.putheader("Content-Length", len(buf)) > -http.endheaders() > -http.send(buf) > +headers = {"Content-Type": "application/json", > + "Content-Length", str(len(buf))} > + > +http.request("PATCH", h['path'], body=buf, headers=headers) > > r = http.getresponse() > if r.status != 200: > @@ -368,11 +367,10 @@ def trim(h, count, offset): >'size': count, >'flush': False}).encode() > > -http.putrequest("PATCH", h['path']) > -http.putheader("Content-Type", "application/json") > -http.putheader("Content-Length", len(buf)) > -http.endheaders() > -http.send(buf) > +headers = {"Content-Type": "application/json", > + "Content-Length", str(len(buf))} > + > +http.request("PATCH", h['path'], body=buf, headers=headers) > > r = http.getresponse() > if r.status != 200: > @@ -387,11 +385,10 @@ def flush(h): > # Construct the JSON request for flushing. > buf = json.dumps({'op': "flush"}).encode() > > -http.putrequest("PATCH", h['path']) > -http.putheader("Content-Type", "application/json") > -http.putheader("Content-Length", len(buf)) > -http.endheaders() > -http.send(buf) > +headers = {"Content-Type": "application/json", > + "Content-Length", str(len(buf))} > + > +http.request("PATCH", h['path'], body=buf, headers=headers) > > r = http.getresponse() > if r.status != 200: > -- > 2.17.1 -- 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 ___ Libguestfs mailing list Libguestfs@redhat.com https://www.redhat.com/mailman/listinfo/libguestfs