Skip to content

Single unpredictable changes #698

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Aug 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions core/src/main/python/wlsdeploy/aliases/alias_constants.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Copyright (c) 2017, 2019, Oracle Corporation and/or its affiliates. All rights reserved.
Copyright (c) 2017, 2020, Oracle Corporation and/or its affiliates.
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.

These constants are internal to the aliases module and should not be used, as they are not part of the public API.
Expand All @@ -21,6 +21,7 @@
MODEL_NAME = 'model_name'
NAME_VALUE = 'name_value'
PASSWORD_TOKEN = "--FIX ME--"
PATH_TOKEN = 'path_token'
PREFERRED_MODEL_TYPE = 'preferred_model_type'
RESTART_REQUIRED = 'restart_required'
SET_MBEAN_TYPE = 'set_mbean_type'
Expand Down Expand Up @@ -52,9 +53,8 @@
MULTIPLE_WITH_TYPE_SUBFOLDER = 'multiple_with_type_subfolder'
NONE_CHILD_FOLDERS_TYPE = 'none'
SINGLE = 'single'
SINGLE_UNPREDICTABLE = 'single_unpredictable'

ChildFoldersTypes = Enum(['MULTIPLE', 'MULTIPLE_WITH_TYPE_SUBFOLDER', 'NONE', 'SINGLE', 'SINGLE_UNPREDICTABLE'])
ChildFoldersTypes = Enum(['MULTIPLE', 'MULTIPLE_WITH_TYPE_SUBFOLDER', 'NONE', 'SINGLE'])

# get_method values
GET = 'GET'
Expand Down
54 changes: 14 additions & 40 deletions core/src/main/python/wlsdeploy/aliases/alias_entries.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from wlsdeploy.aliases.alias_constants import MODEL_NAME
from wlsdeploy.aliases.alias_constants import NAME_VALUE
from wlsdeploy.aliases.alias_constants import NONE_CHILD_FOLDERS_TYPE
from wlsdeploy.aliases.alias_constants import PATH_TOKEN
from wlsdeploy.aliases.alias_constants import SECURITY_PROVIDER_NAME_MAP
from wlsdeploy.aliases.alias_constants import SET_MBEAN_TYPE
from wlsdeploy.aliases.alias_constants import SET_METHOD
Expand All @@ -44,6 +45,7 @@
from wlsdeploy.aliases.alias_constants import WLST_SKIP_NAMES
from wlsdeploy.aliases.alias_constants import WLST_SUBFOLDERS_PATH
from wlsdeploy.aliases.alias_constants import WLST_TYPE
from wlsdeploy.aliases.flattened_folder import FlattenedFolder
from wlsdeploy.aliases.location_context import LocationContext
from wlsdeploy.aliases.model_constants import APP_DEPLOYMENTS
from wlsdeploy.aliases.model_constants import APPLICATION
Expand Down Expand Up @@ -369,7 +371,7 @@ def get_model_folder_path_for_location(self, location):
if name is not None:
my_loc.add_name_token(name_token, name)
# dont include token in path for single-unpredictable
if not self.is_location_child_folder_type(my_loc, ChildFoldersTypes.SINGLE_UNPREDICTABLE):
if not self.is_location_child_folder_type(my_loc, ChildFoldersTypes.SINGLE):
model_folder_path += '%s/' % name
elif location_folder != location_folders[-1]:
# Throw AliasException if name_token is missing
Expand Down Expand Up @@ -488,53 +490,25 @@ def is_location_child_folder_type(self, location, child_folders_type):
_logger.exiting(class_name=_class_name, method_name=_method_name, result=result)
return result

def location_contains_flattened_folder(self, location):
def get_wlst_flattened_folder_info_for_location(self, location):
"""
Does the location folder specified refer to a WLST location that has been flattened to simplify the model?
Get the information used to create the flattened folder.
:param location: the location
:return: True, if this location contains a flattened WLST folder, False otherwise
:return: a FlattenedFolder object, or None if the location does not have a flattened folder
"""
_method_name = 'location_contains_flattened_folder'

_logger.entering(str(location), class_name=_class_name, method_name=_method_name)
result = False
folder_dict = self.__get_dictionary_for_location(location, False)
if folder_dict is not None and FLATTENED_FOLDER_DATA in folder_dict:
result = True
_logger.exiting(class_name=_class_name, method_name=_method_name, result=result)
return result

def get_wlst_flattened_type_for_location(self, location):
"""
Get the type of the flattened WLST folder to use to create the folder.
:param location: the location
:return: the type of the flattened WLST folder
"""
_method_name = 'get_wlst_flattened_type_for_location'
_method_name = 'get_wlst_flattened_folder_info_for_location'

