Signed-off-by: Chris Lalancette <clalance(a)redhat.com>
---
imgfac/builders/VMWare.py | 22 +++++++++++++---------
1 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/imgfac/builders/VMWare.py b/imgfac/builders/VMWare.py
index 319c96f..e950c5f 100644
--- a/imgfac/builders/VMWare.py
+++ b/imgfac/builders/VMWare.py
@@ -47,14 +47,6 @@ class VMImport:
self.vim = Vim(url)
self.vim.login(username, password)
- def curl_progress(self, download_t, download_d, upload_t, upload_d):
- curtime=time()
- # TODO: Make poke frequency variable
- # 5 seconds isn't too much and it makes the status bar in the vSphere GUI
look nice :-)
- if (curtime - self.time_at_last_poke) >= 5:
- self.vim.invoke('HttpNfcLeaseProgress', _this=self.lease_mo_ref,
percent = int(upload_d*100/upload_t))
- self.time_at_last_poke = time()
-
def import_vm(self, datastore, network_name, name, disksize_kb,
memory, num_cpus, guest_id, host=None, imagefilename=None):
@@ -157,6 +149,16 @@ class VMImport:
self.lease_timeout = lease.info.leaseTimeout
self.time_at_last_poke = time()
+ def curl_progress(download_t, download_d, upload_t, upload_d):
+ curtime = time()
+ # TODO: Make poke frequency variable
+ # 5 seconds isn't too much and it makes the status bar in the
+ # vSphere GUI look nice :-)
+ if (curtime - self.time_at_last_poke) >= 5:
+ self.vim.invoke('HttpNfcLeaseProgress',
+ _this = self.lease_mo_ref,
+ percent = int(upload_d * 100 / upload_t))
+ self.time_at_last_poke = time()
image_file = open(imagefilename)
@@ -168,7 +170,9 @@ class VMImport:
curl.setopt(pycurl.POST, 1)
curl.setopt(pycurl.POSTFIELDSIZE, image_size)
curl.setopt(pycurl.READFUNCTION, image_file.read)
- curl.setopt(pycurl.HTTPHEADER, ["User-Agent: Load Tool (PyCURL Load
Tool)", "Content-Type: application/octet-stream"])
+ curl.setopt(pycurl.HTTPHEADER,
+ ["User-Agent: Load Tool (PyCURL Load Tool)",
+ "Content-Type: application/octet-stream"])
curl.setopt(pycurl.NOPROGRESS, 0)
curl.setopt(pycurl.PROGRESSFUNCTION, self.curl_progress)
curl.perform()
--
1.7.4.4