Skip to content

Commit d89c963

Browse files
applyJRF to apply resources to servers
1 parent fc6d3e4 commit d89c963

File tree

7 files changed

+263
-68
lines changed

7 files changed

+263
-68
lines changed

core/src/main/python/create.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
33
The Universal Permissive License (UPL), Version 1.0
44
55
The main module for the WLSDeploy tool to create empty domains.
@@ -38,12 +38,15 @@
3838
from wlsdeploy.util import getcreds
3939
from wlsdeploy.util import tool_exit
4040
from wlsdeploy.util import variables
41+
from wlsdeploy.util import wlst_extended
4142
from wlsdeploy.util import wlst_helper
4243
from wlsdeploy.util.cla_utils import CommandLineArgUtil
4344
from wlsdeploy.util.model_context import ModelContext
4445
from wlsdeploy.util.model_translator import FileToPython
4546
from wlsdeploy.util.weblogic_helper import WebLogicHelper
4647

48+
wlst_extended.wlst_functions = globals()
49+
4750
_program_name = 'createDomain'
4851
_class_name = 'create'
4952
__logger = PlatformLogger('wlsdeploy.create')

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

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ def __extend_domain(self, domain_home):
321321

322322
self.logger.info('WLSDPLY-12207', self._domain_name, domain_home,
323323
class_name=self.__class_name, method_name=_method_name)
324+
# we might want to replace this later to extend a domain in update
324325
self.wlst_helper.read_domain(domain_home)
325326
self.__set_app_dir()
326327

@@ -331,13 +332,21 @@ def __extend_domain(self, domain_home):
331332

332333
self.__configure_fmw_infra_database()
333334

334-
server_groups_to_target = self._domain_typedef.get_server_groups_to_target()
335-
self.target_helper.target_server_groups_to_servers(server_groups_to_target)
335+
if self.wls_helper.is_set_server_groups_supported():
336+
server_groups_to_target = self._domain_typedef.get_server_groups_to_target()
337+
self.target_helper.target_server_groups_to_servers(server_groups_to_target)
338+
else:
339+
# need to update this before can target it
340+
# might want to replace this later with
341+
# self.wlst_helper.update_domain()
342+
# self.wlst_helper.close_domain()
343+
# # we might want to replace this later to extend a domain in update
344+
# self.wlst_helper.read_domain(domain_home)
345+
self.target_helper.target_jrf_groups_to_clusters_servers(domain_home)
346+
336347

337348
self.logger.info('WLSDPLY-12209', self._domain_name,
338349
class_name=self.__class_name, method_name=_method_name)
339-
self.wlst_helper.update_domain()
340-
self.wlst_helper.close_domain()
341350

342351
self.logger.exiting(class_name=self.__class_name, method_name=_method_name)
343352
return
@@ -700,7 +709,7 @@ def __configure_fmw_infra_database(self):
700709

701710
stb_user = self.wls_helper.get_stb_user_name(rcu_prefix)
702711
self.logger.fine('WLSDPLY-12222', stb_user, class_name=self.__class_name, method_name=_method_name)
703-
712+
#
704713
wlst_path = self.alias_helper.get_wlst_attributes_path(location)
705714
self.wlst_helper.cd(wlst_path)
706715
wlst_name, wlst_value = \
@@ -709,7 +718,8 @@ def __configure_fmw_infra_database(self):
709718
JDBC_DRIVER_PARAMS_PROPERTIES, DRIVER_PARAMS_USER_PROPERTY)
710719

711720
self.logger.info('WLSDPLY-12223', class_name=self.__class_name, method_name=_method_name)
712-
self.wlst_helper.get_database_defaults()
721+
if self._domain_typedef.is_get_database_defaults():
722+
self.wlst_helper.get_database_defaults()
713723

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

core/src/main/python/wlsdeploy/tool/util/target_helper.py

