Skip to content

Commit 3a652ec

Browse files
authored
Merge pull request #256 from oracle/WDT-61-set-server-groups-11g
Wdt 61 set server groups 11g
2 parents 6150063 + 3988c58 commit 3a652ec

File tree

14 files changed

+282
-14
lines changed

14 files changed

+282
-14
lines changed

core/src/main/python/create.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,15 @@
3939
from wlsdeploy.util import getcreds
4040
from wlsdeploy.util import tool_exit
4141
from wlsdeploy.util import variables
42+
from wlsdeploy.util import wlst_extended
4243
from wlsdeploy.util import wlst_helper
4344
from wlsdeploy.util.cla_utils import CommandLineArgUtil
4445
from wlsdeploy.util.model_context import ModelContext
4546
from wlsdeploy.util.model_translator import FileToPython
4647
from wlsdeploy.util.weblogic_helper import WebLogicHelper
4748

49+
wlst_extended.wlst_functions = globals()
50+
4851
_program_name = CREATE_DOMAIN
4952

5053
_class_name = 'create'

core/src/main/python/deploy.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,15 @@
3939
from wlsdeploy.util import getcreds
4040
from wlsdeploy.util import tool_exit
4141
from wlsdeploy.util import variables
42+
from wlsdeploy.util import wlst_extended
4243
from wlsdeploy.util.cla_utils import CommandLineArgUtil
4344
from wlsdeploy.util.model import Model
4445
from wlsdeploy.util.model_context import ModelContext
4546
from wlsdeploy.util.model_translator import FileToPython
4647
from wlsdeploy.util.weblogic_helper import WebLogicHelper
4748

49+
wlst_extended.wlst_functions = globals()
50+
4851

4952
_program_name = 'deployApps'
5053
_class_name = 'deploy'

core/src/main/python/discover.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,15 @@
4747
from wlsdeploy.util import getcreds
4848
from wlsdeploy.util import model_translator
4949
from wlsdeploy.util import tool_exit
50+
from wlsdeploy.util import wlst_extended
5051
from wlsdeploy.util import wlst_helper
5152
from wlsdeploy.util.cla_utils import CommandLineArgUtil
5253
from wlsdeploy.util.model import Model
5354
from wlsdeploy.util.model_context import ModelContext
5455
from wlsdeploy.util.weblogic_helper import WebLogicHelper
5556

57+
wlst_extended.wlst_functions = globals()
58+
5659
_program_name = 'discoverDomain'
5760
_class_name = 'discover'
5861
__logger = PlatformLogger(discoverer.get_discover_logger_name())

core/src/main/python/update.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,14 @@
4444
from wlsdeploy.util import getcreds
4545
from wlsdeploy.util import tool_exit
4646
from wlsdeploy.util import variables
47+
from wlsdeploy.util import wlst_extended
4748
from wlsdeploy.util.cla_utils import CommandLineArgUtil
4849
from wlsdeploy.util.model import Model
4950
from wlsdeploy.util.model_context import ModelContext
5051
from wlsdeploy.util.model_translator import FileToPython
5152
from wlsdeploy.util.weblogic_helper import WebLogicHelper
5253

54+
wlst_extended.wlst_functions = globals()
5355

5456
_program_name = UPDATE_DOMAIN
5557
_class_name = 'update'
@@ -93,6 +95,7 @@ def __process_args(args):
9395
__verify_required_args_present(required_arg_map)
9496
__process_model_args(optional_arg_map)
9597
__wlst_mode = __process_online_args(optional_arg_map)
98+
9699
__process_encryption_args(optional_arg_map)
97100

98101
domain_type = dictionary_utils.get_element(optional_arg_map, CommandLineArgUtil.DOMAIN_TYPE_SWITCH)

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -324,13 +324,18 @@ def __extend_domain(self, domain_home):
324324

325325
self.__configure_fmw_infra_database()
326326

327-
server_groups_to_target = self._domain_typedef.get_server_groups_to_target()
328-
self.target_helper.target_server_groups_to_servers(server_groups_to_target)
327+
if self.wls_helper.is_set_server_groups_supported():
328+
server_groups_to_target = self._domain_typedef.get_server_groups_to_target()
329+
self.target_helper.target_server_groups_to_servers(server_groups_to_target)
330+
self.wlst_helper.update_domain()
331+
else:
332+
# Update the domain to apply the extension templates.
333+
self.wlst_helper.update_domain()
334+
self.target_helper.target_jrf_groups_to_clusters_servers(domain_home)
329335

