Skip to content

Commit 1605e55

Browse files
author
SrikanteswaraRao Talluri
committed
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>
1 parent 4ee3fdb commit 1605e55

2 files changed

Lines changed: 20 additions & 8 deletions

File tree

‎tools/marvin/marvin/marvinInit.py‎

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,16 @@
3939
import time
4040
import os
4141
import logging
42+
import string
43+
import random
4244

4345

4446
class MarvinInit:
45-
def __init__(self, config_file, load_flag):
47+
def __init__(self, config_file, load_flag, log_folder_path=None):
4648
self.__configFile = config_file
4749
self.__loadFlag = load_flag
4850
self.__parsedConfig = None
49-
self.__logFolderPath = None
51+
self.__logFolderPath = log_folder_path
5052
self.__tcRunLogger = None
5153
self.__testClient = None
5254
self.__tcRunDebugFile = None
@@ -111,15 +113,21 @@ def __initLogging(self):
111113
for a given test run are available under a given
112114
timestamped folder
113115
'''
114-
log_config = self.__parsedConfig.logger
115116
temp_path = "".join(str(time.time()).split("."))
116-
if log_config is not None:
117-
if log_config.LogFolderPath is not None:
118-
self.logFolderPath = log_config.LogFolderPath + temp_path
117+
if self.__logFolderPath is None:
118+
log_config = self.__parsedConfig.logger
119+
if log_config is not None:
120+
if log_config.LogFolderPath is not None:
121+
self.logFolderPath = log_config.LogFolderPath + '/' + temp_path
122+
else:
123+
self.logFolderPath = temp_path
119124
else:
120125
self.logFolderPath = temp_path
121126
else:
122-
self.logFolderPath = temp_path
127+
self.logFolderPath = self.__logFolderPath + '/' + temp_path
128+
if os.path.exists(self.logFolderPath):
129+
self.logFolderPath = self.logFolderPath \
130+
+ ''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(3))
123131
os.makedirs(self.logFolderPath)
124132
'''
125133
Log File Paths

‎tools/marvin/marvin/marvinPlugin.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ def configure(self, options, conf):
6868
self.enabled = True
6969
self.configFile = options.config_file
7070
self.loadFlag = options.load
71+
self.logFolderPath = options.log_folder_path
7172
self.conf = conf
7273
'''
7374
Initializes the marvin with required settings
@@ -87,6 +88,9 @@ def options(self, parser, env):
8788
parser.add_option("--load", action="store_true", default=False,
8889
dest="load",
8990
help="Only load the deployment configuration given")
91+
parser.add_option("--log-folder-path", action="store", default=None,
92+
dest="log_folder_path",
93+
help="Path to the folder where log files will be stored")
9094
Plugin.options(self, parser, env)
9195

9296
def wantClass(self, cls):
@@ -165,7 +169,7 @@ def startMarvin(self):
165169
Creates a debugstream for tc debug log
166170
'''
167171
try:
168-
obj_marvininit = MarvinInit(self.configFile, self.loadFlag)
172+
obj_marvininit = MarvinInit(self.configFile, self.loadFlag, self.logFolderPath)
169173
if obj_marvininit.init() == SUCCESS:
170174
self.testClient = obj_marvininit.getTestClient()
171175
self.tcRunLogger = obj_marvininit.getLogger()

0 commit comments

Comments
 (0)