parent
							
								
									f88c9d1d06
								
							
						
					
					
						commit
						3a6b93c85d
					
				@ -18,10 +18,17 @@
 | 
				
			|||||||
#
 | 
					#
 | 
				
			||||||
# -----------------------------------------------------------------------
 | 
					# -----------------------------------------------------------------------
 | 
				
			||||||
from __future__ import with_statement
 | 
					from __future__ import with_statement
 | 
				
			||||||
import logging
 | 
					 | 
				
			||||||
import re
 | 
					 | 
				
			||||||
import os
 | 
					import os
 | 
				
			||||||
import datetime
 | 
					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 urllib
 | 
				
			||||||
import socket
 | 
					import socket
 | 
				
			||||||
import tarfile
 | 
					import tarfile
 | 
				
			||||||
@ -29,9 +36,6 @@ 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
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -50,7 +54,7 @@ class backup_xva(backup_generic):
 | 
				
			|||||||
    ignore_proxies = "yes"
 | 
					    ignore_proxies = "yes"
 | 
				
			||||||
    use_compression = "true"
 | 
					    use_compression = "true"
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    if str2bool(ignore_proxies):
 | 
					    if  str2bool(ignore_proxies) == True:
 | 
				
			||||||
        os.environ['http_proxy']=""
 | 
					        os.environ['http_proxy']=""
 | 
				
			||||||
        os.environ['https_proxy']=""
 | 
					        os.environ['https_proxy']=""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -95,7 +99,7 @@ class backup_xva(backup_generic):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        #add snapshot option
 | 
					        #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)
 | 
					            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))
 | 
				
			||||||
@ -142,11 +146,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(self.use_compression):
 | 
					                if not str2bool(use_compression):
 | 
				
			||||||
                    socket.setdefaulttimeout(120)
 | 
					                    socket.setdefaulttimeout(120)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                scheme = "http://"
 | 
					                scheme = "http://"
 | 
				
			||||||
                if str2bool(enable_https):
 | 
					                if str2bool(enable_https) == True:
 | 
				
			||||||
                    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)
 | 
				
			||||||
               
 | 
					               
 | 
				
			||||||
@ -160,7 +164,7 @@ class backup_xva(backup_generic):
 | 
				
			|||||||
                raise
 | 
					                raise
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        finally:
 | 
					        finally:
 | 
				
			||||||
            if not str2bool(halt_vm):
 | 
					            if str2bool(halt_vm) == False:
 | 
				
			||||||
                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):
 | 
				
			||||||
@ -186,7 +190,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():
 | 
				
			||||||
                os.unlink(filename_temp)
 | 
					                unlink(filename_temp)
 | 
				
			||||||
                return("Tar error")
 | 
					                return("Tar error")
 | 
				
			||||||
            tar.close()
 | 
					            tar.close()
 | 
				
			||||||
            if str2bool(self.verify_export):
 | 
					            if str2bool(self.verify_export):
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user