Skip to content

Commit bd47802

Browse files
committed
Merge branch 'jira-wdt-907-opss-wallet' into 'main'
Include OPSS wallet passphrase and tokenize in discovered model when using targets See merge request weblogic-cloud/weblogic-deploy-tooling!1715
2 parents 633954d + 6c851d9 commit bd47802

File tree

5 files changed

+18
-29
lines changed

5 files changed

+18
-29
lines changed

core/src/main/python/discover.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,8 @@ def __validate_discover_passwords_and_security_data_args(model_context, argument
328328
passwords_argument = None
329329
if model_context.is_discover_passwords():
330330
passwords_argument = CommandLineArgUtil.DISCOVER_PASSWORDS_SWITCH
331+
elif model_context.is_discover_opss_wallet():
332+
passwords_argument = CommandLineArgUtil.DISCOVER_OPSS_WALLET_SWITCH
331333
elif model_context.is_discover_security_provider_passwords():
332334
passwords_argument = CommandLineArgUtil.DISCOVER_SECURITY_PROVIDER_DATA_SWITCH + " " \
333335
+ model_context.get_discover_security_provider_data_types_label()
@@ -350,15 +352,9 @@ def __validate_discover_passwords_and_security_data_args(model_context, argument
350352
__logger.throwing(ex, class_name=_class_name, method_name=_method_name)
351353
raise ex
352354

353-
if model_context.is_discover_passwords() or model_context.is_discover_security_provider_data() or \
354-
model_context.is_discover_opss_wallet():
355+
if passwords_argument:
355356
if not model_context.is_encrypt_discovered_passwords() and model_context.get_encryption_passphrase() is not None:
356357
# don't allow turning off encryption and supplying an encryption passphrase
357-
if model_context.is_discover_passwords():
358-
arg = CommandLineArgUtil.DISCOVER_PASSWORDS_SWITCH
359-
else:
360-
arg = CommandLineArgUtil.DISCOVER_SECURITY_PROVIDER_DATA_SWITCH
361-
362358
if CommandLineArgUtil.PASSPHRASE_ENV_SWITCH in argument_map:
363359
bad_arg = CommandLineArgUtil.PASSPHRASE_ENV_SWITCH
364360
elif CommandLineArgUtil.PASSPHRASE_FILE_SWITCH in argument_map:
@@ -369,7 +365,7 @@ def __validate_discover_passwords_and_security_data_args(model_context, argument
369365
bad_arg = CommandLineArgUtil.PASSPHRASE_SWITCH
370366

371367
ex = exception_helper.create_cla_exception(ExitCode.ARG_VALIDATION_ERROR, 'WLSDPLY-06052',
372-
_program_name, arg, bad_arg)
368+
_program_name, passwords_argument, bad_arg)
373369
__logger.throwing(ex, class_name=_class_name, method_name=_method_name)
374370
raise ex
375371

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from oracle.weblogic.deploy.util import WLSDeployArchiveIOException
99

1010
from wlsdeploy.aliases.alias_constants import PASSWORD_TOKEN
11+
from wlsdeploy.aliases.model_constants import DOMAIN_INFO
1112
from wlsdeploy.aliases.model_constants import OPSS_WALLET_PASSPHRASE
1213
from wlsdeploy.aliases.wlst_modes import WlstModes
1314
from wlsdeploy.exception import exception_helper
@@ -30,7 +31,7 @@ def __init__(self, model_context, domain_info, base_location, wlst_mode=WlstMode
3031
"""
3132
The constructor
3233
:param model_context:
33-
:param model:
34+
:param domain_info:
3435
:param base_location:
3536
:param wlst_mode:
3637
:param aliases:
@@ -93,6 +94,11 @@ def _export_opss_wallet(self):
9394
self._domain_info_dictionary[OPSS_WALLET_PASSPHRASE] = \
9495
self._get_opss_wallet_passphrase_for_model(opss_wallet_passphrase)
9596

97+
if self._credential_injector is not None:
98+
location = self._aliases.get_model_section_attribute_location(DOMAIN_INFO)
99+
self._credential_injector.check_and_tokenize(self._domain_info_dictionary, OPSS_WALLET_PASSPHRASE,
100+
location)
101+
96102
_logger.exiting(class_name=_class_name, method_name=_method_name)
97103

98104
def _get_opss_wallet_passphrase_for_model(self, password):

core/src/main/python/wlsdeploy/tool/util/filters/wko_filter.py

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,13 @@
1717
from wlsdeploy.aliases.model_constants import CLUSTER
1818
from wlsdeploy.aliases.model_constants import CLUSTER_MESSAGING_MODE
1919
from wlsdeploy.aliases.model_constants import DATABASE_LESS_LEASING_BASIS
20-
from wlsdeploy.aliases.model_constants import DOMAIN_INFO
2120
from wlsdeploy.aliases.model_constants import DYNAMIC_SERVERS
2221
from wlsdeploy.aliases.model_constants import LISTEN_PORT
2322
from wlsdeploy.aliases.model_constants import MACHINE
2423
from wlsdeploy.aliases.model_constants import MIGRATION_BASIS
2524
from wlsdeploy.aliases.model_constants import NM_PROPERTIES
2625
from wlsdeploy.aliases.model_constants import NODE_MANAGER_PW_ENCRYPTED
2726
from wlsdeploy.aliases.model_constants import NODE_MANAGER_USER_NAME
28-
from wlsdeploy.aliases.model_constants import OPSS_SECRETS
29-
from wlsdeploy.aliases.model_constants import OPSS_WALLET_PASSPHRASE
3027
from wlsdeploy.aliases.model_constants import PARTITION
3128
from wlsdeploy.aliases.model_constants import PARTITION_WORK_MANAGER
3229
from wlsdeploy.aliases.model_constants import RESOURCES
@@ -149,25 +146,15 @@ def check_clustered_server_ports(model, _model_context):
149146
server_port_map[server_cluster] = {"firstServer": server_name, "serverPort": server_port_text}
150147

151148

152-
def filter_domain_info(model, _model_context):
149+
def filter_domain_info(_model, _model_context):
153150
"""
154151
Remove elements from the domainInfo section of the model that are not relevant in a Kubernetes environment.
155-
This may include references to OPSS secret elements.
156-
:param model: the model to be updated
157-
:param _model_context: used to get target configuration
152+
Currently, there are no items to be removed.
153+
:param _model: the model to be updated
154+
:param _model_context: unused, passed by filter_helper if called independently
158155
"""
159156
_method_name = 'filter_domain_info'
160157

161-
target_configuration = _model_context.get_target_configuration()
162-
if not target_configuration.uses_opss_secrets():
163-
domain_info = dictionary_utils.get_dictionary_element(model, DOMAIN_INFO)
164-
for delete_key in [OPSS_WALLET_PASSPHRASE, OPSS_SECRETS]:
165-
if delete_key in domain_info:
166-
source_name = target_configuration.get_domain_home_source_name()
167-
_logger.info('WLSDPLY-20208', delete_key, DOMAIN_INFO, source_name,
168-
class_name=_class_name, method_name=_method_name)
169-
del domain_info[delete_key]
170-
171158

172159
def filter_topology(model, _model_context):
173160
"""

core/src/main/resources/oracle/weblogic/deploy/aliases/category_modules/DomainInfo.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"AdminUserName": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "AdminUserName", "wlst_path": "WP001", "default_value": "weblogic", "wlst_type": "credential" } ],
99
"AppDir": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "AppDir", "wlst_path": "WP001", "default_value": null, "wlst_type": "string", "uses_path_tokens": "true" } ],
1010
"OPSSSecrets": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "OPSSSecrets", "wlst_path": "WP001", "default_value": null, "wlst_type": "password", "secret_suffix": "opsssecrets", "secret_key": "walletPassword" } ],
11-
"OPSSWalletPassphrase": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "OPSSWalletPassphrase", "wlst_path": "WP001", "default_value": null, "wlst_type": "password", "secret_suffix": "opsssecrets", "secret_key": "walletPassword" } ],
11+
"OPSSWalletPassphrase": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "OPSSWalletPassphrase", "wlst_path": "WP001", "default_value": null, "wlst_type": "password", "secret_suffix": "opsswallet", "secret_key": "passphrase" } ],
1212
"ServerGroupTargetingLimits": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "ServerGroupTargetingLimits", "wlst_path": "WP001", "default_value": null, "wlst_type": "dict" } ],
1313
"DynamicClusterServerGroupTargetingLimits": [ {"version": "[12.2.1.1,)", "wlst_mode": "both", "wlst_name": "dynamicClusterServerGroupTargetingLimits", "wlst_path": "WP001", "default_value": null, "wlst_type": "dict" } ],
1414
"ServerStartMode": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "ServerStartMode", "wlst_path": "WP001", "default_value": null, "wlst_type": "string" } ],

core/src/test/python/wlsdeploy/util/target_configuration_helper_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ def testGetSecretPath(self):
9494
# domainInfo:/OPSSSecrets has a secret key "walletPassword"
9595
info_location = LocationContext()
9696
info_att_location = LocationContext().append_location(DOMAIN_INFO_ALIAS)
97-
self.assertEqual('opsssecrets:walletPassword', HELPER.get_secret_path(info_location, info_att_location,
98-
OPSS_WALLET_PASSPHRASE, self.aliases))
97+
self.assertEqual('opsswallet:passphrase', HELPER.get_secret_path(info_location, info_att_location,
98+
OPSS_WALLET_PASSPHRASE, self.aliases))
9999

100100
# domainInfo:/RCUDbInfo/javax.net.ssl.keyStorePassword has dots in the name
101101
rcu_location = LocationContext().append_location(RCU_DB_INFO)

0 commit comments

Comments
 (0)