Skip to content

Commit 15b9d9b

Browse files
authored
Apply OPSS credential values from the model during domain creation (#1431)
1 parent 25d1a77 commit 15b9d9b

File tree

7 files changed

+132
-18
lines changed

7 files changed

+132
-18
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
from wlsdeploy.aliases.model_constants import JPA
6060
from wlsdeploy.aliases.model_constants import ODL_CONFIGURATION
6161
from wlsdeploy.aliases.model_constants import OHS
62+
from wlsdeploy.aliases.model_constants import OPSS_INITIALIZATION
6263
from wlsdeploy.aliases.model_constants import RCU_DB_INFO
6364
from wlsdeploy.aliases.model_constants import RESOURCE_MANAGER
6465
from wlsdeploy.aliases.model_constants import RESOURCES
@@ -157,6 +158,7 @@ class AliasEntries(object):
157158
]
158159

159160
__domain_info_top_level_folders = [
161+
OPSS_INITIALIZATION,
160162
RCU_DB_INFO,
161163
WLS_ROLES,
162164
WLS_USER_PASSWORD_CREDENTIAL_MAPPINGS

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@
208208
ODL_CONFIGURATION = 'ODLConfiguration'
209209
OHS = 'OHS'
210210
OPEN_LDAP_AUTHENTICATOR = 'OpenLDAPAuthenticator'
211+
OPSS_INITIALIZATION = 'OPSSInitialization'
211212
ORACLE_OID_AUTHENTICATOR = 'OracleInternetDirectoryAuthenticator'
212213
ORACLE_OUD_AUTHENTICATOR = 'OracleUnifiedDirectoryAuthenticator'
213214
ORACLE_OVD_AUTHENTICATOR = 'OracleVirtualDirectoryAuthenticator'
@@ -296,6 +297,7 @@
296297
SYSTEM_PASSWORD_VALIDATOR = 'SystemPasswordValidator'
297298
TARGET = 'Target'
298299
TARGET_DESTINATION = 'TargetDestination'
300+
TARGET_KEY = 'TargetKey'
299301
TEMPLATE = 'Template'
300302
THREAD_DUMP_ACTION = 'ThreadDumpAction'
301303
THRESHOLDS = 'Thresholds'

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
from wlsdeploy.exception import exception_helper
8181
from wlsdeploy.exception.expection_types import ExceptionType
8282
from wlsdeploy.tool.create import atp_helper
83+
from wlsdeploy.tool.create import opss_helper
8384
from wlsdeploy.tool.create import ssl_helper
8485
from wlsdeploy.tool.create import rcudbinfo_helper
8586
from wlsdeploy.tool.create.creator import Creator
@@ -334,7 +335,7 @@ def __run_rcu(self):
334335
truststore_type)
335336

336337
ssl_conn_properties["oracle.net.ssl_server_dn_match"] = 'false'
337-
338+
338339
fmw_database = self.wls_helper.get_jdbc_url_from_rcu_connect_string(rcu_database)
339340
runner = RCURunner.createSslRunner(domain_type, oracle_home, java_home, fmw_database, rcu_prefix, rcu_schemas,
340341
rcu_db_info.get_rcu_variables(), rcu_runner_map, ssl_conn_properties)
@@ -641,6 +642,9 @@ def __extend_domain_with_select_template(self, domain_home):
641642

642643
self.__apply_base_domain_config(topology_folder_list, delete=True)
643644

645+
# apply OPSS configuration before the first domain write
646+
opss_helper.create_credentials(self.model.get_model(), self.model_context, self.aliases, self.wlst_helper)
647+
644648
self.logger.info('WLSDPLY-12205', self._domain_name, domain_home,
645649
class_name=self.__class_name, method_name=_method_name)
646650
self.wlst_helper.write_domain(domain_home)
@@ -1137,7 +1141,7 @@ def __validate_and_get_ssl_rcudbinfo(self, rcu_db_info, check_admin_pwd=False):
11371141
"'rcu_admin_password']")
11381142
raise ex
11391143

1140-
return tns_admin, rcu_database, truststore_pwd, truststore_type, truststore, keystore_pwd, keystore_type, keystore
1144+
return tns_admin, rcu_database, truststore_pwd, truststore_type, truststore, keystore_pwd, keystore_type, keystore
11411145

