CLOUDSTACK-5449: fix the log creation failure case and added an option

for user to provide --log-folder-path=

Signed-off-by: SrikanteswaraRao Talluri <talluri@apache.org>
This commit is contained in:
SrikanteswaraRao Talluri 2013-12-11 01:52:34 +05:30
parent 3144e01c13
commit a9d96aff06
2 changed files with 20 additions and 8 deletions

View File

@ -39,14 +39,16 @@ import sys
import time
import os
import logging
import string
import random
class MarvinInit:
def __init__(self, config_file, load_flag):
def __init__(self, config_file, load_flag, log_folder_path=None):
self.__configFile = config_file
self.__loadFlag = load_flag
self.__parsedConfig = None
self.__logFolderPath = None
self.__logFolderPath = log_folder_path
self.__tcRunLogger = None
self.__testClient = None
self.__tcRunDebugFile = None
@ -111,15 +113,21 @@ class MarvinInit:
for a given test run are available under a given
timestamped folder
'''
log_config = self.__parsedConfig.logger
temp_path = "".join(str(time.time()).split("."))
if log_config is not None:
if log_config.LogFolderPath is not None:
self.logFolderPath = log_config.LogFolderPath + temp_path
if self.__logFolderPath is None:
log_config = self.__parsedConfig.logger
if log_config is not None:
if log_config.LogFolderPath is not None:
self.logFolderPath = log_config.LogFolderPath + '/' + temp_path
else:
self.logFolderPath = temp_path
else:
self.logFolderPath = temp_path
else:
self.logFolderPath = temp_path
self.logFolderPath = self.__logFolderPath + '/' + temp_path
if os.path.exists(self.logFolderPath):
self.logFolderPath = self.logFolderPath \
+ ''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(3))
os.makedirs(self.logFolderPath)
'''
Log File Paths

View File

@ -68,6 +68,7 @@ class MarvinPlugin(Plugin):
self.enabled = True
self.configFile = options.config_file
self.loadFlag = options.load
self.logFolderPath = options.log_folder_path
self.conf = conf
'''
Initializes the marvin with required settings
@ -87,6 +88,9 @@ class MarvinPlugin(Plugin):
parser.add_option("--load", action="store_true", default=False,
dest="load",
help="Only load the deployment configuration given")
parser.add_option("--log-folder-path", action="store", default=None,
dest="log_folder_path",
help="Path to the folder where log files will be stored")
Plugin.options(self, parser, env)
def wantClass(self, cls):
@ -165,7 +169,7 @@ class MarvinPlugin(Plugin):
Creates a debugstream for tc debug log
'''
try:
obj_marvininit = MarvinInit(self.configFile, self.loadFlag)
obj_marvininit = MarvinInit(self.configFile, self.loadFlag, self.logFolderPath)
if obj_marvininit.init() == SUCCESS:
self.testClient = obj_marvininit.getTestClient()
self.tcRunLogger = obj_marvininit.getLogger()