336+
self.wlst_helper.close_domain()
330337
self.logger.info('WLSDPLY-12209', self._domain_name,
331338
class_name=self.__class_name, method_name=_method_name)
332-
self.wlst_helper.update_domain()
333-
self.wlst_helper.close_domain()
334339

335340
self.logger.exiting(class_name=self.__class_name, method_name=_method_name)
336341
return
@@ -684,12 +689,12 @@ def __configure_fmw_infra_database(self):
684689

685690
location.append_location(JDBC_DRIVER_PARAMS_PROPERTIES)
686691
token_name = self.alias_helper.get_name_token(location)
692+
687693
if token_name is not None:
688694
location.add_name_token(token_name, DRIVER_PARAMS_USER_PROPERTY)
689695

690696
stb_user = self.wls_helper.get_stb_user_name(rcu_prefix)
691697
self.logger.fine('WLSDPLY-12222', stb_user, class_name=self.__class_name, method_name=_method_name)
692-
693698
wlst_path = self.alias_helper.get_wlst_attributes_path(location)
694699
self.wlst_helper.cd(wlst_path)
695700
wlst_name, wlst_value = \
@@ -698,7 +703,8 @@ def __configure_fmw_infra_database(self):
698703
JDBC_DRIVER_PARAMS_PROPERTIES, DRIVER_PARAMS_USER_PROPERTY)
699704

700705
self.logger.info('WLSDPLY-12223', class_name=self.__class_name, method_name=_method_name)
701-
self.wlst_helper.get_database_defaults()
706+
if self.wls_helper.is_database_defaults_supported():
707+
self.wlst_helper.get_database_defaults()
702708

703709
self.logger.exiting(class_name=self.__class_name, method_name=_method_name)
704710
return

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

Lines changed: 42 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
from sets import Set
@@ -308,3 +308,44 @@ def get_file_hash(file_name):
308308
raise ex
309309
_logger.exiting(class_name=_class_name, method_name=_method_name, result=result)
310310
return result
311+
312+
313+
def save_changes(model_context):
314+
"""
315+
Call this if necessary to save changes and disconnect from the domain.
316+
This works in both offline and online.
317+
:param model_context: contains information about the current tool settings
318+
"""
319+
_method_name = 'save_changes'
320+
if model_context.get_target_wlst_mode() == WlstModes.ONLINE:
321+
if _wlst_helper.is_connected():
322+
_logger.fine('WLSDPLY-09110', class_name=_class_name, method_name=_method_name)
323+
_wlst_helper.save()
324+
_wlst_helper.activate()
325+
_wlst_helper.disconnect()
326+
else:
327+
_logger.fine('WLSDPLY-09109', class_name=_class_name, method_name=_method_name)
328+
else:
329+
_logger.fine('WLSDPLY-09111', class_name=_class_name, method_name=_method_name)
330+
_wlst_helper.update_domain()
331+
332+
333+
def read_again(model_context):
334+
"""
335+
Establish connection with the domain and start editing in both online and offline wlst mode.
336+
:param model_context: contains information about the current tool settings
337+
"""
338+
_method_name = 'read_again'
339+
if model_context.get_target_wlst_mode() == WlstModes.ONLINE:
340+
if not _wlst_helper.is_connected():
341+
_logger.fine('WLSDPLY-09113', class_name=_class_name, method_name=_method_name)
342+
_wlst_helper.connect(model_context.get_admin_user(), model_context.get_admin_password(),
343+
model_context.get_admin_url())
344+
_wlst_helper.edit()
345+
_wlst_helper.start_edit()
346+
else:
347+
_logger.fine('WLSDPLY-09112', class_name=_class_name, method_name=_method_name)
348+
else:
349+
_logger.fine('WLSDPLY-09114', class_name=_class_name, method_name=_method_name)
350+
_wlst_helper.close_domain()
351+
_wlst_helper.read_domain(model_context.get_domain_home())

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,13 @@ def update(self):
107107
for folder_name in remaining:
108108
self._process_section(self._topology, folder_list, folder_name, location)
109109

