Skip to content

Commit 2a00e44

Browse files
Do not end discover if wlst.cd() fails
1 parent 4e65259 commit 2a00e44

File tree

3 files changed

+51
-27
lines changed

3 files changed

+51
-27
lines changed

core/src/main/python/wlsdeploy/tool/discover/common_resources_discoverer.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,13 @@ def get_datasources(self):
9191
self._populate_model_parameters(result[datasource], location)
9292

9393
location.append_location(model_second_folder)
94-
wlst_helper.cd(self._alias_helper.get_wlst_attributes_path(location))
95-
result[datasource][model_second_folder] = OrderedDict()
96-
resource_result = result[datasource][model_second_folder]
97-
self._populate_model_parameters(resource_result, location)
98-
self._discover_subfolders(resource_result, location)
99-
location.remove_name_token(name_token)
100-
location.pop_location()
94+
if self.wlst_cd(self._alias_helper.get_wlst_attributes_path(location), location):
95+
result[datasource][model_second_folder] = OrderedDict()
96+
resource_result = result[datasource][model_second_folder]
97+
self._populate_model_parameters(resource_result, location)
98+
self._discover_subfolders(resource_result, location)
99+
location.remove_name_token(name_token)
100+
location.pop_location()
101101
_logger.exiting(class_name=_class_name, method_name=_method_name, result=result)
102102
return model_top_folder_name, result
103103

core/src/main/python/wlsdeploy/tool/discover/discoverer.py

Lines changed: 42 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ def _populate_model_parameters(self, dictionary, location):
6464
_method_name = '_populate_model_parameters'
6565
wlst_path = self._alias_helper.get_wlst_attributes_path(location)
6666
_logger.finer('WLSDPLY-06100', wlst_path, class_name=_class_name, method_name=_method_name)
67-
self._wlst_helper.cd(wlst_path)
67+
68+
if not self.wlst_cd(wlst_path, location):
69+
return
70+
6871
wlst_params = self._get_attributes_for_current_location(location)
6972
_logger.finest('WLSDPLY-06102', self._wlst_helper.get_pwd(), wlst_params, class_name=_class_name,
7073
method_name=_method_name)
@@ -232,7 +235,7 @@ def _find_names_in_folder(self, location):
232235
folder_path = self._alias_helper.get_wlst_list_path(location)
233236
_logger.finest('WLSDPLY-06111', folder_path, class_name=_class_name, method_name=_method_name)
234237
if wlst_helper.path_exists(folder_path):
235-
self._wlst_helper.cd(folder_path)
238+
self.wlst_cd(folder_path, location)
236239
names = self._wlst_helper.lsc()
237240
return names
238241