_logger.entering(str(location), class_name=_class_name, method_name=_method_name)
result = None
folder_dict = self.__get_dictionary_for_location(location, False)
if folder_dict is not None and FLATTENED_FOLDER_DATA in folder_dict and \
WLST_TYPE in folder_dict[FLATTENED_FOLDER_DATA]:
result = folder_dict[FLATTENED_FOLDER_DATA][WLST_TYPE]
_logger.exiting(class_name=_class_name, method_name=_method_name, result=result)
return result

def get_wlst_flattened_name_for_location(self, location):
"""
Get the name of the flattened WLST folder to use to create the folder.
:param location: the location
:return: the name of the flattened WLST folder
"""
_method_name = 'get_wlst_flattened_name_for_location'

_logger.entering(str(location), class_name=_class_name, method_name=_method_name)
result = None
folder_dict = self.__get_dictionary_for_location(location, False)
if folder_dict is not None and FLATTENED_FOLDER_DATA in folder_dict and \
NAME_VALUE in folder_dict[FLATTENED_FOLDER_DATA]:
result = alias_utils.get_token_value(location, folder_dict[FLATTENED_FOLDER_DATA][NAME_VALUE])
flattened_folder_data = dictionary_utils.get_element(folder_dict, FLATTENED_FOLDER_DATA)
if flattened_folder_data is not None:
mbean_type = flattened_folder_data[WLST_TYPE]
mbean_name = alias_utils.get_token_value(location, flattened_folder_data[NAME_VALUE])
path_token = flattened_folder_data[PATH_TOKEN]
result = FlattenedFolder(mbean_type, mbean_name, path_token)

_logger.exiting(class_name=_class_name, method_name=_method_name, result=result)
return result

Expand Down
47 changes: 13 additions & 34 deletions core/src/main/python/wlsdeploy/aliases/aliases.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def requires_unpredictable_single_name_handling(self, location):
_method_name = 'requires_unpredictable_single_name_handling'

try:
return self._alias_entries.is_location_child_folder_type(location, ChildFoldersTypes.SINGLE_UNPREDICTABLE)
return self._alias_entries.is_location_child_folder_type(location, ChildFoldersTypes.SINGLE)
except AliasException, ae:
self._raise_exception(ae, _method_name, 'WLSDPLY-19021', location.get_current_model_folder(),
location.get_folder_path(), ae.getLocalizedMessage())
Expand Down Expand Up @@ -403,45 +403,17 @@ def get_wlst_mbean_type(self, location):
except AliasException, ae:
self._raise_exception(ae, _method_name, 'WLSDPLY-19010', str(location), ae.getLocalizedMessage())

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

try:
return self._alias_entries.location_contains_flattened_folder(location)
except AliasException, ae:
self._raise_exception(ae, _method_name, 'WLSDPLY-19011', str(location), ae.getLocalizedMessage())

def get_wlst_flattened_mbean_name(self, location):
"""
Get the flattened WLST folder name.
:param location: the location
:return: the flattened folder name
:raises: Tool type exception: if an error occurs due to a bad location or bad alias data
"""
_method_name = 'get_wlst_flattened_mbean_name'

try:
return self._alias_entries.get_wlst_flattened_name_for_location(location)
except AliasException, ae:
self._raise_exception(ae, _method_name, 'WLSDPLY-19012', str(location), ae.getLocalizedMessage())

def get_wlst_flattened_mbean_type(self, location):
"""
Get the flattened WLST folder type.
:param location: the location
:return: the flattened folder type
:raises: Tool type exception: if an error occurs due to a bad location or bad alias data
"""
_method_name = 'get_wlst_flattened_mbean_type'

try:
return self._alias_entries.get_wlst_flattened_type_for_location(location)
return self._alias_entries.get_wlst_flattened_folder_info_for_location(location)
except AliasException, ae:
self._raise_exception(ae, _method_name, 'WLSDPLY-19013', str(location), ae.getLocalizedMessage())

Expand Down Expand Up @@ -1204,6 +1176,13 @@ def decrypt_password(self, text):
# Convenience Methods #
###########################################################################

def get_exception_type(self):
"""
Get the exception type for this Aliases instance.
:return: the exception type
"""
return self._exception_type