Lines changed: 116 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
33
The Universal Permissive License (UPL), Version 1.0
44
"""
55

@@ -38,85 +38,128 @@ def __init__(self, model, model_context, aliases, exception_type, logger):
3838
else:
3939
self._admin_server_name = DEFAULT_ADMIN_SERVER_NAME
4040

41-
def target_server_groups_to_servers(self, server_groups_to_target):
41+
def target_jrf_groups_to_clusters_servers(self, domain_home):
4242
"""
43-
Target the server groups to the servers.
44-
:param server_groups_to_target: the list of server groups to target
45-
:raises: BundleAwareException of the specified type: if an error occurs
43+
Use the apply_jrf only for those versions of wlst that do not have server groups.
44+
This assigns the JRF resources to all managed servers. If the managed server is in a
45+
cluster, this method assigns the JRF resources are assigned to the cluster. Else, if
46+
the managed server is stand-alone, the resources are assigned to the managed server.
47+
:param domain_home: the directory for the domain_home
4648
"""
47-
_method_name = '__target_server_groups_to_servers'
49+
_method_name = 'target_jrf_groups_to_clusters_servers'
4850

49-
self.logger.entering(server_groups_to_target, class_name=self.__class_name, method_name=_method_name)
50-
if len(server_groups_to_target) == 0:
51-
return
51+
self.logger.entering(domain_home, class_name=self.__class_name, method_name=_method_name)
5252

5353
location = LocationContext()
5454
root_path = self.alias_helper.get_wlst_attributes_path(location)
5555
self.wlst_helper.cd(root_path)
56+
admin_server_name = self.wlst_helper.get(ADMIN_SERVER_NAME)
5657

5758
# We need to get the effective list of servers for the domain. Since any servers
5859
# referenced in the model have already been created but the templates may have
5960
# defined new servers not listed in the model, get the list from WLST.
60-
server_names = self._get_existing_server_names()
61+
server_names = self.get_existing_server_names()
62+
if admin_server_name in server_names:
63+
server_names.remove(admin_server_name)
6164

6265
# Get the clusters and and their members
63-
cluster_map = self._get_clusters_and_members_map()
66+
cluster_map = self.get_clusters_and_members_map()
67+
self.wlst_helper.update_domain()
68+
self.wlst_helper.close_domain()
6469

65-
# Get any limits that may have been defined in the model
66-
domain_info = self.model.get_model_domain_info()
67-
server_group_targeting_limits = \
68-
dictionary_utils.get_dictionary_element(domain_info, SERVER_GROUP_TARGETING_LIMITS)
69-
if len(server_group_targeting_limits) > 0:
70-
server_group_targeting_limits = \
71-
self._get_server_group_targeting_limits(server_group_targeting_limits, cluster_map)
72-
73-
# Get the map of server names to server groups to target
74-
server_to_server_groups_map =\
75-
self._get_server_to_server_groups_map(self._admin_server_name,
76-
server_names,
77-
server_groups_to_target,
78-
server_group_targeting_limits) # type: dict
79-
80-
if len(server_names) > 1:
81-
for server, server_groups in server_to_server_groups_map.iteritems():
82-
if len(server_groups) > 0:
83-
server_name = self.wlst_helper.get_quoted_name_for_wlst(server)
84-
self.logger.info('WLSDPLY-12224', str(server_groups), server_name,
85-
class_name=self.__class_name, method_name=_method_name)
86-
self.wlst_helper.set_server_groups(server_name, server_groups)
87-
88-
elif len(server_group_targeting_limits) == 0:
89-
#
90-
# Domain has no managed servers and there were not targeting limits specified to target
91-
# server groups to the admin server so make sure that the server groups are targeted to
92-
# the admin server.
93-
#
94-
# This is really a best effort attempt. It works for JRF domains but it is certainly possible
95-
# that it may cause problems with other custom domain types. Of course, creating a domain with
96-
# no managed servers is not a primary use case of this tool so do it and hope for the best...
97-
#
98-
server_name = self.wlst_helper.get_quoted_name_for_wlst(server_names[0])
99-
self.wlst_helper.set_server_groups(server_name, server_groups_to_target)
70+
# Get the clusters and and their members
71+
for cluster_name, cluster_servers in cluster_map.iteritems():
72+
self.logger.info('WLSDPLY-12232', 'Cluster', cluster_name, class_name=self.__class_name,
73+
method_name=_method_name)
74+
self.wlst_helper.apply_jrf(cluster_name, domain_home, should_update=True)
75+
for member in cluster_servers:
76+
if member in server_names:
77+
server_names.remove(member)
78+
for ms_name in server_names:
79+
self.logger.info('WLSDPLY-12232', 'Managed Server', ms_name, class_name=self.__class_name,
80+
method_name=_method_name)
81+
self.wlst_helper.apply_jrf(ms_name, domain_home, should_update=True)
10082

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

104-
def _get_existing_server_names(self):
86+
def target_server_groups_to_servers(self, domain_home, server_groups_to_target):
10587
"""
106-
Get the list of server names from WLST.
107-
:return: the list of server names
108-
:raises: BundleAwareException of the specified type: is an error occurs reading from the aliases or WLST
88+
Target the server groups to the servers.
89+
:param server_groups_to_target: the list of server groups to target
90+
:raises: BundleAwareException of the specified type: if an error occurs
10991
"""
110-
_method_name = '_get_existing_server_names'
92+
_method_name = '__target_server_groups_to_servers'
11193

112-
self.logger.entering(class_name=self.__class_name, method_name=_method_name)
113-
server_location = LocationContext().append_location(SERVER)
114-
server_list_path = self.alias_helper.get_wlst_list_path(server_location)
115-
result = self.wlst_helper.get_existing_object_list(server_list_path)
116-
self.logger.exiting(class_name=self.__class_name, method_name=_method_name, result=result)
117-
return result
94+
self.logger.entering(server_groups_to_target, class_name=self.__class_name, method_name=_method_name)
95+
if len(server_groups_to_target) > 0:
96+
location = LocationContext()
97+
root_path = self.alias_helper.get_wlst_attributes_path(location)
98+
self.wlst_helper.cd(root_path)
99+
100+
# We need to get the effective list of servers for the domain. Since any servers
101+
# referenced in the model have already been created but the templates may have
102+
# defined new servers not listed in the model, get the list from WLST.
103+
server_names = self.get_existing_server_names()
104+
105+
# Get the clusters and and their members
106+
cluster_map = self.get_clusters_and_members_map()
107+
108+
location = LocationContext()
109+
root_path = self.alias_helper.get_wlst_attributes_path(location)
110+
self.wlst_helper.cd(root_path)
118111

119-
def _get_clusters_and_members_map(self):
112+
# We need to get the effective list of servers for the domain. Since any servers
113+
# referenced in the model have already been created but the templates may have
114+
# defined new servers not listed in the model, get the list from WLST.
115+
server_names = self.get_existing_server_names()
116+
117+
# Get the clusters and and their members
118+
cluster_map = self.get_clusters_and_members_map()
119+
120+
# Get any limits that may have been defined in the model
121+
domain_info = self.model.get_model_domain_info()
122+
server_group_targeting_limits = \
123+
dictionary_utils.get_dictionary_element(domain_info, SERVER_GROUP_TARGETING_LIMITS)
124+
if len(server_group_targeting_limits) > 0:
125+
server_group_targeting_limits = \
126+
self._get_server_group_targeting_limits(server_group_targeting_limits, cluster_map)
127+
128+
# Get the map of server names to server groups to target
129+
server_to_server_groups_map =\
130+
self._get_server_to_server_groups_map(self._admin_server_name,
131+
server_names,
132+
server_groups_to_target,
133+
server_group_targeting_limits) # type: dict
134+
135+
if len(server_names) > 1:
136+
for server, server_groups in server_to_server_groups_map.iteritems():
137+
if len(server_groups) > 0:
138+
server_name = self.wlst_helper.get_quoted_name_for_wlst(server)
139+
self.logger.info('WLSDPLY-12224', str(server_groups), server_name,
140+
class_name=self.__class_name, method_name=_method_name)
141+
self.wlst_helper.set_server_groups(server_name, server_groups)
142+
143+
elif len(server_group_targeting_limits) == 0:
144+
#
145+
# Domain has no managed servers and there were not targeting limits specified to target
146+
# server groups to the admin server so make sure that the server groups are targeted to
147+
# the admin server.
148+
#
149+
# This is really a best effort attempt. It works for JRF domains but it is certainly possible
150+
# that it may cause problems with other custom domain types. Of course, creating a domain with
151+
# no managed servers is not a primary use case of this tool so do it and hope for the best...
152+
#
153+
server_name = self.wlst_helper.get_quoted_name_for_wlst(server_names[0])
154+
self.wlst_helper.set_server_groups(server_name, server_groups_to_target)
155+
156+
# might want to replace this later with
157+
self.wlst_helper.update_domain()
158+
self.wlst_helper.close_domain()
159+
self.logger.exiting(class_name=self.__class_name, method_name=_method_name)
160+
return
161+
162+
def get_clusters_and_members_map(self):
120163
"""
121164
Get a map keyed by cluster name with values that are a list of member server names
122165
:return: the cluster name to member server names map
@@ -148,6 +191,21 @@ def _get_clusters_and_members_map(self):
148191
self.logger.exiting(class_name=self.__class_name, method_name=_method_name, result=cluster_map)
149192
return cluster_map
150193