110-
server_groups_to_target = self._domain_typedef.get_server_groups_to_target()
111-
self.target_helper.target_server_groups_to_servers(server_groups_to_target)
110+
if self.wls_helper.is_set_server_groups_supported():
111+
server_groups_to_target = self._domain_typedef.get_server_groups_to_target()
112+
self.target_helper.target_server_groups_to_servers(server_groups_to_target)
113+
else:
114+
deployer_utils.save_changes(self.model_context)
115+
self.target_helper.target_jrf_groups_to_clusters_servers(self.model_context.get_domain_home())
116+
deployer_utils.read_again(self.model_context)
112117

113118
# files referenced in attributes are extracted as attributes are processed
114119

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

Lines changed: 59 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

@@ -38,6 +38,49 @@ 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_jrf_groups_to_clusters_servers(self, domain_home, should_update=True):
42+
"""
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
48+
"""
49+
_method_name = 'target_jrf_groups_to_clusters_servers'
50+
51+
self.logger.entering(domain_home, class_name=self.__class_name, method_name=_method_name)
52+
53+
location = LocationContext()
54+
root_path = self.alias_helper.get_wlst_attributes_path(location)
55+
self.wlst_helper.cd(root_path)
56+
admin_server_name = self.wlst_helper.get(ADMIN_SERVER_NAME)
57+
58+
# We need to get the effective list of servers for the domain. Since any servers
59+
# referenced in the model have already been created but the templates may have
60+
# defined new servers not listed in the model, get the list from WLST.
61+
server_names = self.get_existing_server_names()
62+
if admin_server_name in server_names:
63+
server_names.remove(admin_server_name)
64+
65+
# Get the clusters and and their members
66+
cluster_map = self._get_clusters_and_members_map()
67+
68+
# Get the clusters and and their members
69+
for cluster_name, cluster_servers in cluster_map.iteritems():
70+
self.logger.info('WLSDPLY-12233', 'Cluster', cluster_name, class_name=self.__class_name,
71+
method_name=_method_name)
72+
self.wlst_helper.apply_jrf(cluster_name, domain_home, should_update=should_update)
73+
for member in cluster_servers:
74+
if member in server_names:
75+
server_names.remove(member)
76+
for ms_name in server_names:
77+
self.logger.info('WLSDPLY-12233', 'Managed Server', ms_name, class_name=self.__class_name,
78+
method_name=_method_name)
79+
self.wlst_helper.apply_jrf(ms_name, domain_home, should_update=should_update)
80+
81+
self.logger.exiting(class_name=self.__class_name, method_name=_method_name)
82+
return
83+
4184
def target_server_groups_to_servers(self, server_groups_to_target):
4285
"""
4386
Target the server groups to the servers.
@@ -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: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
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
@@ -860,6 +880,13 @@ def domain_runtime(self):
860880
raise ex
861881
return
862882

883+
def is_connected(self):
884+
"""
885+
Determine if the wlst session is currently connected to the admin server.
886+
:return: True if connected
887+
"""
888+
return wlst_helper.is_connected()
889+
863890
def custom(self):
864891
"""
865892
Change to the custom MBean tree.

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,20 @@ def is_select_template_supported(self):
7272
"""
7373
return self.is_weblogic_version_or_above('12.2.1')
7474

75+
def is_database_defaults_supported(self):
76+
"""
77+
Is setDatabaseDefaults() supported by the version of JRF?
78+
:return: true if use the method to prime the JRF database defaults
79+
"""
80+
return self.is_weblogic_version_or_above('12.1.2')
81+
82+
def is_set_server_groups_supported(self):
83+
"""
84+
Is setServerGroups() supported by the version of WLST?
85+
:return: true if the setServerGroups() is supported
86+
"""
87+
return self.is_weblogic_version_or_above('12.1.2')
88+
7589
def is_dynamic_clusters_supported(self):
7690
"""
7791
Is dynamic clusters supported in this version of WLS?
@@ -107,7 +121,9 @@ def get_jrf_service_table_datasource_name(self):
107121
Get the JRF DataSource name for the service table schema.
108122
:return: the JRF DataSource name
109123
"""
110-
return 'LocalSvcTblDataSource'
124+
if self.is_weblogic_version_or_above('12.1.2'):
125+
return 'LocalSvcTblDataSource'
126+
return 'mds-owsm'
111127

112128
def get_default_admin_username(self):
113129
"""

0 commit comments

Comments
 (0)