예제 #1
0
	def __init__(self,File):
		import datetime
		import configobj
		from CCSUtils import SimpleLogger
		from CCSUtils import send_mail
		from sys import path 
		from sys import exit
		import imp

		self.__email_subject = ""
		self.__email_body = ""
		self.StartTime = datetime.datetime.now()
		self.EndTimie = datetime.datetime.now()
		# Load application main config file
		appConfig = configobj.ConfigObj("/etc/CCSBackupEngine/app.conf")['main']
		# Install application Logger
		appLogger = SimpleLogger()
		self.L =appLogger.append
		self.D = appLogger.DEBUG
		try : 
			if len(appConfig['LogLevel']) > 1 and len(appConfig['LogFile']) > 1 :
				appLogger.setup(appConfig('LogLevel'),appConfig('LogFile'))
			elif len(appConfig.get('LogFile')) > 1 :
				appLogger.setup(appLogger.WARNING, appConfig('LogFile'))
			else :
				appLogger.setup()
		except :
			print "Could n`t parse app.conf LogLevel or LogFile values\n"
			exit(-1)
		self.L("Loading instance configuration file {0} : ".format(File), self.D)
		Iconf = configobj.ConfigObj(File)
		# Get backup type
		self.L("Checking backup type driver.\n", self.D)
		if Iconf['type'] not in appConfig['AllowedBackupTypes'] : 
			self.L("Unkown backup type : {0} ,\n Supported backup types are {1}\n Exit..\n".format(Iconf['type'], appConfig['AllowedBackupTypes']), appLogger.ERROR)
			exit(-1)
		L("Load Driver of this module if exist") 
		try :
				path.insert(0,"/etc/CCSBackupEngine/Drivers/")
		except :
				self.L("Could not insert driver path /etc/CCSBackupEngine/Drivers", appLogger.ERROR)
				exit(-2)
		L("Loading driver file TD(Sub)")
		Backup = __import__(Iconf['type'])  #T.D Add Sanity check for the imported module.
		modConfig = configobj.ConfigObj("/etc/CCSBackupEngine/app.conf")[Iconf['type']]
		self._backupAgent =  Backup.Backup(modConfig)
		if not self._checkConfig(Iconf) :
			self.L("Failed while executing driver checkConfig()") ; #exit(-3)
예제 #2
0
from CCSUtils import SimpleLogger
#import CCSUtils
from CCSUtils import send_mail as sm

if __name__ == "__main__" :
        logger = SimpleLogger()
        logger.setup(logger.DEBUG)
        L = logger.append
        L("Hi man", logger.DEBUG)
        L("Bye. BYe Debug")
        logger.setup(logger.ERROR)
	L("Starting Send Email")
	#sm = send_mail
예제 #3
0
		self._backupAgent._checkConfig(Iconf) #T.D this should call with module config instead of conf file 

	def Exec(self):
		self.L("Calling Backup job driver", self.D)
		if not self._backupAgent.Exec() :
			self.L("Failed while Executing driver Exec()") ;  #T.D Review log severity level and add your Email subject and text

	def sendEmail(self): #T.D convert this to a public class .
		self.L("Sending Email", self.D)

def print_usage():
	print "Usage: argv[0] /full/path/to/conf/file \n"
	print "check manual pages. "
	exit(1)

if __name__ == "__main__" :
	from sys import argv,exit
	from CCSUtils import SimpleLogger

	logger = SimpleLogger()
	logger.setup(logger.DEBUG)
	L =logger.append
	D = logger.DEBUG
	L("Starting CCS Backup Service .", D)
	if (len(argv)) != 2 :
		print_usage()
	L("Loading config file "+argv[1],D) 
	bAgent = BackupProxy(argv[1])
	bAgent.Exec()
	bAgent.sendEmail()