Skip to content

Commit 097e653

Browse files
authored
Single unpredictable changes (#698)
* JIRA WDT-312 - remove single_unpredictable value from child_folders_type; fix unit tests * JIRA WDT-312 - revised alias files to conform to single-folder rules; added checks to alias file test; adjusted other tests * JIRA WDT-312 - added unit test for parent path; corrected some paths * JIRA WDT-449 - Corrected UnixMachine list path * JIRA WDT-312 - Use tokens for flattened folder substitution * JIRA WDT-312 - Set single-folder token when locations are appended * JIRA WDT-312 - remove DynamicallyCreated attribute * JIRA WDT-312 - Check for flattened folder token in validator * JIRA WDT-312 - Set single-folder and flattened-folder tokens as needed in discover * JIRA WDT-312 - Get exception type from Aliases object * JIRA WDT-312 - Set single-folder tokens for JDBC lookup * JIRA WDT-312 - Use shared methods for JDBC driver params lookup, flattened folder check * JIRA WDT-312 - Return the JDBC driver params location * JIRA WDT-312 - Change default for JdbcResource to datasource name; revised tests
1 parent f1404bf commit 097e653

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+717
-638
lines changed

core/src/main/python/wlsdeploy/aliases/alias_constants.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2017, 2019, Oracle Corporation and/or its affiliates. All rights reserved.
2+
Copyright (c) 2017, 2020, Oracle Corporation and/or its affiliates.
33
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
44
55
These constants are internal to the aliases module and should not be used, as they are not part of the public API.
@@ -21,6 +21,7 @@
2121
MODEL_NAME = 'model_name'
2222
NAME_VALUE = 'name_value'
2323
PASSWORD_TOKEN = "--FIX ME--"
24+
PATH_TOKEN = 'path_token'
2425
PREFERRED_MODEL_TYPE = 'preferred_model_type'
2526
RESTART_REQUIRED = 'restart_required'
2627
SET_MBEAN_TYPE = 'set_mbean_type'
@@ -52,9 +53,8 @@
5253
MULTIPLE_WITH_TYPE_SUBFOLDER = 'multiple_with_type_subfolder'
5354
NONE_CHILD_FOLDERS_TYPE = 'none'
5455
SINGLE = 'single'
55-
SINGLE_UNPREDICTABLE = 'single_unpredictable'
5656

57-
ChildFoldersTypes = Enum(['MULTIPLE', 'MULTIPLE_WITH_TYPE_SUBFOLDER', 'NONE', 'SINGLE', 'SINGLE_UNPREDICTABLE'])
57+
ChildFoldersTypes = Enum(['MULTIPLE', 'MULTIPLE_WITH_TYPE_SUBFOLDER', 'NONE', 'SINGLE'])
5858

5959
# get_method values
6060
GET = 'GET'

core/src/main/python/wlsdeploy/aliases/alias_entries.py

Lines changed: 14 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from wlsdeploy.aliases.alias_constants import MODEL_NAME
2626
from wlsdeploy.aliases.alias_constants import NAME_VALUE
2727
from wlsdeploy.aliases.alias_constants import NONE_CHILD_FOLDERS_TYPE
28+
from wlsdeploy.aliases.alias_constants import PATH_TOKEN
2829
from wlsdeploy.aliases.alias_constants import SECURITY_PROVIDER_NAME_MAP
2930
from wlsdeploy.aliases.alias_constants import SET_MBEAN_TYPE
3031
from wlsdeploy.aliases.alias_constants import SET_METHOD
@@ -44,6 +45,7 @@
4445
from wlsdeploy.aliases.alias_constants import WLST_SKIP_NAMES
4546
from wlsdeploy.aliases.alias_constants import WLST_SUBFOLDERS_PATH
4647
from wlsdeploy.aliases.alias_constants import WLST_TYPE
48+
from wlsdeploy.aliases.flattened_folder import FlattenedFolder
4749
from wlsdeploy.aliases.location_context import LocationContext
4850
from wlsdeploy.aliases.model_constants import APP_DEPLOYMENTS
4951
from wlsdeploy.aliases.model_constants import APPLICATION
@@ -369,7 +371,7 @@ def get_model_folder_path_for_location(self, location):
369371
if name is not None:
370372
my_loc.add_name_token(name_token, name)
371373
# dont include token in path for single-unpredictable
372-
if not self.is_location_child_folder_type(my_loc, ChildFoldersTypes.SINGLE_UNPREDICTABLE):
374+
if not self.is_location_child_folder_type(my_loc, ChildFoldersTypes.SINGLE):
373375
model_folder_path += '%s/' % name
374376
elif location_folder != location_folders[-1]:
375377
# Throw AliasException if name_token is missing
@@ -488,53 +490,25 @@ def is_location_child_folder_type(self, location, child_folders_type):
488490
_logger.exiting(class_name=_class_name, method_name=_method_name, result=result)
489491
return result
490492

491-
def location_contains_flattened_folder(self, location):
493+
def get_wlst_flattened_folder_info_for_location(self, location):
492494
"""
493-
Does the location folder specified refer to a WLST location that has been flattened to simplify the model?
495+
Get the information used to create the flattened folder.
494496
:param location: the location
495-
:return: True, if this location contains a flattened WLST folder, False otherwise
497+
:return: a FlattenedFolder object, or None if the location does not have a flattened folder
496498
"""
497-
_method_name = 'location_contains_flattened_folder'
498-
499-
_logger.entering(str(location), class_name=_class_name, method_name=_method_name)
500-
result = False
501-
folder_dict = self.__get_dictionary_for_location(location, False)
502-
if folder_dict is not None and FLATTENED_FOLDER_DATA in folder_dict:
503-
result = True
504-
_logger.exiting(class_name=_class_name, method_name=_method_name, result=result)
505-
return result
506-
507-
def get_wlst_flattened_type_for_location(self, location):
508-
"""
509-
Get the type of the flattened WLST folder to use to create the folder.
510-
:param location: the location
511-
:return: the type of the flattened WLST folder
512-
"""
513-
_method_name = 'get_wlst_flattened_type_for_location'
499+
_method_name = 'get_wlst_flattened_folder_info_for_location'
514500

515501
_logger.entering(str(location), class_name=_class_name, method_name=_method_name)
516502
result = None
517-
folder_dict = self.__get_dictionary_for_location(location, False)
518-
if folder_dict is not None and FLATTENED_FOLDER_DATA in folder_dict and \
519-
WLST_TYPE in folder_dict[FLATTENED_FOLDER_DATA]:
520-
result = folder_dict[FLATTENED_FOLDER_DATA][WLST_TYPE]
521-
_logger.exiting(class_name=_class_name, method_name=_method_name, result=result)
522-
return result
523-
524-
def get_wlst_flattened_name_for_location(self, location):
525-
"""
526-
Get the name of the flattened WLST folder to use to create the folder.
527-
:param location: the location
528-
:return: the name of the flattened WLST folder
529-
"""
530-
_method_name = 'get_wlst_flattened_name_for_location'
531503

532-
_logger.entering(str(location), class_name=_class_name, method_name=_method_name)
533-
result = None
534504
folder_dict = self.__get_dictionary_for_location(location, False)
535-
if folder_dict is not None and FLATTENED_FOLDER_DATA in folder_dict and \
536-
NAME_VALUE in folder_dict[FLATTENED_FOLDER_DATA]:
537-
result = alias_utils.get_token_value(location, folder_dict[FLATTENED_FOLDER_DATA][NAME_VALUE])
505+
flattened_folder_data = dictionary_utils.get_element(folder_dict, FLATTENED_FOLDER_DATA)
506+
if flattened_folder_data is not None:
507+
mbean_type = flattened_folder_data[WLST_TYPE]
508+
mbean_name = alias_utils.get_token_value(location, flattened_folder_data[NAME_VALUE])
509+
path_token = flattened_folder_data[PATH_TOKEN]
510+
result = FlattenedFolder(mbean_type, mbean_name, path_token)
511+
538512
_logger.exiting(class_name=_class_name, method_name=_method_name, result=result)
539513
return result
540514

core/src/main/python/wlsdeploy/aliases/aliases.py

Lines changed: 13 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ def requires_unpredictable_single_name_handling(self, location):
286286
_method_name = 'requires_unpredictable_single_name_handling'
287287

288288
try:
289-
return self._alias_entries.is_location_child_folder_type(location, ChildFoldersTypes.SINGLE_UNPREDICTABLE)
289+
return self._alias_entries.is_location_child_folder_type(location, ChildFoldersTypes.SINGLE)
290290
except AliasException, ae:
291291
self._raise_exception(ae, _method_name, 'WLSDPLY-19021', location.get_current_model_folder(),
292292
location.get_folder_path(), ae.getLocalizedMessage())
@@ -403,45 +403,17 @@ def get_wlst_mbean_type(self, location):
403403
except AliasException, ae:
404404
self._raise_exception(ae, _method_name, 'WLSDPLY-19010', str(location), ae.getLocalizedMessage())
405405

406-
def is_flattened_folder(self, location):
406+
def get_wlst_flattened_folder_info(self, location):
407407
"""
408-
Is the current location one that contains a flattened WLST folder?
408+
Get the information used to create the flattened folder.
409409
:param location: the location
410-
:return: True, if the specified location contains a flattened WLST tuple of folders, False otherwise
410+
:return: a FlattenedFolder object, or None if the location does not have a flattened folder
411411
:raises: Tool type exception: if an error occurs due to a bad location or bad alias data
412412
"""
413-
_method_name = 'is_flattened_folder'
413+
_method_name = 'get_wlst_flattened_mbean_info'
414414

415415
try:
416-
return self._alias_entries.location_contains_flattened_folder(location)
417-
except AliasException, ae:
418-
self._raise_exception(ae, _method_name, 'WLSDPLY-19011', str(location), ae.getLocalizedMessage())
419-
420-
def get_wlst_flattened_mbean_name(self, location):
421-
"""
422-
Get the flattened WLST folder name.
423-
:param location: the location
424-
:return: the flattened folder name
425-
:raises: Tool type exception: if an error occurs due to a bad location or bad alias data
426-
"""
427-
_method_name = 'get_wlst_flattened_mbean_name'
428-
429-
try:
430-
return self._alias_entries.get_wlst_flattened_name_for_location(location)
431-
except AliasException, ae:
432-
self._raise_exception(ae, _method_name, 'WLSDPLY-19012', str(location), ae.getLocalizedMessage())
433-
434-
def get_wlst_flattened_mbean_type(self, location):
435-
"""
436-
Get the flattened WLST folder type.
437-
:param location: the location
438-
:return: the flattened folder type
439-
:raises: Tool type exception: if an error occurs due to a bad location or bad alias data
440-
"""
441-
_method_name = 'get_wlst_flattened_mbean_type'
442-
443-
try:
444-
return self._alias_entries.get_wlst_flattened_type_for_location(location)
416+
return self._alias_entries.get_wlst_flattened_folder_info_for_location(location)
445417
except AliasException, ae:
446418
self._raise_exception(ae, _method_name, 'WLSDPLY-19013', str(location), ae.getLocalizedMessage())
447419

@@ -1204,6 +1176,13 @@ def decrypt_password(self, text):
12041176
# Convenience Methods #
12051177
###########################################################################
12061178

1179+
def get_exception_type(self):
1180+
"""
1181+
Get the exception type for this Aliases instance.
1182+
:return: the exception type
1183+
"""
1184+
return self._exception_type
1185+
12071186
def get_wlst_mbean_type_and_name(self, location):
12081187
"""
12091188
Get the MBean type and name from the specified location.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
"""
2+
Copyright (c) 2020, Oracle Corporation and/or its affiliates.
3+
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
4+
"""
5+
6+
7+
class FlattenedFolder(object):
8+
"""
9+
Class containing information for processing a flattened folder.
10+
"""
11+
def __init__(self, mbean_type, mbean_name, path_token):
12+
"""
13+
Creates a new instance of the object containing flattened folder information.
14+
:param mbean_type: the type of the MBean represented by the folder
15+
:param mbean_name: the name of the MBean represented by the folder
16+
:param path_token: the path token used to update the location context
17+
"""
18+
self.mbean_type = mbean_type
19+
self.mbean_name = mbean_name
20+
self.path_token = path_token
21+
22+
def get_mbean_type(self):
23+
"""
24+
Get the MBean type for the flattened folder.
25+
:return: the MBean type
26+
"""
27+
return self.mbean_type
28+
29+
def get_mbean_name(self):
30+
"""
31+
Get the MBean name for the flattened folder.
32+
:return: the MBean name
33+
"""
34+
return self.mbean_name
35+
36+
def get_path_token(self):
37+
"""
38+
Get the path token for the flattened folder.
39+
:return: the path token
40+
"""
41+
return self.path_token

core/src/main/python/wlsdeploy/tool/create/creator.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -404,13 +404,17 @@ def _process_flattened_folder(self, location):
404404
:param location: the location
405405
:raises: CreateException: if an error occurs
406406
"""
407-
if self.aliases.is_flattened_folder(location):
407+
flattened_folder_info = self.aliases.get_wlst_flattened_folder_info(location)
408+
if flattened_folder_info is not None:
408409
create_path = self.aliases.get_wlst_flattened_folder_create_path(location)
409-
mbean_type = self.aliases.get_wlst_flattened_mbean_type(location)
410-
mbean_name = self.aliases.get_wlst_flattened_mbean_name(location)
410+
mbean_type = flattened_folder_info.get_mbean_type()
411+
mbean_name = flattened_folder_info.get_mbean_name()
411412
existing_folders = self._get_existing_folders(create_path)
412413
if mbean_type not in existing_folders:
413414
self.wlst_helper.create(mbean_name, mbean_type)
415+
416+
path_token = flattened_folder_info.get_path_token()
417+
location.add_name_token(path_token, mbean_name)
414418
return
415419

416420
def _get_existing_folders(self, wlst_path):

core/src/main/python/wlsdeploy/tool/create/domain_creator.py

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@
3838
from wlsdeploy.aliases.model_constants import DRIVER_PARAMS_TRUSTSTORE_PROPERTY
3939
from wlsdeploy.aliases.model_constants import DRIVER_PARAMS_USER_PROPERTY
4040
from wlsdeploy.aliases.model_constants import DRIVER_PARAMS_kEYSTORE_PROPERTY
41-
from wlsdeploy.aliases.model_constants import JDBC_DRIVER_PARAMS
4241
from wlsdeploy.aliases.model_constants import JDBC_DRIVER_PARAMS_PROPERTIES
43-
from wlsdeploy.aliases.model_constants import JDBC_RESOURCE
4442
from wlsdeploy.aliases.model_constants import JDBC_SYSTEM_RESOURCE
4543
from wlsdeploy.aliases.model_constants import LOG_FILTER
4644
from wlsdeploy.aliases.model_constants import MACHINE
@@ -939,13 +937,7 @@ def __configure_fmw_infra_database(self):
939937
ds_names = self.wlst_helper.lsc()
940938

941939
for ds_name in ds_names:
942-
location = LocationContext()
943-
location.append_location(JDBC_SYSTEM_RESOURCE)
944-
token_name = self.aliases.get_name_token(location)
945-
location.add_name_token(token_name, ds_name)
946-
947-
location.append_location(JDBC_RESOURCE)
948-
location.append_location(JDBC_DRIVER_PARAMS)
940+
location = deployer_utils.get_jdbc_driver_params_location(ds_name, self.aliases)
949941
wlst_path = self.aliases.get_wlst_attributes_path(location)
950942
self.wlst_helper.cd(wlst_path)
951943

@@ -959,6 +951,7 @@ def __configure_fmw_infra_database(self):
959951
self.wlst_helper.set_if_needed(wlst_name, wlst_value, masked=True)
960952

961953
location.append_location(JDBC_DRIVER_PARAMS_PROPERTIES)
954+
deployer_utils.set_flattened_folder_token(location, self.aliases)
962955
token_name = self.aliases.get_name_token(location)
963956
if token_name is not None:
964957
location.add_name_token(token_name, DRIVER_PARAMS_USER_PROPERTY)
@@ -1008,15 +1001,8 @@ def __configure_fmw_infra_database(self):
10081001
fmw_database = self.wls_helper.get_jdbc_url_from_rcu_connect_string(rcu_database)
10091002
self.logger.fine('WLSDPLY-12221', fmw_database, class_name=self.__class_name, method_name=_method_name)
10101003

1011-
location = LocationContext()
1012-
location.append_location(JDBC_SYSTEM_RESOURCE)
1013-
token_name = self.aliases.get_name_token(location)
10141004
svc_table_ds_name = self.wls_helper.get_jrf_service_table_datasource_name()
1015-
if token_name is not None:
1016-
location.add_name_token(token_name, svc_table_ds_name)
1017-
1018-
location.append_location(JDBC_RESOURCE)
1019-
location.append_location(JDBC_DRIVER_PARAMS)
1005+
location = deployer_utils.get_jdbc_driver_params_location(svc_table_ds_name, self.aliases)
10201006
wlst_path = self.aliases.get_wlst_attributes_path(location)
10211007
self.wlst_helper.cd(wlst_path)
10221008

@@ -1035,6 +1021,7 @@ def __configure_fmw_infra_database(self):
10351021
self.wlst_helper.set_if_needed(wlst_name, wlst_value, masked=True)
10361022

10371023
location.append_location(JDBC_DRIVER_PARAMS_PROPERTIES)
1024+
deployer_utils.set_flattened_folder_token(location, self.aliases)
10381025
token_name = self.aliases.get_name_token(location)
10391026

10401027
if token_name is not None:

0 commit comments

Comments
 (0)