26
26
27
27
sys .path .append (os .path .dirname (os .path .realpath (sys .argv [0 ])))
28
28
29
+ from wlsdeploy .aliases import model_constants
30
+ from wlsdeploy .aliases .aliases import Aliases
31
+ from wlsdeploy .aliases .location_context import LocationContext
29
32
from wlsdeploy .aliases .wlst_modes import WlstModes
30
33
from wlsdeploy .exception import exception_helper
31
34
from wlsdeploy .logging .platform_logger import PlatformLogger
@@ -135,7 +138,7 @@ def __process_online_args(optional_arg_map):
135
138
raise ex
136
139
optional_arg_map [CommandLineArgUtil .ADMIN_PASS_SWITCH ] = String (password )
137
140
138
- __logger . info ( 'WLSDPLY-06020' )
141
+ mode = WlstModes . ONLINE
139
142
return mode
140
143
141
144
@@ -159,23 +162,28 @@ def __process_archive_filename_arg(required_arg_map):
159
162
return
160
163
161
164
162
- def __discover (model_context ):
165
+ def __discover (model_context , aliases ):
163
166
"""
164
167
Populate the model from the domain.
165
168
:param model_context: the model context
166
169
:return: the fully-populated model
167
170
:raises DiscoverException: if an error occurred while discover the domain
168
171
"""
169
172
_method_name = '__discover'
170
-
171
173
model = Model ()
174
+ base_location = LocationContext ()
172
175
__connect_to_domain (model_context )
173
176
try :
174
- DomainInfoDiscoverer (model_context , model .get_model_domain_info (), wlst_mode = __wlst_mode ).discover ()
175
- TopologyDiscoverer (model_context , model .get_model_topology (), wlst_mode = __wlst_mode ).discover ()
176
- ResourcesDiscoverer (model_context , model .get_model_resources (), wlst_mode = __wlst_mode ).discover ()
177
- DeploymentsDiscoverer (model_context , model .get_model_app_deployments (), wlst_mode = __wlst_mode ).discover ()
178
- __discover_multi_tenant (model , model_context )
177
+ _add_domain_name (base_location , aliases )
178
+ DomainInfoDiscoverer (model_context , model .get_model_domain_info (), base_location , wlst_mode = __wlst_mode ,
179
+ aliases = aliases ).discover ()
180
+ TopologyDiscoverer (model_context , model .get_model_topology (), base_location , wlst_mode = __wlst_mode ,
181
+ aliases = aliases ).discover ()
182
+ ResourcesDiscoverer (model_context , model .get_model_resources (), base_location , wlst_mode = __wlst_mode ,
183
+ aliases = aliases ).discover ()
184
+ DeploymentsDiscoverer (model_context , model .get_model_app_deployments (), base_location , wlst_mode = __wlst_mode ,
185
+ aliases = aliases ).discover ()
186
+ __discover_multi_tenant (model , model_context , base_location , aliases )
179
187
except AliasException , ae :
180
188
wls_version = WebLogicHelper (__logger ).get_actual_weblogic_version ()
181
189
wlst_mode = WlstModes .from_value (__wlst_mode )
@@ -189,14 +197,32 @@ def __discover(model_context):
189
197
return model
190
198
191
199
192
- def __discover_multi_tenant (model , model_context ):
200
+ def _add_domain_name (location , aliases ):
201
+ _method_name = '_get_domain_name'
202
+ try :
203
+ wlst_helper .cd ('/' )
204
+ domain_name = wlst_helper .get (model_constants .DOMAIN_NAME )
205
+ except PyWLSTException , pe :
206
+ de = exception_helper .create_discover_exception ('WLSDPLY-06020' , pe .getLocalizedMessage ())
207
+ __logger .throwing (class_name = _class_name , method_name = _method_name , error = de )
208
+ raise de
209
+ if domain_name is not None :
210
+ location .add_name_token (aliases .get_name_token (location ), domain_name )
211
+ __logger .info ('WLSDPLY-06022' , domain_name , class_name = _class_name , method_name = _method_name )
212
+ else :
213
+ de = exception_helper .create_discover_exception ('WLSDPLY-WLSDPLY-06021' )
214
+ __logger .throwing (class_name = _class_name , method_name = _method_name , error = de )
215
+ raise de
216
+
217
+
218
+ def __discover_multi_tenant (model , model_context , base_location , aliases ):
193
219
"""
194
220
Discover the multi-tenant-related parts of the domain, if they exist.
195
221
:param model: the model object to populate
196
222
:param model_context: the model context object
197
223
:raises DiscoverException: if an error occurs during discovery
198
224
"""
199
- MultiTenantDiscoverer (model , model_context , wlst_mode = __wlst_mode ).discover ()
225
+ MultiTenantDiscoverer (model , model_context , base_location , wlst_mode = __wlst_mode , aliases = aliases ).discover ()
200
226
return
201
227
202
228
@@ -356,7 +382,7 @@ def __persist_model(model, model_context):
356
382
return
357
383
358
384
359
- def __check_and_customize_model (model , model_context ):
385
+ def __check_and_customize_model (model , model_context , aliases ):
360
386
"""
361
387
Customize the model dictionary before persisting. Validate the model after customization for informational
362
388
purposes. Any validation errors will not stop the discovered model to be persisted.
@@ -368,25 +394,24 @@ def __check_and_customize_model(model, model_context):
368
394
if filter_helper .apply_filters (model .get_model (), "discover" ):
369
395
__logger .info ('WLSDPLY-06014' , _class_name = _class_name , method_name = _method_name )
370
396
371
-
372
397
try :
373
- validator = Validator (model_context , wlst_mode = __wlst_mode )
398
+ validator = Validator (model_context , wlst_mode = __wlst_mode , aliases = aliases )
374
399
375
400
# no variables are generated by the discover tool
376
401
validator .validate_in_tool_mode (model .get_model (), variables_file_name = None ,
377
- archive_file_name = model_context .get_archive_file_name ())
402
+ archive_file_name = model_context .get_archive_file_name ())
378
403
except ValidateException , ex :
379
404
__logger .warning ('WLSDPLY-06015' , ex .getLocalizedMessage (), class_name = _class_name , method_name = _method_name )
380
405
381
406
382
- def __log_and_exit (exit_code , _class_name , _method_name ):
407
+ def __log_and_exit (exit_code , class_name , method_name ):
383
408
"""
384
409
Helper method to log the exiting message and call sys.exit()
385
410
:param exit_code: the exit code to use
386
- :param _class_name : the class name to pass to the logger
387
- :param _method_name : the method name to pass to the logger
411
+ :param class_name : the class name to pass to the logger
412
+ :param method_name : the method name to pass to the logger
388
413
"""
389
- __logger .exiting (result = exit_code , class_name = _class_name , method_name = _method_name )
414
+ __logger .exiting (result = exit_code , class_name = class_name , method_name = method_name )
390
415
sys .exit (exit_code )
391
416
392
417
@@ -424,16 +449,17 @@ def main(args):
424
449
ex .getLocalizedMessage (), error = ex , class_name = _class_name , method_name = _method_name )
425
450
__log_and_exit (CommandLineArgUtil .PROG_ERROR_EXIT_CODE , _class_name , _method_name )
426
451
452
+ aliases = Aliases (model_context , wlst_mode = __wlst_mode )
427
453
model = None
428
454
try :
429
- model = __discover (model_context )
455
+ model = __discover (model_context , aliases )
430
456
except DiscoverException , ex :
431
457
__logger .severe ('WLSDPLY-06011' , _program_name , model_context .get_domain_name (),
432
458
model_context .get_domain_home (), ex .getLocalizedMessage (),
433
459
error = ex , class_name = _class_name , method_name = _method_name )
434
460
__log_and_exit (CommandLineArgUtil .PROG_ERROR_EXIT_CODE , _class_name , _method_name )
435
461
436
- __check_and_customize_model (model , model_context )
462
+ __check_and_customize_model (model , model_context , aliases )
437
463
438
464
try :
439
465
__persist_model (model , model_context )
0 commit comments