Skip to content

Commit 1fb988b

Browse files
CarolynRountreerakillen
authored andcommitted
Wdt 228 target dynamic servers to cluster (#358)
* Apply JRF resources to dynamic cluster * Add troubleshooting message for applyJRF * intermediate checkins * assign JRF resources using applyJRF * One working approach * Add rearrangement of execution of targeting * Checkin cleanups * fixes for exception issue message * Fixes for 10.3.6 testing * cleanup * Revert "cleanup" This reverts commit 0f0b6ca. * WDT-228 Remove archive file from repository * clarify warning message 12244 * changed warning message 9701
1 parent b4a48fe commit 1fb988b

File tree

16 files changed

+1029
-152
lines changed

16 files changed

+1029
-152
lines changed

core/src/main/java/oracle/weblogic/deploy/util/StringUtils.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,4 +147,20 @@ public static String[] splitCommaSeparatedList(String listString) {
147147
return listString.split(COMMA_SEPARATED_LIST_SPLITTER);
148148
}
149149

150+
/**
151+
* Return a printable string representing the Boolean True or False value for the integer.
152+
* @param value containing the integer value of a boolean
153+
* @return String representation of the boolean integer
154+
*/
155+
public static String stringForBoolean(int value) {
156+
switch(value) {
157+
case 0:
158+
return Boolean.FALSE.toString();
159+
case 1:
160+
return Boolean.TRUE.toString();
161+
default:
162+
return "UNKNOWN";
163+
}
164+
}
165+
150166
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010
from wlsdeploy.exception import exception_helper
1111
from wlsdeploy.exception.expection_types import ExceptionType
1212
from wlsdeploy.logging.platform_logger import PlatformLogger
13-
from wlsdeploy.tool.deploy import deployer_utils
13+
from wlsdeploy.util import dictionary_utils
1414
from wlsdeploy.tool.util.alias_helper import AliasHelper
1515
from wlsdeploy.tool.util.attribute_setter import AttributeSetter
1616
from wlsdeploy.tool.util.custom_folder_helper import CustomFolderHelper
1717
from wlsdeploy.tool.util.wlst_helper import WlstHelper
18-
from wlsdeploy.util import dictionary_utils
1918
from wlsdeploy.util.model import Model
2019
from wlsdeploy.util.weblogic_helper import WebLogicHelper
21-
20+
from wlsdeploy.tool.deploy import deployer_utils
21+
2222

2323
class Creator(object):
2424
"""

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"""
55
import javaos as os
66
from oracle.weblogic.deploy.create import RCURunner
7-
87
from wlsdeploy.aliases.location_context import LocationContext
98
from wlsdeploy.aliases.model_constants import ADMIN_PASSWORD
109
from wlsdeploy.aliases.model_constants import ADMIN_SERVER_NAME
@@ -415,8 +414,6 @@ def __extend_domain(self, domain_home):
415414
self.target_helper.target_server_groups_to_servers(server_groups_to_target)
416415
self.wlst_helper.update_domain()
417416
elif self._domain_typedef.is_jrf_domain_type():
418-
# Update the domain to apply the extension templates.
419-
self.wlst_helper.update_domain()
420417
self.target_helper.target_jrf_groups_to_clusters_servers(domain_home)
421418

422419
self.wlst_helper.close_domain()
@@ -457,13 +454,20 @@ def __create_domain_with_select_template(self, domain_home):
457454
self.__set_app_dir()
458455
self.__configure_fmw_infra_database()
459456

460-
server_groups_to_target = self._domain_typedef.get_server_groups_to_target()
461-
self.target_helper.target_server_groups_to_servers(server_groups_to_target)
462-
463457
self.logger.info('WLSDPLY-12206', self._domain_name, domain_home,
464458
class_name=self.__class_name, method_name=_method_name)
459+
460+
server_groups_to_target = self._domain_typedef.get_server_groups_to_target()
461+
server_assigns, dynamic_assigns = self.target_helper.target_server_groups_to_servers(server_groups_to_target)
462+
if server_assigns is not None:
463+
self.target_helper.target_server_groups(server_assigns)
464+
465465
self.wlst_helper.write_domain(domain_home)
466466
self.wlst_helper.close_template()
467+
468+
if dynamic_assigns is not None:
469+
self.target_helper.target_server_groups_to_dynamic_clusters(dynamic_assigns)
470+
467471
self.logger.exiting(class_name=self.__class_name, method_name=_method_name)
468472
return
469473

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

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class DomainTypedef(object):
2929
__domain_typedef_extension = '.json'
3030

3131
JRF_TEMPLATE_REGEX = "^(.*jrf_template[0-9._]*\\.jar)|(Oracle JRF WebServices Asynchronous services)$"
32+
RESTRICTED_JRF_TEMPLATE_REGEX = "^(Oracle Restricted JRF)$"
3233

3334
def __init__(self, program_name, domain_type):
3435
"""
@@ -94,6 +95,13 @@ def get_domain_type(self):
9495
"""
9596
return self._domain_type
9697

98+
def has_jrf_resources(self):
99+
"""
100+
Determine if the domain type has domain resources from either the JRF or Restricted JRF templates.
101+
:return: True if the domain type has resources from one of the JRF type
102+
"""
103+
return self.is_jrf_domain_type() or self.is_restricted_jrf_domain_type()
104+
97105
def is_jrf_domain_type(self):
98106
"""
99107
Determine if this is a JRF domain type by checking for the JRF extension template.
@@ -105,12 +113,15 @@ def is_jrf_domain_type(self):
105113
return True
106114
return False
107115

108-
def domain_type_has_jrf_resources(self):
116+
def is_restricted_jrf_domain_type(self):
109117
"""
110-
Does the running domain type contain the JRF server group ?
111-
:return:
118+
Determine if this domain type applies the Restricted JRF template.
119+
:return: True if the Restricted JRF template is in the extension templates list
112120
"""
113-
return 'JRF-MAN-SVR' in self.get_server_groups_to_target()
121+
for template in self.get_extension_templates():
122+
if re.match(self.RESTRICTED_JRF_TEMPLATE_REGEX, template):
123+
return True
124+
return False
114125

115126
def get_base_template(self):
116127
"""
@@ -121,6 +132,14 @@ def get_base_template(self):
121132
self.__resolve_paths()
122133
return self._domain_typedef['baseTemplate']
123134

135+
def has_extension_templates(self):
136+
"""
137+
Determine if the domain type has extension templates.
138+
:return: True if the domain type will apply extension templates
139+
"""
140+
ets = self.get_extension_templates()
141+
return ets is not None and len(ets) > 0
142+
124143
def get_extension_templates(self):
125144
"""
126145
Get the list of extension templates to apply when create/extending the domain.

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

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -279,44 +279,3 @@ def get_file_hash(file_name):
279279
raise ex
280280
_logger.exiting(class_name=_class_name, method_name=_method_name, result=result)
281281
return result
282-
283-
284-
def save_changes(model_context):
285-
"""
286-
Call this if necessary to save changes and disconnect from the domain.
287-
This works in both offline and online.
288-
:param model_context: contains information about the current tool settings
289-
"""
290-
_method_name = 'save_changes'
291-
if model_context.get_target_wlst_mode() == WlstModes.ONLINE:
292-
if _wlst_helper.is_connected():
293-
_logger.fine('WLSDPLY-09110', class_name=_class_name, method_name=_method_name)
294-
_wlst_helper.save()
295-
_wlst_helper.activate()
296-
_wlst_helper.disconnect()
297-
else:
298-
_logger.fine('WLSDPLY-09109', class_name=_class_name, method_name=_method_name)
299-
else:
300-
_logger.fine('WLSDPLY-09111', class_name=_class_name, method_name=_method_name)
301-
_wlst_helper.update_domain()
302-
303-
304-
def read_again(model_context):
305-
"""
306-
Establish connection with the domain and start editing in both online and offline wlst mode.
307-
:param model_context: contains information about the current tool settings
308-
"""
309-
_method_name = 'read_again'
310-
if model_context.get_target_wlst_mode() == WlstModes.ONLINE:
311-
if not _wlst_helper.is_connected():
312-
_logger.fine('WLSDPLY-09113', class_name=_class_name, method_name=_method_name)
313-
_wlst_helper.connect(model_context.get_admin_user(), model_context.get_admin_password(),
314-
model_context.get_admin_url())
315-
_wlst_helper.edit()
316-
_wlst_helper.start_edit()
317-
else:
318-
_logger.fine('WLSDPLY-09112', class_name=_class_name, method_name=_method_name)
319-
else:
320-
_logger.fine('WLSDPLY-09114', class_name=_class_name, method_name=_method_name)
321-
_wlst_helper.close_domain()
322-
_wlst_helper.read_domain(model_context.get_domain_home())

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

Lines changed: 90 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from wlsdeploy.aliases.model_constants import SERVER_TEMPLATE
1515
from wlsdeploy.aliases.model_constants import UNIX_MACHINE
1616
from wlsdeploy.aliases.wlst_modes import WlstModes
17+
from wlsdeploy.exception import exception_helper
1718
from wlsdeploy.exception.expection_types import ExceptionType
1819
from wlsdeploy.tool.create.security_provider_creator import SecurityProviderCreator
1920
from wlsdeploy.tool.deploy import deployer_utils
@@ -34,16 +35,17 @@ def __init__(self, model, model_context, aliases, wlst_mode=WlstModes.OFFLINE):
3435
Deployer.__init__(self, model, model_context, aliases, wlst_mode)
3536
self._topology = self.model.get_model_topology()
3637
self._resources = self.model.get_model_resources()
37-
self._topology_helper = TopologyHelper(self.aliases, ExceptionType.DEPLOY, self.logger)
38+
self._exception_type = ExceptionType.DEPLOY
39+
self._topology_helper = TopologyHelper(self.aliases, self._exception_type, self.logger)
3840
self._domain_typedef = self.model_context.get_domain_typedef()
3941

4042
self._security_provider_creator = SecurityProviderCreator(model.get_model(), model_context, aliases,
41-
ExceptionType.DEPLOY, self.logger)
43+
self._exception_type, self.logger)
4244

4345
self.library_helper = LibraryHelper(self.model, self.model_context, self.aliases,
44-
model_context.get_domain_home(), ExceptionType.DEPLOY, self.logger)
46+
model_context.get_domain_home(), self._exception_type, self.logger)
4547

46-
self.target_helper = TargetHelper(self.model, self.model_context, self.aliases, ExceptionType.DEPLOY,
48+
self.target_helper = TargetHelper(self.model, self.model_context, self.aliases, self._exception_type,
4749
self.logger)
4850

4951
# Override
@@ -72,7 +74,11 @@ def update(self):
7274
"""
7375
Deploy resource model elements at the domain level, including multi-tenant elements.
7476
"""
77+
# For issue in setServerGroups in online mode (new configured clusters and stand-alone managed servers
78+
# will not have extension template resources targeted)
79+
existing_managed_servers, existing_configured_clusters = self._create_list_of_setservergroups_targets()
7580
domain_token = deployer_utils.get_domain_token(self.alias_helper)
81+
7682
location = LocationContext()
7783
location.add_name_token(domain_token, self.model_context.get_domain_name())
7884

@@ -104,24 +110,33 @@ def update(self):
104110
# create placeholders for Servers that are in a cluster as /Server/JTAMigratableTarget
105111
# can reference "other" servers
106112
self._topology_helper.create_placeholder_servers_in_cluster(self._topology)
113+
107114
self._process_section(self._topology, folder_list, SERVER, location)
108115

109116
self._process_section(self._topology, folder_list, MIGRATABLE_TARGET, location)
110117

118+
new_managed_server_list, new_configured_cluster_list = self._create_list_of_setservergroups_targets()
119+
120+
self._check_for_online_setservergroups_issue(existing_managed_servers, new_managed_server_list)
121+
self._check_for_online_setservergroups_issue(existing_configured_clusters, new_configured_cluster_list)
122+
111123
# process remaining top-level folders. copy list to avoid concurrent update in loop
112124
remaining = list(folder_list)
113125
for folder_name in remaining:
114126
self._process_section(self._topology, folder_list, folder_name, location)
115127

116128
if self.wls_helper.is_set_server_groups_supported():
117129
server_groups_to_target = self._domain_typedef.get_server_groups_to_target()
118-
self.target_helper.target_server_groups_to_servers(server_groups_to_target)
119-
elif self._domain_typedef.domain_type_has_jrf_resources():
120-
deployer_utils.save_changes(self.model_context)
121-
self.target_helper.target_jrf_groups_to_clusters_servers(self.model_context.get_domain_home())
122-
deployer_utils.read_again(self.model_context)
123-
124-
# files referenced in attributes are extracted as attributes are processed
130+
server_assigns, dynamic_assigns = \
131+
self.target_helper.target_server_groups_to_servers(server_groups_to_target)
132+
if dynamic_assigns is not None:
133+
self.wlst_helper.save_and_close(self.model_context)
134+
self.target_helper.target_server_groups_to_dynamic_clusters(dynamic_assigns)
135+
self.wlst_helper.reopen(self.model_context)
136+
if server_assigns is not None:
137+
self.target_helper.target_server_groups(server_assigns)
138+
elif self._domain_typedef.is_jrf_domain_type():
139+
self.target_helper.target_jrf_groups_to_clusters_servers()
125140

126141
self.library_helper.install_domain_libraries()
127142
self.library_helper.extract_classpath_libraries()
@@ -153,3 +168,67 @@ def _set_domain_attributes(self):
153168
attribute_path = self.alias_helper.get_wlst_attributes_path(location)
154169
self.wlst_helper.cd(attribute_path)
155170
self.set_attributes(location, attrib_dict)
171+
172+
def is_online_with_ext_templates(self):
173+
return self.model_context.is_wlst_online() and self.model_context.get_domain_typedef().has_extension_templates()
174+
175+
def _check_for_online_setservergroups_issue(self, existing_list, new_list):
176+
_method_name = '_check_for_online_setservergroups_issue'
177+
if len(existing_list) != len(new_list):
178+
for entity_name in new_list:
179+
if entity_name not in existing_list:
180+
self.logger.warning('WLSDPLY-09701', entity_name,
181+
class_name=self._class_name, method_name=_method_name)
182+
return
183+
184+
def _create_list_of_setservergroups_targets(self):
185+
"""
186+
If an update is executed in online WLST mode, return a list of all existing configured / mixed clusters and
187+
stand-alone managed servers. This method will be invoked to create a list of existing, and a list of new
188+
as added by the update tool. These lists will be compared to determine if they will encounter
189+
the online WLST problem with setServerGroups. The setServerGroups will target template resources to the
190+
new entities, but this targeting is not persisted to the config.xml.
191+
"""
192+
_method_name = '_create_list_of_setservergroups_targets'
193+
self.logger.entering(class_name=self._class_name, method_name=_method_name)
194+
195+
if not self.is_online_with_ext_templates():
196+
self.logger.exiting(class_name=self._class_name, method_name=_method_name)
197+
return list(), list()
198+
199+
location = LocationContext().append_location(SERVER)
200+
server_path = self.alias_helper.get_wlst_list_path(location)
201+
existing_managed_servers = list()
202+
existing_servers = self.wlst_helper.get_existing_object_list(server_path)
203+
if existing_servers is not None:
204+
name_token = self.alias_helper.get_name_token(location)
205+
for server_name in existing_servers:
206+
location.add_name_token(name_token, server_name)
207+
wlst_path = self.alias_helper.get_wlst_attributes_path(location)
208+
self.wlst_helper.cd(wlst_path)
209+
cluster_attribute = self.alias_helper.get_wlst_attribute_name(location, CLUSTER)
210+
cluster_value = self.wlst_helper.get(cluster_attribute)
211+
if cluster_value is None:
212+
existing_managed_servers.append(server_name)
213+
location.remove_name_token(name_token)
214+
215+
existing_configured_clusters = list()
216+
location = LocationContext().append_location(CLUSTER)
217+
cluster_path = self.alias_helper.get_wlst_list_path(location)
218+
existing_clusters = self.wlst_helper.get_existing_object_list(cluster_path)
219+
if existing_clusters is not None:
220+
name_token = self.alias_helper.get_name_token(location)
221+
for cluster_name in existing_clusters:
222+
location.add_name_token(name_token, cluster_name)
223+
wlst_path = self.alias_helper.get_wlst_attributes_path(location)
224+
self.wlst_helper.cd(wlst_path)
225+
ds_mbean = self.alias_helper.get_wlst_mbean_type(location)
226+
if not self.wlst_helper.subfolder_exists(ds_mbean,
227+
self.alias_helper.get_wlst_subfolders_path(location)):
228+
existing_configured_clusters.append(cluster_name)
229+
location.remove_name_token(name_token)
230+
231+
self.logger.exiting(class_name=self._class_name, method_name=_method_name,
232+
result='configured_clusters=' + str(existing_configured_clusters) +
233+
' managed servers=' + str(existing_managed_servers))
234+
return existing_configured_clusters, existing_managed_servers

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
33
The Universal Permissive License (UPL), Version 1.0
44
"""
5+
from com.sun.identity.agents.weblogic.v10 import AgentAuthenticatorMBeanImplBeanInfo
6+
from com.sun.identity.agents.weblogic.v10 import AgentAuthenticatorMBeanImpl
7+
from com.sun.identity.agents.weblogic.v10 import AgentAuthenticatorMBean
8+
from com.sun.identity.agents.weblogic.v10 import AgentAuthenticatorImpl
59
from java.io import File
610
from java.lang import IllegalArgumentException
711

@@ -46,6 +50,7 @@ def __init__(self, model_context, topology_dictionary, base_location, wlst_mode=
4650
self._add_att_handler(model_constants.CLASSPATH, self._add_classpath_libraries_to_archive)
4751
self._add_att_handler(model_constants.CUSTOM_IDENTITY_KEYSTORE_FILE, self._add_keystore_file_to_archive)
4852
self._add_att_handler(model_constants.CUSTOM_TRUST_KEYSTORE_FILE, self._add_keystore_file_to_archive)
53+
self.agent_authenticator = AgentAuthenticatorImpl()
4954

5055
def discover(self):
5156
"""

0 commit comments

Comments
 (0)