194+
def get_existing_server_names(self):
195+
"""
196+
Get the list of server names from WLST.
197+
:return: the list of server names
198+
:raises: BundleAwareException of the specified type: is an error occurs reading from the aliases or WLST
199+
"""
200+
_method_name = '_get_existing_server_names'
201+
202+
self.logger.entering(class_name=self.__class_name, method_name=_method_name)
203+
server_location = LocationContext().append_location(SERVER)
204+
server_list_path = self.alias_helper.get_wlst_list_path(server_location)
205+
result = self.wlst_helper.get_existing_object_list(server_list_path)
206+
self.logger.exiting(class_name=self.__class_name, method_name=_method_name, result=result)
207+
return result
208+
151209
def _get_server_group_targeting_limits(self, server_group_targeting_limits, clusters_map):
152210
"""
153211
Get any server group targeting limits specified in the model, converting any cluster

core/src/main/python/wlsdeploy/tool/util/wlst_helper.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
"""
2-
Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
33
The Universal Permissive License (UPL), Version 1.0
44
"""
55
from oracle.weblogic.deploy.util import PyWLSTException
66

77
from wlsdeploy.exception import exception_helper
8+
from wlsdeploy.util import wlst_extended
89
from wlsdeploy.util import wlst_helper
910

1011

@@ -41,6 +42,25 @@ def assign(self, source_type, source_name, target_type, target_name):
4142
self.__logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
4243
raise ex
4344

45+
def apply_jrf(self, jrf_target, domain_home, should_update=False):
46+
"""
47+
For those installs that require populating the JRF server group information to the managed servers
48+
:param jrf_target: The entity to which to target the JRF applications and services
49+
:param domain_home: The domain home directory
50+
:param should_update: If True the applyJRF will update the domain after apply
51+
:raises: Exception specific to tool type
52+
"""
53+
_method_name = 'apply_jrf'
54+
55+
try:
56+
wlst_extended.apply_jrf(jrf_target, domain_home, should_update)
57+
except PyWLSTException, pwe:
58+
ex = exception_helper.create_exception(self.__exception_type, 'WLSDPLY-00071',
59+
jrf_target, domain_home,
60+
pwe.getLocalizedMessage(), error=pwe)
61+
self.__logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
62+
raise ex
63+
4464
def cd(self, wlst_path):
4565
"""
4666
Change WLST directories to the specified path

