parent
f88c9d1d06
commit
3a6b93c85d
@ -18,10 +18,17 @@
|
||||
#
|
||||
# -----------------------------------------------------------------------
|
||||
from __future__ import with_statement
|
||||
import logging
|
||||
import re
|
||||
import os
|
||||
import datetime
|
||||
from common import *
|
||||
import XenAPI
|
||||
import time
|
||||
import logging
|
||||
import re
|
||||
import os.path
|
||||
import os
|
||||
import datetime
|
||||
import select
|
||||
import urllib
|
||||
import socket
|
||||
import tarfile
|
||||
@ -29,9 +36,6 @@ import hashlib
|
||||
from stat import *
|
||||
import ssl
|
||||
|
||||
from common import *
|
||||
import XenAPI
|
||||
|
||||
if hasattr(ssl, '_create_unverified_context'):
|
||||
ssl._create_default_https_context = ssl._create_unverified_context
|
||||
|
||||
@ -50,13 +54,13 @@ class backup_xva(backup_generic):
|
||||
ignore_proxies = "yes"
|
||||
use_compression = "true"
|
||||
|
||||
if str2bool(ignore_proxies):
|
||||
if str2bool(ignore_proxies) == True:
|
||||
os.environ['http_proxy']=""
|
||||
os.environ['https_proxy']=""
|
||||
|
||||
def verify_export_xva(self,filename):
|
||||
self.logger.debug("[%s] Verify xva export integrity",self.server_name)
|
||||
tar = tarfile.open(filename)
|
||||
tar = tarfile.open(filename)
|
||||
members = tar.getmembers()
|
||||
for tarinfo in members:
|
||||
if re.search('^[0-9]*$',os.path.basename(tarinfo.name)):
|
||||
@ -95,7 +99,7 @@ class backup_xva(backup_generic):
|
||||
|
||||
|
||||
#add snapshot option
|
||||
if not str2bool(halt_vm):
|
||||
if str2bool(halt_vm) == False:
|
||||
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))
|
||||
self.logger.debug("[%s] Old snaps count %s", vdi_name, len(old_snapshots))
|
||||
@ -142,11 +146,11 @@ class backup_xva(backup_generic):
|
||||
try:
|
||||
filename_temp = filename+".tmp"
|
||||
self.logger.debug("[%s] Copy in progress",self.backup_name)
|
||||
if not str2bool(self.use_compression):
|
||||
if not str2bool(use_compression):
|
||||
socket.setdefaulttimeout(120)
|
||||
|
||||
scheme = "http://"
|
||||
if str2bool(enable_https):
|
||||
if str2bool(enable_https) == True:
|
||||
scheme = "https://"
|
||||
url = scheme+user_xen+":"+password_xen+"@"+self.xcphost+"/export?use_compression="+self.use_compression+"&uuid="+session.xenapi.VM.get_uuid(vm)
|
||||
|
||||
@ -160,7 +164,7 @@ class backup_xva(backup_generic):
|
||||
raise
|
||||
|
||||
finally:
|
||||
if not str2bool(halt_vm):
|
||||
if str2bool(halt_vm) == False:
|
||||
self.logger.debug("[%s] Destroy snapshot",'tisbackup-%s'%(vdi_name))
|
||||
try:
|
||||
for vbd in session.xenapi.VM.get_VBDs(snapshot):
|
||||
@ -186,7 +190,7 @@ class backup_xva(backup_generic):
|
||||
if os.path.exists(filename_temp):
|
||||
tar = tarfile.open(filename_temp)
|
||||
if not tar.getnames():
|
||||
os.unlink(filename_temp)
|
||||
unlink(filename_temp)
|
||||
return("Tar error")
|
||||
tar.close()
|
||||
if str2bool(self.verify_export):
|
||||
|
Loading…
Reference in New Issue
Block a user