31
31
32
32
from wlsdeploy .aliases .wlst_modes import WlstModes
33
33
from wlsdeploy .exception import exception_helper
34
+ from wlsdeploy .exception .expection_types import ExceptionType
34
35
from wlsdeploy .logging .platform_logger import PlatformLogger
35
36
from wlsdeploy .tool .discover import discoverer
36
37
from wlsdeploy .tool .discover .deployments_discoverer import DeploymentsDiscoverer
41
42
from wlsdeploy .tool .util import filter_helper
42
43
from wlsdeploy .tool .util import model_context_helper
43
44
from wlsdeploy .tool .util .variable_injector import VariableInjector
45
+ from wlsdeploy .tool .util import wlst_helper
46
+ from wlsdeploy .tool .util .wlst_helper import WlstHelper
44
47
from wlsdeploy .tool .validate .validator import Validator
45
48
from wlsdeploy .util import getcreds
46
49
from wlsdeploy .util import model_translator
47
50
from wlsdeploy .util import path_utils
48
51
from wlsdeploy .util import tool_exit
49
- from wlsdeploy .util import wlst_extended
50
- from wlsdeploy .util import wlst_helper
51
52
from wlsdeploy .util .cla_utils import CommandLineArgUtil
52
53
from wlsdeploy .util .model import Model
53
54
from wlsdeploy .util .weblogic_helper import WebLogicHelper
54
55
55
- wlst_extended .wlst_functions = globals ()
56
+ wlst_helper .wlst_functions = globals ()
56
57
57
58
_program_name = 'discoverDomain'
58
59
_class_name = 'discover'
@@ -216,19 +217,23 @@ def __process_java_home(optional_arg_map):
216
217
__logger .info ('WLSDPLY-06027' , java_home_name , iae .getLocalizedMessage (),
217
218
class_name = _class_name , method_name = _method_name )
218
219
219
- def __discover (model_context , aliases , injector ):
220
+
221
+ def __discover (model_context , aliases , injector , helper ):
220
222
"""
221
223
Populate the model from the domain.
222
224
:param model_context: the model context
225
+ :param aliases: aliases instance for discover
226
+ :param injector: variable injector instance
227
+ :param helper: wlst_helper instance
223
228
:return: the fully-populated model
224
229
:raises DiscoverException: if an error occurred while discover the domain
225
230
"""
226
231
_method_name = '__discover'
227
232
model = Model ()
228
233
base_location = LocationContext ()
229
- __connect_to_domain (model_context )
234
+ __connect_to_domain (model_context , helper )
230
235
try :
231
- _add_domain_name (base_location , aliases )
236
+ _add_domain_name (base_location , aliases , helper )
232
237
DomainInfoDiscoverer (model_context , model .get_model_domain_info (), base_location , wlst_mode = __wlst_mode ,
233
238
aliases = aliases , variable_injector = injector ).discover ()
234
239
TopologyDiscoverer (model_context , model .get_model_topology (), base_location , wlst_mode = __wlst_mode ,
@@ -247,15 +252,15 @@ def __discover(model_context, aliases, injector):
247
252
__logger .throwing (ex , class_name = _class_name , method_name = _method_name )
248
253
raise ex
249
254
250
- __disconnect_domain ()
255
+ __disconnect_domain (helper )
251
256
return model
252
257
253
258
254
- def _add_domain_name (location , aliases ):
259
+ def _add_domain_name (location , aliases , helper ):
255
260
_method_name = '_get_domain_name'
256
261
try :
257
- wlst_helper .cd ('/' )
258
- domain_name = wlst_helper .get (model_constants .DOMAIN_NAME )
262
+ helper .cd ('/' )
263
+ domain_name = helper .get (model_constants .DOMAIN_NAME )
259
264
except PyWLSTException , pe :
260
265
de = exception_helper .create_discover_exception ('WLSDPLY-06020' , pe .getLocalizedMessage ())
261
266
__logger .throwing (class_name = _class_name , method_name = _method_name , error = de )
@@ -281,19 +286,20 @@ def __discover_multi_tenant(model, model_context, base_location, aliases, inject
281
286
return
282
287
283
288
284
- def __connect_to_domain (model_context ):
289
+ def __connect_to_domain (model_context , helper ):
285
290
"""
286
291
Connects WLST to the domain by either connecting to the Admin Server or reading the domain from disk.
287
292
:param model_context: the model context
293
+ :param helper: wlst helper instance
288
294
:raises DiscoverException: if a WLST error occurs while connecting to or reading the domain
289
295
"""
290
296
_method_name = '__connect_to_domain'
291
297
292
298
__logger .entering (class_name = _class_name , method_name = _method_name )
293
299
if __wlst_mode == WlstModes .ONLINE :
294
300
try :
295
- wlst_helper .connect (model_context .get_admin_user (), model_context .get_admin_password (),
296
- model_context .get_admin_url ())
301
+ helper .connect (model_context .get_admin_user (), model_context .get_admin_password (),
302
+ model_context .get_admin_url ())
297
303
except PyWLSTException , wlst_ex :
298
304
ex = exception_helper .create_discover_exception ('WLSDPLY-06001' , model_context .get_admin_url (),
299
305
model_context .get_admin_user (),
@@ -302,7 +308,7 @@ def __connect_to_domain(model_context):
302
308
raise ex
303
309
else :
304
310
try :
305
- wlst_helper .read_domain (model_context .get_domain_home ())
311
+ helper .read_domain (model_context .get_domain_home ())
306
312
except PyWLSTException , wlst_ex :
307
313
wls_version = WebLogicHelper (__logger ).get_actual_weblogic_version ()
308
314
ex = exception_helper .create_discover_exception ('WLSDPLY-06002' , model_context .get_domain_home (),
@@ -354,25 +360,26 @@ def __close_archive(model_context):
354
360
return
355
361
356
362
357
- def __disconnect_domain ():
363
+ def __disconnect_domain (helper ):
358
364
"""
359
365
Disconnects WLST from the domain by either disconnecting from the Admin Server or closing the domain read from disk.
366
+ :param helper: wlst_helper instance
360
367
:raises DiscoverException: if a WLST error occurred while disconnecting or closing the domain
361
368
"""
362
369
_method_name = '__disconnect_domain'
363
370
364
371
__logger .entering (class_name = _class_name , method_name = _method_name )
365
372
if __wlst_mode == WlstModes .ONLINE :
366
373
try :
367
- wlst_helper .disconnect ()
374
+ helper .disconnect ()
368
375
except PyWLSTException , wlst_ex :
369
376
ex = exception_helper .create_discover_exception ('WLSDPLY-06006' ,
370
377
wlst_ex .getLocalizedMessage (), error = wlst_ex )
371
378
__logger .throwing (ex , class_name = _class_name , method_name = _method_name )
372
379
raise ex
373
380
else :
374
381
try :
375
- wlst_helper .close_domain ()
382
+ helper .close_domain ()
376
383
except PyWLSTException , wlst_ex :
377
384
ex = exception_helper .create_discover_exception ('WLSDPLY-06007' ,
378
385
wlst_ex .getLocalizedMessage (), error = wlst_ex )
@@ -494,7 +501,8 @@ def main(args):
494
501
for index , arg in enumerate (args ):
495
502
__logger .finer ('sys.argv[{0}] = {1}' , str (index ), str (arg ), class_name = _class_name , method_name = _method_name )
496
503
497
- wlst_helper .silence ()
504
+ helper = WlstHelper (ExceptionType .DISCOVER )
505
+ helper .silence ()
498
506
499
507
exit_code = CommandLineArgUtil .PROG_OK_EXIT_CODE
500
508
@@ -528,7 +536,7 @@ def main(args):
528
536
else :
529
537
__logger .info ('WLSDPLY-06024' , class_name = _class_name , method_name = _method_name )
530
538
try :
531
- model = __discover (model_context , aliases , discover_injector )
539
+ model = __discover (model_context , aliases , discover_injector , helper )
532
540
except DiscoverException , ex :
533
541
__logger .severe ('WLSDPLY-06011' , _program_name , model_context .get_domain_name (),
534
542
model_context .get_domain_home (), ex .getLocalizedMessage (),
0 commit comments