@@ -264,15 +267,16 @@ def _find_subfolders(self, location):
264267
:return: list of subfolders
265268
"""
266269
wlst_path = self._alias_helper.get_wlst_subfolders_path(location)
267-
self._wlst_helper.cd(wlst_path)
268-
wlst_subfolders = self._wlst_helper.lsc()
269-
if wlst_subfolders:
270-
new_subfolders = []
271-
for wlst_subfolder in wlst_subfolders:
272-
model_subfolder_name = self._get_model_name(location, wlst_subfolder)
273-
if model_subfolder_name:
274-
new_subfolders.append(wlst_subfolder)
275-
wlst_subfolders = new_subfolders
270+
wlst_subfolders = []
271+
if self.wlst_cd(wlst_path, location):
272+
wlst_subfolders = self._wlst_helper.lsc()
273+
if wlst_subfolders:
274+
new_subfolders = []
275+
for wlst_subfolder in wlst_subfolders:
276+
model_subfolder_name = self._get_model_name(location, wlst_subfolder)
277+
if model_subfolder_name:
278+
new_subfolders.append(wlst_subfolder)
279+
wlst_subfolders = new_subfolders
276280
return wlst_subfolders
277281

278282
def _discover_subfolder_singleton(self, model_subfolder_name, location):
@@ -290,9 +294,9 @@ def _discover_subfolder_singleton(self, model_subfolder_name, location):
290294
# For all server subfolder names there should only be one path
291295
if self._mbean_names_exist(location):
292296
subfolder_path = self._alias_helper.get_wlst_attributes_path(location)
293-
self._wlst_helper.cd(subfolder_path)
294-
self._populate_model_parameters(subfolder_result, location)
295-
self._discover_subfolders(subfolder_result, location)
297+
if self.wlst_cd(subfolder_path, location):
298+
self._populate_model_parameters(subfolder_result, location)
299+
self._discover_subfolders(subfolder_result, location)
296300
_logger.finest('WLSDPLY-06111', str(location), class_name=_class_name, method_name=_method_name)
297301
_logger.exiting(class_name=_class_name, method_name=_method_name)
298302
return subfolder_result
@@ -374,9 +378,9 @@ def _discover_subfolder_with_names(self, model_subfolder_name, location, name_to
374378
subfolder_result[name] = OrderedDict()
375379
location.add_name_token(name_token, name)
376380
subfolder_path = self._alias_helper.get_wlst_attributes_path(location)
377-
self._wlst_helper.cd(subfolder_path)
378-
self._populate_model_parameters(subfolder_result[name], location)
379-
self._discover_subfolders(subfolder_result[name], location)
381+
if self.wlst_cd(subfolder_path, location):
382+
self._populate_model_parameters(subfolder_result[name], location)
383+
self._discover_subfolders(subfolder_result[name], location)
380384
location.remove_name_token(name_token)
381385
_logger.finest('WLSDPLY-06114', str(location), class_name=_class_name, method_name=_method_name)
382386
_logger.exiting(class_name=_class_name, method_name=_method_name)
@@ -449,8 +453,8 @@ def _discover_single_folder(self, location):
449453
_logger.entering(str(location), class_name=_class_name, method_name=_method_name)
450454
result = OrderedDict()
451455
subfolder_path = self._alias_helper.get_wlst_attributes_path(location)
452-
self._wlst_helper.cd(subfolder_path)
453-
self._populate_model_parameters(result, location)
456+
if self.wlst_cd(subfolder_path, location):
457+
self._populate_model_parameters(result, location)
454458
_logger.exiting(class_name=_class_name, method_name=_method_name)
455459
return result
456460

@@ -532,7 +536,7 @@ def _get_artificial_type(self, location):
532536
mbean_name = None
533537
subfolder_path = self._alias_helper.get_wlst_attributes_path(location)
534538
if subfolder_path:
535-
location_object = self._wlst_helper.cd(subfolder_path)
539+
location_object = self.wlst_cd(subfolder_path, location)
536540
if location_object is None:
537541
_logger.fine('WLSDPLY-06121', self._alias_helper.get_wlst_attributes_path(location),
538542
class_name=_class_name, method_name=_method_name)
@@ -577,6 +581,24 @@ def _get_wlst_attributes(self, location):
577581
continue
578582
return wlst_attributes
579583

584+
def wlst_cd(self, path, location):
585+
"""
586+
Change to the directory specified in the path. If the wlst.cd() fails, assume something is wrong with the
587+
construction of the path tokens: Log a message, and return a indication to the caller that it should
588+
not continue on in this path.
589+
:param path: where to change directory
590+
:param location: context containing the current location information used to determine the path
591+
:return: the mbean instance if the wlst.cd() was successful, or None
592+
"""
593+
_method_name = 'wlst_cd'
594+
result = None
595+
try:
596+
result = wlst_helper.cd(path)
597+
except PyWLSTException, pe:
598+
_logger.warning('WLSDPLY-06140', path, str(location), pe.getLocalizedMessage(), class_name=_class_name,
599+
method_name=_method_name)
600+
return result
601+
580602

581603
def add_to_model_if_not_empty(dictionary, entry_name, entry_value):
582604
"""

core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,8 @@ WLSDPLY-06127=Unable to discover attribute {0} at location {1} under wls version
458458
will not be added to the model : {4}
459459
WLSDPLY-06130=Unexpected exception attempting to discover MBean entries at location {0} will prevent the discovery \
460460
of attributes at this location : {1}
461+
WLSDPLY-06140=Unable to cd to the expected path {0} constructed from location context {1}; the current folder \
462+
and its sub-folders cannot be discovered : {2}
461463

462464
# resources_discoverer.py
463465
WLSDPLY-06300=Discovering domain model resources

0 commit comments

Comments
 (0)