Skip to content

Commit 7778da8

Browse files
committed
Merge branch 'enable-cert-mgmt' into 'main'
Enable certificate management before writing domain with servers See merge request weblogic-cloud/weblogic-deploy-tooling!1823
2 parents 2649d87 + 9dc3c9b commit 7778da8

File tree

4 files changed

+48
-2
lines changed

4 files changed

+48
-2
lines changed

core/src/main/python/update.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@ def __update_online(model_deployer, model, model_context, aliases):
184184

185185
topology_updater = TopologyUpdater(model, model_context, aliases, wlst_mode=WlstModes.ONLINE)
186186
try:
187+
topology_updater.update_certificate_management_enabled()
188+
187189
jdbc_names = topology_updater.update_machines_clusters_and_servers(delete_now=False)
188190
topology_updater.warn_set_server_groups()
189191

@@ -248,6 +250,9 @@ def __update_offline(model_deployer, model, model_context, aliases):
248250
# this needs to be before first updateDomain for NativeVersionEnabled=true to update correctly
249251
topology_updater.update_nm_properties()
250252

253+
# this needs to be done before updateDomain in case server has KeyStores: DomainKeystores
254+
topology_updater.update_certificate_management_enabled()
255+
251256
__update_offline_domain()
252257

253258
topology_updater.set_server_groups()

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,8 @@ def __set_core_domain_params(self):
556556
self.wlst_helper.set_option_if_needed(USE_SAMPLE_DATABASE, use_sample_db)
557557

558558
self.__set_secure_and_production_modes()
559+
deployer_utils.set_certificate_management_enabled(self._topology, self._domain_name,
560+
self.wlst_helper, self.aliases)
559561

560562
self.__set_domain_name()
561563
self.__set_admin_password()
@@ -870,6 +872,7 @@ def __set_domain_name(self):
870872
# Stash the default name since the SecurityConfiguration subfolder name does not change
871873
# to the new domain name until after the domain has been written to disk and re-read.
872874
#
875+
self.wlst_helper.cd('/')
873876
self.__default_domain_name = self.wlst_helper.get(NAME)
874877
if self.__default_domain_name is None or len(self.__default_domain_name) == 0:
875878
self.__default_domain_name = DEFAULT_WLS_DOMAIN_NAME

core/src/main/python/wlsdeploy/tool/deploy/deployer_utils.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2017, 2024, Oracle and/or its affiliates.
2+
Copyright (c) 2017, 2025, Oracle 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
import os
@@ -26,9 +26,11 @@
2626
from wlsdeploy.aliases.location_context import LocationContext
2727
from wlsdeploy.aliases.model_constants import APPLICATION
2828
from wlsdeploy.aliases.model_constants import APP_DEPLOYMENTS
29+
from wlsdeploy.aliases.model_constants import CERTIFICATE_MANAGEMENT
2930
from wlsdeploy.aliases.model_constants import CLUSTER
3031
from wlsdeploy.aliases.model_constants import DYNAMIC_CLUSTER_SIZE
3132
from wlsdeploy.aliases.model_constants import DYNAMIC_SERVERS
33+
from wlsdeploy.aliases.model_constants import ENABLED
3234
from wlsdeploy.aliases.model_constants import FILE_URI
3335
from wlsdeploy.aliases.model_constants import JDBC_RESOURCE
3436
from wlsdeploy.aliases.model_constants import JDBC_DATASOURCE_PARAMS
@@ -41,6 +43,7 @@
4143
from wlsdeploy.aliases.model_constants import LIBRARY
4244
from wlsdeploy.aliases.model_constants import MACHINE
4345
from wlsdeploy.aliases.model_constants import MAX_DYNAMIC_SERVER_COUNT
46+
from wlsdeploy.aliases.model_constants import SECURITY_CONFIGURATION
4447
from wlsdeploy.aliases.model_constants import SERVER
4548
from wlsdeploy.aliases.model_constants import SERVER_NAME_PREFIX
4649
from wlsdeploy.aliases.model_constants import SERVER_NAME_START_IDX
@@ -720,6 +723,33 @@ def check_if_dynamic_cluster(server_name, cluster_name, aliases):
720723
return True
721724
return False
722725

726+
def set_certificate_management_enabled(topology, domain_name, wlst_helper, aliases):
727+
"""
728+
Certificate management must be enabled when Server / KeyStores is set to "DomainKeystores"
729+
in order to pass validation at writeDomain or updateDomain.
730+
"""
731+
security_config_folder = dictionary_utils.get_dictionary_element(topology, SECURITY_CONFIGURATION)
732+
cert_mgmt_folder = dictionary_utils.get_dictionary_element(security_config_folder, CERTIFICATE_MANAGEMENT)
733+
cert_mgmt_enabled = dictionary_utils.get_element(cert_mgmt_folder, ENABLED)
734+
if cert_mgmt_enabled is not None:
735+
location = LocationContext()
736+
domain_name_token = aliases.get_name_token(location)
737+
location.add_name_token(domain_name_token, domain_name)
738+
location.append_location(SECURITY_CONFIGURATION)
739+
740+
# certificate management doesn't exist in older WLS versions
741+
code, message = aliases.is_valid_model_folder_name(location, CERTIFICATE_MANAGEMENT)
742+
if code == ValidationCodes.VALID:
743+
existing_subfolder_names = get_existing_object_list(location, aliases)
744+
create_and_cd(location, existing_subfolder_names, aliases)
745+
746+
location.append_location(CERTIFICATE_MANAGEMENT)
747+
existing_subfolder_names = get_existing_object_list(location, aliases)
748+
create_and_cd(location, existing_subfolder_names, aliases)
749+
750+
cert_mgmt_enabled = alias_utils.convert_boolean(cert_mgmt_enabled)
751+
wlst_name = aliases.get_wlst_attribute_name(location, ENABLED)
752+
wlst_helper.set(wlst_name, cert_mgmt_enabled)
723753

724754
def delete_online_deployment_targets(model, aliases, wlst_mode):
725755
"""

core/src/main/python/wlsdeploy/tool/deploy/topology_updater.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2017, 2024, Oracle and/or its affiliates.
2+
Copyright (c) 2017, 2025, Oracle 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
from wlsdeploy.aliases.location_context import LocationContext
@@ -201,6 +201,14 @@ def update_nm_properties(self):
201201
location.add_name_token(domain_token, self.model_context.get_domain_name())
202202
self._process_section(self._topology, [], NM_PROPERTIES, location)
203203

204+
def update_certificate_management_enabled(self):
205+
"""
206+
Certificate management has to be enabled when Server / KeyStores is set to "DomainKeystores"
207+
in order to pass validation at writeDomain or updateDomain.
208+
"""
209+
domain_name = self.model_context.get_domain_name()
210+
deployer_utils.set_certificate_management_enabled(self._topology, domain_name, self.wlst_helper, self.aliases)
211+
204212
def warn_set_server_groups(self):
205213
# For issue in setServerGroups in online mode (new configured clusters and stand-alone managed servers
206214
# will not have extension template resources targeted)

0 commit comments

Comments
 (0)