Skip to content

Commit

Permalink
Merge branch 'jrf-create-domain-diff-pwds' into 'main'
Browse files Browse the repository at this point in the history
Fix JRF domain creation not using user provided sparse datasource model

See merge request weblogic-cloud/weblogic-deploy-tooling!1513
  • Loading branch information
robertpatrick committed Oct 11, 2023
2 parents 35c6b92 + ff6cea4 commit b3707be
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 5 deletions.
30 changes: 28 additions & 2 deletions core/src/main/python/wlsdeploy/tool/create/domain_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
from wlsdeploy.aliases.model_constants import PASSWORD
from wlsdeploy.aliases.model_constants import PASSWORD_ENCRYPTED
from wlsdeploy.aliases.model_constants import PRODUCTION_MODE_ENABLED
from wlsdeploy.aliases.model_constants import RESOURCES
from wlsdeploy.aliases.model_constants import RCU_COMP_INFO
from wlsdeploy.aliases.model_constants import RCU_DB_INFO
from wlsdeploy.aliases.model_constants import RCU_STG_INFO
Expand Down Expand Up @@ -94,6 +95,7 @@
from wlsdeploy.tool.deploy import model_deployer
from wlsdeploy.tool.util.archive_helper import ArchiveHelper
from wlsdeploy.tool.util.credential_map_helper import CredentialMapHelper
from wlsdeploy.tool.deploy.datasource_deployer import DatasourceDeployer
from wlsdeploy.tool.util.default_authenticator_helper import DefaultAuthenticatorHelper
from wlsdeploy.tool.util.library_helper import LibraryHelper
from wlsdeploy.tool.util.saml2_security_helper import Saml2SecurityHelper
Expand All @@ -105,6 +107,8 @@
from wlsdeploy.util import model
from wlsdeploy.util import model_helper
from wlsdeploy.util import string_utils
from wlsdeploy.aliases.wlst_modes import WlstModes

import wlsdeploy.util.unicode_helper as str_helper

class DomainCreator(Creator):
Expand Down Expand Up @@ -154,7 +158,7 @@ def __init__(self, model_dictionary, model_context, aliases):

self.__default_domain_name = None
self.__default_admin_server_name = None

self.__fmw_template_default_data_sources_names = None
archive_file_name = self.model_context.get_archive_file_name()
if archive_file_name is not None:
self.archive_helper = ArchiveHelper(archive_file_name, self._domain_home, self.logger,
Expand Down Expand Up @@ -732,9 +736,30 @@ def __apply_base_domain_config(self, topology_folder_list, delete=True):

self.__create_other_domain_artifacts(location, topology_local_list)

if self.__fmw_template_default_data_sources_names:
self._reset_fmw_template_data_source_defaults_from_model()

self.logger.exiting(class_name=self.__class_name, method_name=_method_name)
return

def _reset_fmw_template_data_source_defaults_from_model(self):
# Go through the model to find any FMW data sources to override the defaults
# from users's model before the first writeDomain.
resources_dict = self.model.get_model_resources()
if JDBC_SYSTEM_RESOURCE in resources_dict:
fmw_resources = {RESOURCES: {JDBC_SYSTEM_RESOURCE: {}}}
fmw_jdbc_resources = fmw_resources[RESOURCES][JDBC_SYSTEM_RESOURCE]
ds_dict = resources_dict[JDBC_SYSTEM_RESOURCE]
for ds_name in ds_dict:
fmw_ds = ds_dict[ds_name]
if ds_name in self.__fmw_template_default_data_sources_names:
fmw_jdbc_resources[ds_name] = fmw_ds
if len(fmw_resources[RESOURCES][JDBC_SYSTEM_RESOURCE]) != 0:
ds_location = LocationContext()
data_source_deployer = DatasourceDeployer(self.model, self.model_context, self.aliases,
WlstModes.OFFLINE)
data_source_deployer.add_data_sources(fmw_resources[RESOURCES], ds_location)

def __set_core_domain_params(self):
"""
Set the core domain parameters.
Expand Down Expand Up @@ -1192,9 +1217,9 @@ def __set_rcu_datasource_parameters_without_shadow_table(self, rcu_db_info):
folder_path = self.aliases.get_wlst_list_path(location)
self.wlst_helper.cd(folder_path)
ds_names = self.wlst_helper.lsc()
self.__fmw_template_default_data_sources_names = ds_names

for ds_name in ds_names:

# Set the driver params
actual_url = self.__set_datasource_url(ds_name, fmw_database)
self.__set_datasource_password(ds_name, rcu_schema_pwd)
Expand All @@ -1210,6 +1235,7 @@ def __set_rcu_datasource_parameters_without_shadow_table(self, rcu_db_info):
self.logger.info('WLSDPLY_12575', ds_name, actual_url, actual_schema, pset,
class_name=self.__class_name, method_name=_method_name)


def __reset_datasource_template_userid(self, datasource_name, rcu_prefix):
location = deployer_utils.get_jdbc_driver_params_location(datasource_name, self.aliases)
location.append_location(JDBC_DRIVER_PARAMS_PROPERTIES)
Expand Down
39 changes: 36 additions & 3 deletions documentation/3.0/content/userguide/database/connect-db.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,45 @@ In the following examples of the JRF data source sparse model, you can use it to

#### Default template data source

This is a sparse model for JRF data sources with the RCU prefix `FMW1`.
You will need to update at least the `URL`, `PasswordEncrypted`, and the `user` property value. When you specify the value of `URL`, it
must be a valid `JDBC URL` format, which is different from the `rcu_db_conn_string` which does not require the `jdbc:oracle:thin:...` part.
For example, if you have created RCU schemas with different passwords for different schemas. You can use a sparse model to create a domain with different passwords for different FMW data sources.

```yaml
domainInfo:
RCUDbInfo:
rcu_prefix : -- FIX ME --
rcu_schema_password : -- FIX ME --
rcu_db_conn_string : -- FIX ME --
resources:
JDBCSystemResource:
LocalSvcTblDataSource:
JdbcResource:
JDBCDriverParams:
PasswordEncrypted: --FIX ME--
opss-data-source:
JdbcResource:
JDBCDriverParams:
PasswordEncrypted: --FIX ME--
opss-audit-viewDS:
JdbcResource:
JDBCDriverParams:
PasswordEncrypted: --FIX ME--
opss-audit-DBDS:
JdbcResource:
JDBCDriverParams:
PasswordEncrypted: --FIX ME--
mds-owsm:
JdbcResource:
JDBCDriverParams:
PasswordEncrypted: --FIX ME--
```

This is a sparse model of the FMW data sources discovered from a FMW domain. You can use any part of it to update your domain.

```yaml
...
resources:
JDBCSystemResource:
WLSSchemaDataSource:
JdbcResource:
Expand Down

0 comments on commit b3707be

Please sign in to comment.