def get_wlst_mbean_type_and_name(self, location):
"""
Get the MBean type and name from the specified location.
Expand Down
41 changes: 41 additions & 0 deletions core/src/main/python/wlsdeploy/aliases/flattened_folder.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
"""
Copyright (c) 2020, Oracle Corporation and/or its affiliates.
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
"""


class FlattenedFolder(object):
"""
Class containing information for processing a flattened folder.
"""
def __init__(self, mbean_type, mbean_name, path_token):
"""
Creates a new instance of the object containing flattened folder information.
:param mbean_type: the type of the MBean represented by the folder
:param mbean_name: the name of the MBean represented by the folder
:param path_token: the path token used to update the location context
"""
self.mbean_type = mbean_type
self.mbean_name = mbean_name
self.path_token = path_token

def get_mbean_type(self):
"""
Get the MBean type for the flattened folder.
:return: the MBean type
"""
return self.mbean_type

def get_mbean_name(self):
"""
Get the MBean name for the flattened folder.
:return: the MBean name
"""
return self.mbean_name

def get_path_token(self):
"""
Get the path token for the flattened folder.
:return: the path token
"""
return self.path_token
10 changes: 7 additions & 3 deletions core/src/main/python/wlsdeploy/tool/create/creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,13 +404,17 @@ def _process_flattened_folder(self, location):
:param location: the location
:raises: CreateException: if an error occurs
"""
if self.aliases.is_flattened_folder(location):
flattened_folder_info = self.aliases.get_wlst_flattened_folder_info(location)
if flattened_folder_info is not None:
create_path = self.aliases.get_wlst_flattened_folder_create_path(location)
mbean_type = self.aliases.get_wlst_flattened_mbean_type(location)
mbean_name = self.aliases.get_wlst_flattened_mbean_name(location)
mbean_type = flattened_folder_info.get_mbean_type()
mbean_name = flattened_folder_info.get_mbean_name()
existing_folders = self._get_existing_folders(create_path)
if mbean_type not in existing_folders:
self.wlst_helper.create(mbean_name, mbean_type)

path_token = flattened_folder_info.get_path_token()
location.add_name_token(path_token, mbean_name)
return

def _get_existing_folders(self, wlst_path):
Expand Down
21 changes: 4 additions & 17 deletions core/src/main/python/wlsdeploy/tool/create/domain_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@
from wlsdeploy.aliases.model_constants import DRIVER_PARAMS_TRUSTSTORE_PROPERTY
from wlsdeploy.aliases.model_constants import DRIVER_PARAMS_USER_PROPERTY
from wlsdeploy.aliases.model_constants import DRIVER_PARAMS_kEYSTORE_PROPERTY
from wlsdeploy.aliases.model_constants import JDBC_DRIVER_PARAMS
from wlsdeploy.aliases.model_constants import JDBC_DRIVER_PARAMS_PROPERTIES
from wlsdeploy.aliases.model_constants import JDBC_RESOURCE
from wlsdeploy.aliases.model_constants import JDBC_SYSTEM_RESOURCE
from wlsdeploy.aliases.model_constants import LOG_FILTER
from wlsdeploy.aliases.model_constants import MACHINE
Expand Down Expand Up @@ -939,13 +937,7 @@ def __configure_fmw_infra_database(self):
ds_names = self.wlst_helper.lsc()

for ds_name in ds_names:
location = LocationContext()
location.append_location(JDBC_SYSTEM_RESOURCE)
token_name = self.aliases.get_name_token(location)
location.add_name_token(token_name, ds_name)

location.append_location(JDBC_RESOURCE)
location.append_location(JDBC_DRIVER_PARAMS)
location = deployer_utils.get_jdbc_driver_params_location(ds_name, self.aliases)
wlst_path = self.aliases.get_wlst_attributes_path(location)
self.wlst_helper.cd(wlst_path)

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

location.append_location(JDBC_DRIVER_PARAMS_PROPERTIES)
deployer_utils.set_flattened_folder_token(location, self.aliases)
token_name = self.aliases.get_name_token(location)
if token_name is not None:
location.add_name_token(token_name, DRIVER_PARAMS_USER_PROPERTY)
Expand Down Expand Up @@ -1008,15 +1001,8 @@ def __configure_fmw_infra_database(self):
fmw_database = self.wls_helper.get_jdbc_url_from_rcu_connect_string(rcu_database)
self.logger.fine('WLSDPLY-12221', fmw_database, class_name=self.__class_name, method_name=_method_name)

location = LocationContext()
location.append_location(JDBC_SYSTEM_RESOURCE)
token_name = self.aliases.get_name_token(location)
svc_table_ds_name = self.wls_helper.get_jrf_service_table_datasource_name()
if token_name is not None:
location.add_name_token(token_name, svc_table_ds_name)

location.append_location(JDBC_RESOURCE)
location.append_location(JDBC_DRIVER_PARAMS)
location = deployer_utils.get_jdbc_driver_params_location(svc_table_ds_name, self.aliases)
wlst_path = self.aliases.get_wlst_attributes_path(location)
self.wlst_helper.cd(wlst_path)

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

location.append_location(JDBC_DRIVER_PARAMS_PROPERTIES)
deployer_utils.set_flattened_folder_token(location, self.aliases)
token_name = self.aliases.get_name_token(location)

if token_name is not None:
Expand Down
Loading