Skip to content

Commit e0be1b1

Browse files
committed
adding ServerGroupTargetingLimits element to the model
1 parent 601187a commit e0be1b1

File tree

9 files changed

+374
-39
lines changed

9 files changed

+374
-39
lines changed

README.md

Lines changed: 100 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ This file tells the Create Domain tool what templates to use to create the domai
659659
"Oracle SOA Suite"
660660
],
661661
"serverGroupsToTarget": [ "JRF-MAN-SVR", "WSMPM-MAN-SVR", "SOA-MGD-SVRS" ],
662-
"rcuSchemas": [ "STB", "WLS", "MDS", "IAU", "IAU_VIEWER", "IAU_APPEND", "OPSS", "UCSUMS", "ESS", "SOAINFRA" ]
662+
"rcuSchemas": [ "STB", "WLS", "MDS", "IAU", "IAU_VIEWER", "IAU_APPEND", "OPSS", "UCSUMS", "SOAINFRA" ]
663663
}
664664
}
665665
}
@@ -669,6 +669,105 @@ Once the new domain typedef file exists, simply specify the new domain type name
669669

670670
weblogic-deploy\bin\createDomain.cmd -oracle_home d:\SOA12213 -domain_type SOA -domain_parent d:\demo\domains -model_file DemoDomain.yaml -archive_file DemoDomain.zip -variable_file DemoDomain.properties -run_rcu -rcu_db mydb.example.com:1539/PDBORCL -rcu_prefix DEMO
671671

672+
To create more complex domains with clusters of different types, it is necessary to control the targeting of server groups to managed servers. By default, all server groups in the domain type definition are targeted to all managed servers. To create a SOA domain with a SOA and OSB clusters, simply add the OSB template and server group to the SOA domain definition, as shown below.
673+
674+
```json
675+
{
676+
"name": "SOA",
677+
"description": "SOA type domain definitions",
678+
"versions": {
679+
"12.2.1.3": "SOA_12213"
680+
},
681+
"definitions": {
682+
"SOA_12213": {
683+
"baseTemplate": "Basic WebLogic Server Domain",
684+
"extensionTemplates": [
685+
"Oracle SOA Suite",
686+
"Oracle Service Bus"
687+
],
688+
"serverGroupsToTarget": [ "JRF-MAN-SVR", "WSMPM-MAN-SVR", "SOA-MGD-SVRS", "OSB-MGD-SVRS-COMBINED" ],
689+
"rcuSchemas": [ "STB", "WLS", "MDS", "IAU", "IAU_VIEWER", "IAU_APPEND", "OPSS", "UCSUMS", "SOAINFRA" ]
690+
}
691+
}
692+
}
693+
```
694+
695+
Then, use the `ServerGroupTargetingLimits` map in the `domainInfo` section to limit the targeting of the Web Services Manager, SOA, and OSB server groups to the `soa_cluster` or `osb_cluster`, as appropriate. In the example below, notice that the `JRF-MAN-SVR` server group is not listed; therefore, it will use the default targeting and be targeted to all managed servers. The value of each element in this section is a logically list of server and/or cluster names. As shown in the example, the value for each server group can be specified as a list, a comma-separated string, or a single-valued string. There is no semantic difference between listing a cluster's member server names versus using the cluster name; the example uses these simply to show what is possible.
696+
697+
```$yaml
698+
domainInfo:
699+
AdminUserName: weblogic
700+
AdminPassword: welcome1
701+
ServerStartMode: prod
702+
ServerGroupTargetingLimits:
703+
'WSMPM-MAN-SVR': soa_cluster
704+
'SOA-MGD-SVRS': 'soa_server1,soa_server2'
705+
'OSB-MGD-SVRS-COMBINED': [ osb_server1, osb_server2 ]
706+
707+
topology:
708+
Name: soa_domain
709+
AdminServerName: AdminServer
710+
Cluster:
711+
soa_cluster:
712+
osb_cluster:
713+
Server:
714+
AdminServer:
715+
ListenAddress: myadmin.example.com
716+
ListenPort: 7001
717+
Machine: machine1
718+
SSL:
719+
Enabled: true
720+
ListenPort: 7002
721+
soa_server1:
722+
ListenAddress: managed1.example.com
723+
ListenPort: 8001
724+
Cluster: soa_cluster
725+
Machine: machine2
726+
SSL:
727+
Enabled: true
728+
ListenPort: 8002
729+
soa_server2:
730+
ListenAddress: managed2.example.com
731+
ListenPort: 8001
732+
Cluster: soa_cluster
733+
Machine: machine3
734+
SSL:
735+
Enabled: true
736+
ListenPort: 8002
737+
osb_server1:
738+
ListenAddress: managed1.example.com
739+
ListenPort: 9001
740+
Cluster: osb_cluster
741+
Machine: machine2
742+
SSL:
743+
Enabled: true
744+
ListenPort: 9002
745+
osb_server2:
746+
ListenAddress: managed2.example.com
747+
ListenPort: 9001
748+
Cluster: osb_cluster
749+
Machine: machine3
750+
SSL:
751+
Enabled: true
752+
ListenPort: 9002
753+
UnixMachine:
754+
machine1:
755+
NodeManager:
756+
ListenAddress: myadmin.example.com
757+
ListenPort: 5556
758+
machine2:
759+
NodeManager:
760+
ListenAddress: managed1.example.com
761+
ListenPort: 5556
762+
machine3:
763+
NodeManager:
764+
ListenAddress: managed2.example.com
765+
ListenPort: 5556
766+
SecurityConfiguration:
767+
NodeManagerUsername: weblogic
768+
NodeManagerPasswordEncrypted: welcome1
769+
```
770+
672771
One last note is that if the model or variables file contains encrypted passwords, add the `-use_encryption` flag to the command-line to tell the Create Domain tool that encryption is being used and to prompt for the encryption passphrase. As with the database passwords, the tool can also read the passphrase from standard input (i.e., stdin) to allow the tool to run without any user input.
673772

