- fix use_compression

This commit is contained in:
ssamson-tis 2015-10-30 15:19:47 +01:00
parent dc53354ea2
commit f88c9d1d06

View File

@ -18,17 +18,10 @@
# #
# ----------------------------------------------------------------------- # -----------------------------------------------------------------------
from __future__ import with_statement from __future__ import with_statement
import os
import datetime
from common import *
import XenAPI
import time
import logging import logging
import re import re
import os.path
import os import os
import datetime import datetime
import select
import urllib import urllib
import socket import socket
import tarfile import tarfile
@ -36,6 +29,9 @@ import hashlib
from stat import * from stat import *
import ssl import ssl
from common import *
import XenAPI
if hasattr(ssl, '_create_unverified_context'): if hasattr(ssl, '_create_unverified_context'):
ssl._create_default_https_context = ssl._create_unverified_context ssl._create_default_https_context = ssl._create_unverified_context
@ -54,7 +50,7 @@ class backup_xva(backup_generic):
ignore_proxies = "yes" ignore_proxies = "yes"
use_compression = "true" use_compression = "true"
if str2bool(ignore_proxies) == True: if str2bool(ignore_proxies):
os.environ['http_proxy']="" os.environ['http_proxy']=""
os.environ['https_proxy']="" os.environ['https_proxy']=""
@ -99,7 +95,7 @@ class backup_xva(backup_generic):
#add snapshot option #add snapshot option
if str2bool(halt_vm) == False: if not str2bool(halt_vm):
self.logger.debug("[%s] Check if previous tisbackups snapshots exist",vdi_name) self.logger.debug("[%s] Check if previous tisbackups snapshots exist",vdi_name)
old_snapshots = session.xenapi.VM.get_by_name_label("tisbackup-%s"%(vdi_name)) old_snapshots = session.xenapi.VM.get_by_name_label("tisbackup-%s"%(vdi_name))
self.logger.debug("[%s] Old snaps count %s", vdi_name, len(old_snapshots)) self.logger.debug("[%s] Old snaps count %s", vdi_name, len(old_snapshots))
@ -146,11 +142,11 @@ class backup_xva(backup_generic):
try: try:
filename_temp = filename+".tmp" filename_temp = filename+".tmp"
self.logger.debug("[%s] Copy in progress",self.backup_name) self.logger.debug("[%s] Copy in progress",self.backup_name)
if not str2bool(use_compression): if not str2bool(self.use_compression):
socket.setdefaulttimeout(120) socket.setdefaulttimeout(120)
scheme = "http://" scheme = "http://"
if str2bool(enable_https) == True: if str2bool(enable_https):
scheme = "https://" scheme = "https://"
url = scheme+user_xen+":"+password_xen+"@"+self.xcphost+"/export?use_compression="+self.use_compression+"&uuid="+session.xenapi.VM.get_uuid(vm) url = scheme+user_xen+":"+password_xen+"@"+self.xcphost+"/export?use_compression="+self.use_compression+"&uuid="+session.xenapi.VM.get_uuid(vm)
@ -164,7 +160,7 @@ class backup_xva(backup_generic):
raise raise
finally: finally:
if str2bool(halt_vm) == False: if not str2bool(halt_vm):
self.logger.debug("[%s] Destroy snapshot",'tisbackup-%s'%(vdi_name)) self.logger.debug("[%s] Destroy snapshot",'tisbackup-%s'%(vdi_name))
try: try:
for vbd in session.xenapi.VM.get_VBDs(snapshot): for vbd in session.xenapi.VM.get_VBDs(snapshot):
@ -190,7 +186,7 @@ class backup_xva(backup_generic):
if os.path.exists(filename_temp): if os.path.exists(filename_temp):
tar = tarfile.open(filename_temp) tar = tarfile.open(filename_temp)
if not tar.getnames(): if not tar.getnames():
unlink(filename_temp) os.unlink(filename_temp)
return("Tar error") return("Tar error")
tar.close() tar.close()
if str2bool(self.verify_export): if str2bool(self.verify_export):