11421146
def __configure_fmw_infra_database(self):
11431147
"""

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

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -335,16 +335,17 @@ def __resolve_paths(self):
335335

336336
if not self._paths_resolved:
337337
if self._model_context is None:
338-
ex = exception_helper.create_create_exception('WLSDPLY-12302')
338+
ex = exception_helper.create_cla_exception(ExitCode.ARG_VALIDATION_ERROR, 'WLSDPLY-12302')
339339
self._logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
340340
raise ex
341341

342342
if 'baseTemplate' in self._domain_typedef:
343343
self._domain_typedef['baseTemplate'] = \
344344
self._model_context.replace_token_string(self._domain_typedef['baseTemplate'])
345345
else:
346-
ex = exception_helper.create_create_exception('WLSDPLY-12303', self._domain_type,
347-
self._domain_typedef_filename, self._version_typedef_name)
346+
ex = exception_helper.create_cla_exception(ExitCode.ARG_VALIDATION_ERROR, 'WLSDPLY-12303',
347+
self._domain_type, self._domain_typedef_filename,
348+
self._version_typedef_name)
348349
self._logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
349350
raise ex
350351

@@ -386,13 +387,13 @@ def __get_version_typedef(self):
386387
_method_name = '__get_version_typedef'
387388

388389
if 'versions' not in self._domain_typedefs_dict:
389-
ex = exception_helper.create_create_exception('WLSDPLY-12304', self._domain_type,
390-
self._domain_typedef_filename)
390+
ex = exception_helper.create_cla_exception(ExitCode.ARG_VALIDATION_ERROR, 'WLSDPLY-12304',
391+
self._domain_type, self._domain_typedef_filename)
391392
self._logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
392393
raise ex
393394
elif 'definitions' not in self._domain_typedefs_dict:
394-
ex = exception_helper.create_create_exception('WLSDPLY-12305', self._domain_type,
395-
self._domain_typedef_filename)
395+
ex = exception_helper.create_cla_exception(ExitCode.ARG_VALIDATION_ERROR, 'WLSDPLY-12305',
396+
self._domain_type, self._domain_typedef_filename)
396397
self._logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
397398
raise ex
398399

@@ -401,8 +402,9 @@ def __get_version_typedef(self):
401402
if self._version_typedef_name in self._domain_typedefs_dict['definitions']:
402403
result = self._domain_typedefs_dict['definitions'][self._version_typedef_name]
403404
else:
404-
ex = exception_helper.create_create_exception('WLSDPLY-12306', self._domain_type,
405-
self._domain_typedef_filename, self._version_typedef_name)
405+
ex = exception_helper.create_cla_exception(ExitCode.ARG_VALIDATION_ERROR, 'WLSDPLY-12306',
406+
self._domain_type, self._domain_typedef_filename,
407+
self._version_typedef_name)
406408
self._logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
407409
raise ex
408410
return result
@@ -418,8 +420,8 @@ def __match_version_typedef(self, versions_dict):
418420

419421
self._logger.entering(versions_dict, class_name=self.__class_name, method_name=_method_name)
420422
if len(versions_dict) == 0:
421-
ex = exception_helper.create_create_exception('WLSDPLY-12307', self._domain_type,
422-
self._domain_typedef_filename)
423+
ex = exception_helper.create_cla_exception(ExitCode.ARG_VALIDATION_ERROR, 'WLSDPLY-12307',
424+
self._domain_type, self._domain_typedef_filename)
423425
self._logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
424426
raise ex
425427

@@ -441,12 +443,14 @@ def __match_version_typedef(self, versions_dict):
441443
new_version = self.wls_helper.get_next_higher_order_version_number(new_version)
442444

443445
if result is None:
444-
ex = exception_helper.create_create_exception('WLSDPLY-12309', self._domain_type,
445-
self._domain_typedef_filename, wls_version)
446+
ex = exception_helper.create_cla_exception(ExitCode.ARG_VALIDATION_ERROR, 'WLSDPLY-12309',
447+
self._domain_type, self._domain_typedef_filename,
448+
wls_version)
446449
self._logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
447450
raise ex
448451
if result == NOT_SUPPORTED:
449-
ex = exception_helper.create_create_exception('WLSDPLY-12313', self._domain_type, wls_version)
452+
ex = exception_helper.create_cla_exception(ExitCode.ARG_VALIDATION_ERROR, 'WLSDPLY-12313',
453+
self._domain_type, wls_version)
450454
self._logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
451455
raise ex
452456
self._logger.exiting(self.__class_name, _method_name, result)
@@ -494,7 +498,7 @@ def _resolve_topology_profile(self):
494498

495499
if 'topologyProfile' not in self._domain_typedefs_dict:
496500
return None
497-
topology_profile = self._domain_typedefs_dict['topologyProfile'];
501+
topology_profile = self._domain_typedefs_dict['topologyProfile']
498502

499503
# there are no valid topology profiles for versions 12.1.x and below
500504
if not self.wls_helper.is_topology_profile_supported():
@@ -504,7 +508,7 @@ def _resolve_topology_profile(self):
504508
self._logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
505509
raise ex
506510

507-
# if specified, toppology profile must be one of the known types
511+
# if specified, topology profile must be one of the known types
508512
if topology_profile not in TopologyProfile:
509513
ex = exception_helper.create_cla_exception(ExitCode.ARG_VALIDATION_ERROR,
510514
'WLSDPLY-12315', topology_profile, self._domain_typedef_filename)
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
"""
2+
Copyright (c) 2023, Oracle 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+
from wlsdeploy.aliases.model_constants import CREDENTIAL
6+
from wlsdeploy.aliases.model_constants import DOMAIN_INFO
7+
from wlsdeploy.aliases.model_constants import OPSS_INITIALIZATION
8+
from wlsdeploy.aliases.model_constants import TARGET_KEY
9+
from wlsdeploy.logging.platform_logger import PlatformLogger
10+
from wlsdeploy.util import dictionary_utils
11+
12+
_class_name = 'opss_helper'
13+
14+
15+
class OPSSHelper(object):
16+
"""
17+
Helper for OPSS credentials in the model dictionary.
18+
"""
19+
_class_name = 'OPSSHelper'
20+
21+
def __init__(self, model_dictionary, model_context, aliases, wlst_helper):
22+
"""
23+
:param model_dictionary: the model dictionary to be used
24+
:param model_context: used to check CLI arguments
25+
:param aliases: used for folder lookup
26+
:param wlst_helper: used for WLST commands
27+
"""
28+
self._model_dictionary = model_dictionary
29+
self._model_context = model_context
30+
self._aliases = aliases
31+
self._wlst_helper = wlst_helper
32+
self._logger = PlatformLogger('wlsdeploy.create')
33+
34+
def create_credentials(self):
35+
_method_name = 'create_credentials'
36+
37+
domain_info = dictionary_utils.get_dictionary_element(self._model_dictionary, DOMAIN_INFO)
38+
opss_initialization = dictionary_utils.get_dictionary_element(domain_info, OPSS_INITIALIZATION)
39+
credentials = dictionary_utils.get_dictionary_element(opss_initialization, CREDENTIAL)
40+
for store_key, store_folder in credentials.iteritems():
41+
self._logger.info('WLSDPLY-12350', store_key, class_name=self._class_name, method_name=_method_name)
42+
keys = dictionary_utils.get_dictionary_element(store_folder, TARGET_KEY)
43+
for key, key_folder in keys.iteritems():
44+
wlst_path = '/Credential/TargetStore/' + store_key + '/TargetKey/' + key
45+
self._wlst_helper.cd(wlst_path)
46+
self._wlst_helper.create('c', 'Credential')
47+
self._wlst_helper.cd('Credential')
48+
for field, field_value in key_folder.iteritems():
49+
self._wlst_helper.set(field, field_value)
50+
51+
52+
def create_credentials(model_dictionary, model_context, aliases, wlst_helper):
53+
"""
54+
Static method for initializing OPSSHelper and creating credentials.
55+
:param model_dictionary: the model dictionary to be used
56+
:param model_context: used to check CLI arguments
57+
:param aliases: used for folder lookup
58+
:param wlst_helper: used for WLST commands
59+
"""
60+
opss_helper = OPSSHelper(model_dictionary, model_context, aliases, wlst_helper)
61+
opss_helper.create_credentials()
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"copyright": "Copyright (c) 2023, Oracle and/or its affiliates.",
3+
"license": "Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl",
4+
"wlst_type": "OPSSInitialization",
5+
"short_name": "OPSS",
6+
"folders": {
7+
"Credential": {
8+
"wlst_type": "Credential",
9+
"child_folders_type": "multiple",
10+
"folders": {
11+
"TargetKey": {
12+
"wlst_type": "TargetKey",
13+
"child_folders_type": "multiple",
14+
"short_name": "Key",
15+
"folders": {},
16+
"attributes": {
17+
"Username": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "Username", "wlst_path": "WP001", "default_value": null, "wlst_type": "credential" } ],
18+
"Password": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "Password", "wlst_path": "WP001", "default_value": null, "wlst_type": "password" } ]
19+
},
20+
"wlst_attributes_path": "WP001",
21+
"wlst_paths": {
22+
"WP001": "/NO_FOLDER/%OPSSINITIALIZATION%/NO_FOLDER/%CREDENTIAL%/NO_FOLDER/%TARGETKEY%"
23+
}
24+
}
25+
},
26+
"attributes": {},
27+
"wlst_attributes_path": "WP001",
28+
"wlst_paths": {
29+
"WP001": "/NO_FOLDER/%OPSSINITIALIZATION%/NO_FOLDER/%CREDENTIAL%"
30+
}
31+
}
32+
},
33+
"attributes": {},
34+
"wlst_attributes_path": "WP001",
35+
"wlst_paths": {
36+
"WP001": "/NO_FOLDER"
37+
}
38+
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1475,6 +1475,9 @@ WLSDPLY-12313=Domain type {0} is not supported for WebLogic version {1}
14751475
WLSDDPL-12314=Topology profile "{0}" is typedef file {1} is not allowed for WebLogic version {2}
14761476
WLSDPLY-12315=Topology profile "{0}" in type definition file {1} is not a known topology profile value
14771477

1478+
# opss_helper.py
1479+
WLSDPLY-12350=Initializing OPSS credentials for target store "{0}"
1480+
14781481
# create.py
14791482
WLSDPLY-12400={0} got the JAVA_HOME {1} from the environment variable but it was not a valid location: {2}
14801483
# number gap to fill

0 commit comments

Comments
 (0)