core/src/main/python/wlsdeploy/util/weblogic_helper.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
33
The Universal Permissive License (UPL), Version 1.0
44
"""
55
import java.lang.Exception as JException
@@ -74,6 +74,20 @@ def is_select_template_supported(self):
7474
"""
7575
return self.is_weblogic_version_or_above('12.2.1')
7676

77+
def is_database_defaults_supported(self):
78+
"""
79+
Is setDatabaseDefaults() supported by the version of JRF?
80+
:return: true if use the method to prime the JRF database defaults
81+
"""
82+
return self.is_weblogic_version_or_above('12.1.2')
83+
84+
def is_set_server_groups_supported(self):
85+
"""
86+
Is setServerGroups() supported by the version of WLST?
87+
:return: true if the setServerGroups() is supported
88+
"""
89+
return self.is_weblogic_version_or_above('12.1.2')
90+
7791
def is_dynamic_clusters_supported(self):
7892
"""
7993
Is dynamic clusters supported in this version of WLS?
@@ -109,7 +123,9 @@ def get_jrf_service_table_datasource_name(self):
109123
Get the JRF DataSource name for the service table schema.
110124
:return: the JRF DataSource name
111125
"""
112-
return 'LocalSvcTblDataSource'
126+
if self.is_weblogic_version_or_above('12.1.2'):
127+
return 'LocalSvcTblDataSource'
128+
return 'mds-owsm'
113129

114130
def get_default_admin_username(self):
115131
"""

0 commit comments

Comments
 (0)