1515# specific language governing permissions and limitations
1616# under the License.
1717'''
18- @Desc: Initializes the marvin and does required prerequisites
18+ Initializes the marvin and does required prerequisites
1919for starting it.
2020 1. Parses the configuration file passed to marvin and creates a
2121 parsed config
2525
2626'''
2727
28- from marvin import configGenerator
29- from marvin import cloudstackException
28+ from marvin .configGenerator import getSetupConfig
3029from marvin .marvinLog import MarvinLog
3130from marvin .deployDataCenter import DeployDataCenters
3231from marvin .cloudstackTestClient import CSTestClient
4948
5049
5150class MarvinInit :
52- def __init__ (self , config_file , load_api_flag = None ,
51+ def __init__ (self , config_file ,
52+ load_api_flag = None ,
5353 deploy_dc_flag = None ,
5454 test_module_name = None ,
5555 zone = None ):
@@ -67,14 +67,14 @@ def __init__(self, config_file, load_api_flag=None,
6767
6868 def __parseConfig (self ):
6969 '''
70+ @Name: __parseConfig
7071 @Desc : Parses the configuration file passed and assigns
7172 the parsed configuration
73+ @Output : SUCCESS or FAILED
7274 '''
7375 try :
74- if self .__configFile is None :
75- return FAILED
76- self .__parsedConfig = configGenerator .\
77- getSetupConfig (self .__configFile )
76+ self .__parsedConfig = getSetupConfig (self .__configFile )
77+
7878 return SUCCESS
7979 except Exception , e :
8080 print "\n Exception Occurred Under __parseConfig : " \
@@ -94,6 +94,11 @@ def getLogger(self):
9494 return self .__tcRunLogger
9595
9696 def getDebugFile (self ):
97+ '''
98+ @Name : getDebugFile
99+ @Desc : Returns the Result file to be used for writing
100+ test outputs
101+ '''
97102 if self .__logFolderPath is not None :
98103 self .__tcResultFile = open (self .__logFolderPath +
99104 "/results.txt" , "w" )
@@ -108,6 +113,7 @@ def init(self):
108113 2. Creates a timestamped log folder and provides all logs
109114 to be dumped there
110115 3. Creates the DataCenter based upon configuration provided
116+ @Output : SUCCESS or FAILED
111117 '''
112118 try :
113119 if ((self .__parseConfig () != FAILED ) and
@@ -125,28 +131,31 @@ def init(self):
125131 return FAILED
126132
127133 def __initLogging (self ):
128- try :
129- '''
130- @Desc : 1. Initializes the logging for marvin and so provides
134+ '''
135+ @Name : __initLogging
136+ @Desc : 1. Initializes the logging for marvin and so provides
131137 various log features for automation run.
132138 2. Initializes all logs to be available under
133139 given Folder Path,where all test run logs
134140 are available for a given run.
135141 3. All logging like exception log,results, run info etc
136142 for a given test run are available under a given
137143 timestamped folder
138- '''
144+ @Output : SUCCESS or FAILED
145+ '''
146+ try :
139147 log_obj = MarvinLog ("CSLog" )
140148 if log_obj is None :
141149 return FAILED
142150 else :
143151 ret = log_obj .\
144- getLogs (self .__testModuleName ,
152+ createLogs (self .__testModuleName ,
145153 self .__parsedConfig .logger )
146154 if ret != FAILED :
147155 self .__logFolderPath = log_obj .getLogFolderPath ()
148156 self .__tcRunLogger = log_obj .getLogger ()
149- return SUCCESS
157+ return SUCCESS
158+ return FAILED
150159 except Exception , e :
151160 print "\n Exception Occurred Under __initLogging " \
152161 ":%s" % GetDetailExceptionInfo (e )
@@ -157,6 +166,7 @@ def __createTestClient(self):
157166 @Name : __createTestClient
158167 @Desc : Creates the TestClient during init
159168 based upon the parameters provided
169+ @Output: Returns SUCCESS or FAILED
160170 '''
161171 try :
162172 mgt_details = self .__parsedConfig .mgtSvr [0 ]
@@ -176,7 +186,12 @@ def __createTestClient(self):
176186 return FAILED
177187
178188 def __loadNewApiFromXml (self ):
189+ '''
190+ @Desc: Kept for future usage
191+ Will enhance later.
192+ '''
179193 try :
194+ return SUCCESS
180195 if self .__loadApiFlag :
181196 apiLoadCfg = self .__parsedConfig .apiLoadCfg
182197 api_dst_dir = apiLoadCfg .ParsedApiDestFolder + "/cloudstackAPI"
@@ -189,7 +204,7 @@ def __loadNewApiFromXml(self):
189204 print "Failed to create folder %s, " \
190205 "due to %s" % (api_dst_dir ,
191206 GetDetailExceptionInfo (e ))
192- exit ( 1 )
207+ return FAILED
193208 mgt_details = self .__parsedConfig .mgtSvr [0 ]
194209 cg = CodeGenerator (api_dst_dir )
195210 if os .path .exists (api_spec_file ):
@@ -206,6 +221,11 @@ def __loadNewApiFromXml(self):
206221 return FAILED
207222
208223 def __setTestDataPath (self ):
224+ '''
225+ @Name : __setTestDataPath
226+ @Desc: Sets the TestData Path for tests to run
227+ @Output: Returns SUCCESS or FAILED
228+ '''
209229 try :
210230 if ((self .__parsedConfig .TestData is not None ) and
211231 (self .__parsedConfig .TestData .Path is not None )):
@@ -217,14 +237,23 @@ def __setTestDataPath(self):
217237 return FAILED
218238
219239 def __deployDC (self ):
240+ '''
241+ @Name : __deployDC
242+ @Desc : Deploy the DataCenter and returns accordingly.
243+ @Output : SUCCESS or FAILED
244+ '''
220245 try :
221- '''
222- Deploy the DataCenter and retrieves test client.
223- '''
224- deploy_obj = DeployDataCenters (self .__testClient ,
246+ ret = SUCCESS
247+ if self .__deployFlag :
248+ deploy_obj = DeployDataCenters (self .__testClient ,
225249 self .__parsedConfig ,
226250 self .__tcRunLogger )
227- return deploy_obj .deploy () if self .__deployFlag else FAILED
251+ ret = deploy_obj .deploy ()
252+ if ret == SUCCESS :
253+ print "Deploy DC Successful"
254+ else :
255+ print "Deploy DC Failed"
256+ return ret
228257 except Exception , e :
229258 print "\n Exception Occurred Under __deployDC : %s" % \
230259 GetDetailExceptionInfo (e )
0 commit comments