674773
## The Deploy Applications Tool

core/src/main/python/wlsdeploy/aliases/alias_entries.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,12 @@ class AliasEntries(object):
155155
'AdminUserName': 'string',
156156
'AdminPassword': 'string',
157157
'ServerStartMode': 'string',
158-
'domainLibraries': 'list'
158+
'domainLibraries': 'list',
159+
# A map of Server Group names to the list of servers/clusters to which they should
160+
# be targeted. The ServerGroup must appear in the domain typedef definition. If
161+
# the ServerGroup is not listed in this map, it will be targeted to all managed
162+
# servers in the domain.
163+
'ServerGroupTargetingLimits': 'dict'
159164
}
160165

161166
__domain_name_token = 'DOMAIN'

core/src/main/python/wlsdeploy/aliases/model_constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@
199199
SELF_TUNING = 'SelfTuning'
200200
SERVER = 'Server'
201201
SERVER_FAILURE_TRIGGER = 'ServerFailureTrigger'
202+
SERVER_GROUP_TARGETING_LIMITS = 'ServerGroupTargetingLimits'
202203
SERVER_START = 'ServerStart'
203204
SERVER_START_MODE = 'ServerStartMode'
204205
SERVER_TEMPLATE = 'ServerTemplate'

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

Lines changed: 146 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
33
The Universal Permissive License (UPL), Version 1.0
44
"""
5+
import copy
6+
7+
from oracle.weblogic.deploy.util import PyOrderedDict as OrderedDict
58
from oracle.weblogic.deploy.util import WLSDeployArchive
69

710
from wlsdeploy.aliases.location_context import LocationContext
@@ -13,8 +16,14 @@
1316
from wlsdeploy.tool.util.attribute_setter import AttributeSetter
1417
from wlsdeploy.tool.util.wlst_helper import WlstHelper
1518
from wlsdeploy.util import dictionary_utils
19+
from wlsdeploy.util.model import Model
20+
from wlsdeploy.util import string_utils
1621
from wlsdeploy.util.weblogic_helper import WebLogicHelper
1722

23+
from wlsdeploy.aliases.model_constants import CLUSTER
24+
from wlsdeploy.aliases.model_constants import MODEL_LIST_DELIMITER
25+
from wlsdeploy.aliases.model_constants import SERVER
26+
1827

1928
class Creator(object):
2029
"""
@@ -27,7 +36,7 @@ def __init__(self, model, model_context, aliases):
2736
self.aliases = aliases
2837
self.alias_helper = AliasHelper(self.aliases, self.logger, ExceptionType.CREATE)
2938
self.wlst_helper = WlstHelper(self.logger, ExceptionType.CREATE)
30-
self.model = model
39+
self.model = Model(model)
3140
self.model_context = model_context
3241
self.wls_helper = WebLogicHelper(self.logger)
3342
self.attribute_setter = AttributeSetter(self.aliases, self.logger, ExceptionType.CREATE)
@@ -436,3 +445,139 @@ def _format_model_path(self, location, name):
436445
path += '/'
437446
path += name
438447
return path
448+
449+
def _get_existing_server_names(self):
450+
"""
451+
Get the list of server names from WLST.
452+
:return: the list of server names
453+
:raises: CreateException: is an error occurs reading from the aliases or WLST
454+
"""
455+
_method_name = '_get_existing_server_names'
456+
457+
self.logger.entering(class_name=self.__class_name, method_name=_method_name)
458+
server_location = LocationContext().append_location(SERVER)
459+
server_list_path = self.alias_helper.get_wlst_list_path(server_location)
460+
result = self.wlst_helper.get_existing_object_list(server_list_path)
461+
self.logger.exiting(class_name=self.__class_name, method_name=_method_name, result=result)
462+
return result
463+
464+
def _get_clusters_and_members_map(self):
465+
"""
466+
Get a map keyed by cluster name with values that are a list of member server names
467+
:return: the cluster name to member server names map
468+
:raises: CreateException: is an error occurs reading from the aliases or WLST
469+
"""
470+
_method_name = '_get_clusters_and_members_map'
471+
472+
self.logger.entering(class_name=self.__class_name, method_name=_method_name)
473+
server_location = LocationContext().append_location(SERVER)
474+
server_list_path = self.alias_helper.get_wlst_list_path(server_location)
475+
server_names = self.wlst_helper.get_existing_object_list(server_list_path)
476+
server_token = self.alias_helper.get_name_token(server_location)
477+
cluster_map = OrderedDict()
478+
for server_name in server_names:
479+
server_location.add_name_token(server_token, server_name)
480+
server_attributes_path = self.alias_helper.get_wlst_attributes_path(server_location)
481+
self.wlst_helper.cd(server_attributes_path)
482+
483+
server_attributes_map = self.wlst_helper.lsa()
484+
cluster_name = dictionary_utils.get_element(server_attributes_map, CLUSTER)
485+
if string_utils.is_empty(cluster_name):
486+
# if server is not part of a cluster, continue with the next server
487+
continue
488+
489+
if cluster_name not in cluster_map:
490+
cluster_map[cluster_name] = list()
491+
cluster_map[cluster_name].append(server_name)
492+
493+
self.logger.exiting(class_name=self.__class_name, method_name=_method_name, result=cluster_map)
494+
return cluster_map
495+
496+
def _get_server_group_targeting_limits(self, server_group_targeting_limits, clusters_map):
497+
"""
498+
Get any server group targeting limits specified in the model, converting any cluster
499+
names to the list of members. This method assumes that the limits dictionary is not
500+
None or empty.
501+
:param server_group_targeting_limits: the raw server group targeting_limits from the model
502+
:param clusters_map: the map of cluster names to member server names
503+
:return: the map of server groups to server names to target
504+
"""
505+
_method_name = '_get_server_group_targeting_limits'
506+
507+
self.logger.entering(str(server_group_targeting_limits), str(clusters_map),
508+
class_name=self.__class_name, method_name=_method_name)
509+
sg_targeting_limits = copy.deepcopy(server_group_targeting_limits)
510+
for server_group_name, sg_targeting_limit in sg_targeting_limits.iteritems():
511+
if type(sg_targeting_limit) is str:
512+
if MODEL_LIST_DELIMITER in sg_targeting_limit:
513+
sg_targeting_limit = sg_targeting_limit.split(MODEL_LIST_DELIMITER)
514+
else:
515+
# convert a single value into a list of one...
516+
new_list = list()
517+
new_list.append(sg_targeting_limit)
518+
sg_targeting_limit = new_list
519+
520+
# Convert any references to a cluster name into the list of member server names
521+
new_list = list()
522+
for target_name in sg_targeting_limit:
523+
target_name = target_name.strip()
524+
if target_name in clusters_map:
525+
cluster_members = dictionary_utils.get_element(clusters_map, target_name)
526+
new_list.extend(cluster_members)
527+
else:
528+
# Assume it is a server name and add it to the new list
529+
new_list.append(target_name)
530+
sg_targeting_limits[server_group_name] = new_list
531+
532+
self.logger.exiting(class_name=self.__class_name, method_name=_method_name, result=sg_targeting_limits)
533+
return sg_targeting_limits
534+
535+
def _get_server_to_server_groups_map(self, admin_server_name, server_names, server_groups, sg_targeting_limits):
536+
"""
537+
Get the map of server names to the list of server groups to target to that server.
538+
:param admin_server_name: the admin server name
539+
:param server_names: the list of server names
540+
:param server_groups: the complete list of server groups that will, by default, be targeted to
541+
all managed servers unless the server is listed in the targeting limits map
542+
:param sg_targeting_limits: the targeting limits map
543+
:return: the map of server names to the list of server groups to target to that server
544+
"""
545+
_method_name = '_get_server_to_server_groups_map'
546+
547+
self.logger.entering(admin_server_name, str(server_names), str(server_groups), str(sg_targeting_limits),
548+
class_name=self.__class_name, method_name=_method_name)
549+
result = OrderedDict()
550+
for server_name in server_names:
551+
server_groups_for_server = self.__get_server_groups_for_server(server_name, sg_targeting_limits)
552+
if server_groups_for_server is not None:
553+
result[server_name] = server_groups_for_server
554+
elif server_name != admin_server_name:
555+
# By default, we only target managed servers unless explicitly listed in the targeting limits
556+
result[server_name] = list(server_groups)
557+
else:
558+
result[admin_server_name] = list()
559+
if admin_server_name not in result:
560+
result[admin_server_name] = list()
561+
self.logger.exiting(class_name=self.__class_name, method_name=_method_name, result=result)
562+
return result
563+
564+
def __get_server_groups_for_server(self, server_name, sg_targeting_limits):
565+
"""
566+
Get the servers groups to target for a given server name.
567+
:param server_name: the server name
568+
:param sg_targeting_limits: the targeting limits
569+
:return: the list of server groups to target to the specified server name, or None
570+
if the server name does not appear in the targeting limits
571+
"""
572+
_method_name = '__get_server_groups_for_server'
573+
574+
self.logger.entering(server_name, str(sg_targeting_limits),
575+
class_name=self.__class_name, method_name=_method_name)
576+
result = None
577+
for server_group, server_names_list in sg_targeting_limits.iteritems():
578+
if server_name in server_names_list:
579+
if result is None:
580+
result = list()
581+
result.append(server_group)
582+
self.logger.exiting(class_name=self.__class_name, method_name=_method_name, result=result)
583+
return result

0 commit comments

Comments
 (0)