mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CLOUDSTACK-5764: Some fixes to marvin
This commit is contained in:
parent
6a2cc9fbd0
commit
edfd2b6799
@ -17,7 +17,7 @@
|
||||
{
|
||||
"zones": [
|
||||
{
|
||||
"name": "Sandbox-simulator-new",
|
||||
"name": "Sandbox-simulator",
|
||||
"guestcidraddress": "10.1.1.0/24",
|
||||
"dns1": "10.147.28.6",
|
||||
"physical_networks": [
|
||||
|
||||
@ -659,6 +659,11 @@ class DeployDataCenters(object):
|
||||
return FAILED
|
||||
|
||||
if __name__ == "__main__":
|
||||
'''
|
||||
@Desc : This facility is mainly to deploy
|
||||
DataCenter by using this module as script
|
||||
by using the input provided configuration.
|
||||
'''
|
||||
parser = OptionParser()
|
||||
parser.add_option("-i", "--input", action="store",
|
||||
default="./datacenterCfg", dest="input",
|
||||
@ -673,22 +678,32 @@ if __name__ == "__main__":
|
||||
'''
|
||||
from marvin.marvinLog import MarvinLog
|
||||
from marvin.cloudstackTestClient import CSTestClient
|
||||
|
||||
'''
|
||||
Step1 : Parse and Create the config from input config provided
|
||||
'''
|
||||
cfg = configGenerator.getSetupConfig(options.input)
|
||||
log_obj = MarvinLog("CSLog")
|
||||
tcRunLogger = log_obj.setLogHandler("/tmp/debug.log")
|
||||
if tcRunLogger is None:
|
||||
print "\nLogger Creation Failed. " \
|
||||
"Please Check"
|
||||
exit(1)
|
||||
log_check = False
|
||||
if log_obj is not None:
|
||||
log_check = True
|
||||
ret = log_obj.createLogs("DataCenter",
|
||||
cfg.logger)
|
||||
if ret != FAILED:
|
||||
log_folder_path = log_obj.getLogFolderPath()
|
||||
tc_run_logger = log_obj.getLogger()
|
||||
if log_check is False:
|
||||
print "\nLog Creation Failed. Please Check"
|
||||
else:
|
||||
print "\nAll Logs Are Available " \
|
||||
"Under /tmp/debug.log File"
|
||||
print "\nAll Logs will be available under %s" % \
|
||||
str(log_folder_path)
|
||||
'''
|
||||
Step2: Create the Test Client
|
||||
'''
|
||||
obj_tc_client = CSTestClient(cfg.mgtSvr[0], cfg.dbSvr,
|
||||
logger=tcRunLogger)
|
||||
if obj_tc_client is not None and obj_tc_client.CreateTestClient() \
|
||||
logger=tc_run_logger)
|
||||
if obj_tc_client is not None and obj_tc_client.createTestClient() \
|
||||
!= FAILED:
|
||||
deploy = DeployDataCenters(obj_tc_client, cfg, tcRunLogger)
|
||||
deploy = DeployDataCenters(obj_tc_client, cfg, tc_run_logger)
|
||||
if deploy.deploy() == FAILED:
|
||||
print "\nDeploy DC Failed"
|
||||
exit(1)
|
||||
@ -696,7 +711,7 @@ if __name__ == "__main__":
|
||||
print "\nTestClient Creation Failed. Please Check"
|
||||
exit(1)
|
||||
else:
|
||||
print "\n Please Specify a Valid Configuration File"
|
||||
print "\n Please Specify a Valid Input Configuration File"
|
||||
|
||||
"""
|
||||
create = createStoragePool.createStoragePoolCmd()
|
||||
|
||||
@ -65,7 +65,7 @@ class MarvinLog:
|
||||
self.__logger = logging.getLogger(self.__loggerName)
|
||||
self.__logger.setLevel(logging.DEBUG)
|
||||
|
||||
def setLogHandler(self, log_file_path, log_format=None,
|
||||
def __setLogHandler(self, log_file_path, log_format=None,
|
||||
log_level=logging.DEBUG):
|
||||
'''
|
||||
@Desc: Adds the given Log handler to the current logger
|
||||
@ -89,7 +89,7 @@ class MarvinLog:
|
||||
return SUCCESS
|
||||
except Exception, e:
|
||||
print "\nException Occurred Under " \
|
||||
"setLogHandler %s" % GetDetailExceptionInfo(e)
|
||||
"__setLogHandler %s" % GetDetailExceptionInfo(e)
|
||||
return FAILED
|
||||
|
||||
def __cleanPreviousLogs(self, logfolder_to_remove):
|
||||
@ -99,7 +99,12 @@ class MarvinLog:
|
||||
@Return: N\A
|
||||
@Input: logfolder_to_remove: Path of Log to remove
|
||||
'''
|
||||
try:
|
||||
os.rmdir(logfolder_to_remove)
|
||||
except Exception, e:
|
||||
print "\n Exception Occurred Under __cleanPreviousLogs :%s" % \
|
||||
GetDetailExceptionInfo(e)
|
||||
return FAILED
|
||||
|
||||
def getLogger(self):
|
||||
'''
|
||||
@ -134,18 +139,19 @@ class MarvinLog:
|
||||
temp_path = time.strftime("%b_%d_%Y_%H_%M_%S",
|
||||
time.localtime())
|
||||
else:
|
||||
temp_path = test_module_name
|
||||
temp_path = str(test_module_name.split(".py")[0])
|
||||
|
||||
if (('LogFolderPath' in log_cfg.__dict__.keys()) and
|
||||
(log_cfg.__dict__.get('LogFolderPath') is not None)):
|
||||
self.__cleanPreviousLogs(log_cfg.
|
||||
__dict__.
|
||||
get('LogFolderPath') + "MarvinLogs/")
|
||||
temp_dir = log_cfg.__dict__.get('LogFolderPath') + "MarvinLogs"
|
||||
get('LogFolderPath') + "/MarvinLogs")
|
||||
temp_dir = \
|
||||
log_cfg.__dict__.get('LogFolderPath') + "/MarvinLogs"
|
||||
else:
|
||||
temp_dir = "MarvinLogs"
|
||||
|
||||
self.__logFolderDir = temp_dir + temp_path
|
||||
self.__logFolderDir = temp_dir + "//" + temp_path
|
||||
print "\n*********Log Folder Path: %s. " \
|
||||
"All logs will be available here **************" \
|
||||
% str(self.__logFolderDir)
|
||||
@ -161,9 +167,9 @@ class MarvinLog:
|
||||
tc_failed_exception_log = \
|
||||
self.__logFolderDir + "/failed_plus_exceptions.txt"
|
||||
tc_run_log = self.__logFolderDir + "/runinfo.txt"
|
||||
if self.setLogHandler(tc_run_log,
|
||||
if self.__setLogHandler(tc_run_log,
|
||||
log_level=logging.DEBUG) != FAILED:
|
||||
self.setLogHandler(tc_failed_exception_log,
|
||||
self.__setLogHandler(tc_failed_exception_log,
|
||||
log_level=logging.FATAL)
|
||||
return SUCCESS
|
||||
return FAILED
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user