Skip to content

Commit 6abc8b9

Browse files
authored
Issue #359 - Support custom extension templates (#366)
* Issue #359 - Support custom extension templates * Issue #359 - Add description for custom extension templates
1 parent f77b68f commit 6abc8b9

File tree

9 files changed

+112
-2
lines changed

9 files changed

+112
-2
lines changed

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,8 @@ def __extend_domain(self, domain_home):
394394

395395
self.logger.entering(domain_home, class_name=self.__class_name, method_name=_method_name)
396396
extension_templates = self._domain_typedef.get_extension_templates()
397-
if len(extension_templates) == 0:
397+
custom_templates = self._domain_typedef.get_custom_extension_templates()
398+
if (len(extension_templates) == 0) and (len(custom_templates) == 0):
398399
return
399400

400401
self.logger.info('WLSDPLY-12207', self._domain_name, domain_home,
@@ -407,6 +408,11 @@ def __extend_domain(self, domain_home):
407408
class_name=self.__class_name, method_name=_method_name)
408409
self.wlst_helper.add_template(extension_template)
409410

411+
for custom_template in custom_templates:
412+
self.logger.info('WLSDPLY-12246', custom_template,
413+
class_name=self.__class_name, method_name=_method_name)
414+
self.wlst_helper.add_template(custom_template)
415+
410416
self.__configure_fmw_infra_database()
411417

412418
if self.wls_helper.is_set_server_groups_supported():
@@ -415,6 +421,8 @@ def __extend_domain(self, domain_home):
415421
self.wlst_helper.update_domain()
416422
elif self._domain_typedef.is_jrf_domain_type():
417423
self.target_helper.target_jrf_groups_to_clusters_servers(domain_home)
424+
else:
425+
self.wlst_helper.update_domain()
418426

419427
self.wlst_helper.close_domain()
420428
self.logger.info('WLSDPLY-12209', self._domain_name,
@@ -444,6 +452,12 @@ def __create_domain_with_select_template(self, domain_home):
444452
class_name=self.__class_name, method_name=_method_name)
445453
self.wlst_helper.select_template(extension_template)
446454

455+
custom_templates = self._domain_typedef.get_custom_extension_templates()
456+
for custom_template in custom_templates:
457+
self.logger.info('WLSDPLY-12245', custom_template,
458+
class_name=self.__class_name, method_name=_method_name)
459+
self.wlst_helper.select_custom_template(custom_template)
460+
447461
self.logger.info('WLSDPLY-12212', class_name=self.__class_name, method_name=_method_name)
448462
self.wlst_helper.load_templates()
449463

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,15 @@ def get_extension_templates(self):
149149
self.__resolve_paths()
150150
return list(self._domain_typedef['extensionTemplates'])
151151

152+
def get_custom_extension_templates(self):
153+
"""
154+
Get the list of custom extension templates to apply when create/extending the domain.
155+
:return: the list of custom extension templates, or an empty list if no extension templates are needed.
156+
:raises: CreateException: if an error occurs resolving the paths
157+
"""
158+
self.__resolve_paths()
159+
return list(self._domain_typedef['customExtensionTemplates'])
160+
152161
def get_server_groups_to_target(self):
153162
"""
154163
Get the list of server groups to target to the managed servers in the domain.
@@ -313,6 +322,15 @@ def __resolve_paths(self):
313322
else:
314323
self._domain_typedef['extensionTemplates'] = []
315324

325+
if 'customExtensionTemplates' in self._domain_typedef:
326+
extension_templates = self._domain_typedef['customExtensionTemplates']
327+
resolved_templates = []
328+
for extension_template in extension_templates:
329+
resolved_templates.append(self._model_context.replace_token_string(extension_template))
330+
self._domain_typedef['customExtensionTemplates'] = resolved_templates
331+
else:
332+
self._domain_typedef['customExtensionTemplates'] = []
333+
316334
if 'serverGroupsToTarget' not in self._domain_typedef:
317335
self._domain_typedef['serverGroupsToTarget'] = []
318336

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,23 @@ def select_template(self, template_name):
504504
raise ex
505505
return
506506

507+
def select_custom_template(self, template_name):
508+
"""
509+
Select the custom template from the specified location.
510+
:param template_name: the custom template to select
511+
:raises: BundleAwareException of the specified type: if an error occurs
512+
"""
513+
_method_name = 'select_custom_template'
514+
515+
try:
516+
wlst_helper.select_custom_template(template_name)
517+
except PyWLSTException, pwe:
518+
ex = exception_helper.create_exception(self.__exception_type, 'WLSDPLY-19148', template_name,
519+
pwe.getLocalizedMessage(), error=pwe)
520+
self.__logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
521+
raise ex
522+
return
523+
507524
def add_template(self, template_name):
508525
"""
509526
Add the domain extension template from the specified location.

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,25 @@ def select_template(template):
538538
_logger.exiting(class_name=_class_name, method_name=_method_name)
539539

540540

541+
def select_custom_template(template):
542+
"""
543+
Select an existing custom domain template or application template for create a domain. This is
544+
available only in WebLogic 12c versions
545+
:param template: to be selected and loaded into the current session
546+
:raises: PyWLSTException: if a WLST error occurs
547+
"""
548+
_method_name = 'select_custom_template'
549+
_logger.entering(template, class_name=_class_name, method_name=_method_name)
550+
551+
try:
552+
wlst.selectCustomTemplate(template)
553+
except offlineWLSTException, e:
554+
pwe = exception_helper.create_pywlst_exception('WLSDPLY-00095', template, e.getLocalizedMessage(), error=e)
555+
_logger.throwing(class_name=_class_name, method_name=_method_name, error=pwe)
556+
raise pwe
557+
_logger.exiting(class_name=_class_name, method_name=_method_name)
558+
559+
541560
def load_templates():
542561
"""
543562
Load all the selected templates.

core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ WLSDPLY-00091=Unable to return the list of unsaved changes for the edit session
9999
WLSDPLY-00092=In the wrong state to activate saved changes for the edit session : {0}
100100
WLSDPLY-00093=In the wrong state to change to start an edit session : {0}
101101
WLSDPLY-00094=Checking the editor in online with current configuration manager failed: {0}
102-
102+
WLSDPLY-00095=wlst.selectCustomTemplate({0}) failed : {1}
103103

104104

105105
###############################################################################
@@ -1051,6 +1051,8 @@ WLSDPLY-12242=The assignment of servers to server groups map is {0}
10511051
WLSDPLY-12243=Server group list found for {0} in domainInfo : {1}
10521052
WLSDPLY-12244=Targeting JRF resources to a dynamic cluster(s), {0}, for a Restricted JRF domain type is not valid \
10531053
when updating in online mode
1054+
WLSDPLY-12245=Selecting custom extension template named {0}
1055+
WLSDPLY-12246=Adding custom extension template file {0} to domain
10541056

10551057
# domain_typedef.py
10561058
WLSDPLY-12300={0} got the domain type {1} but the domain type definition file {2} was not valid: {3}
@@ -1222,6 +1224,7 @@ WLSDPLY-19144=Unable to reopen the domain session : {0}
12221224
WLSDPLY-19145=Unable to save current changes and close the domain session : {0}
12231225
WLSDPLY-19146=Unable to apply JRF resources to the domain : {0}
12241226
WLSDPLY-19147=Unable to save current online changes : {0}
1227+
WLSDPLY-19148=Failed to select custom template ({0}): {1}
12251228

12261229
# wlsdeploy/tool/util/attribute_setter.py
12271230
WLSDPLY-19200=No target found with name {0}

core/src/main/typedefs/JRF.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"@@ORACLE_HOME@@/oracle_common/common/templates/applications/oracle.em_11_1_1_0_0_template.jar"
2222
],
2323
"serverGroupsToTarget" : [ "JRF-MAN-SVR", "WSMPM-MAN-SVR" ],
24+
"customExtensionTemplates": [ ],
2425
"rcuSchemas": [ "MDS", "IAU", "IAU_VIEWER", "IAU_APPEND", "OPSS" ]
2526
},
2627
"JRF_1212" : {
@@ -31,6 +32,7 @@
3132
"@@ORACLE_HOME@@/oracle_common/common/templates/wls/oracle.wsmpm_template_12.1.2.jar",
3233
"@@ORACLE_HOME@@/em/common/templates/wls/oracle.em_wls_template_12.1.2.jar"
3334
],
35+
"customExtensionTemplates": [ ],
3436
"serverGroupsToTarget" : [ "JRF-MAN-SVR", "WSMPM-MAN-SVR" ],
3537
"rcuSchemas": [ "MDS", "IAU", "IAU_VIEWER", "IAU_APPEND", "OPSS", "STB" ]
3638
},
@@ -42,6 +44,7 @@
4244
"@@ORACLE_HOME@@/oracle_common/common/templates/wls/oracle.wsmpm_template_12.1.3.jar",
4345
"@@ORACLE_HOME@@/em/common/templates/wls/oracle.em_wls_template_12.1.3.jar"
4446
],
47+
"customExtensionTemplates": [ ],
4548
"serverGroupsToTarget" : [ "JRF-MAN-SVR", "WSMPM-MAN-SVR" ],
4649
"rcuSchemas": [ "MDS", "IAU", "IAU_VIEWER", "IAU_APPEND", "OPSS", "STB" ]
4750
},
@@ -52,6 +55,7 @@
5255
"Oracle WSM Policy Manager",
5356
"Oracle Enterprise Manager"
5457
],
58+
"customExtensionTemplates": [ ],
5559
"serverGroupsToTarget": [ "JRF-MAN-SVR", "WSMPM-MAN-SVR" ],
5660
"rcuSchemas": [ "MDS", "IAU", "IAU_VIEWER", "IAU_APPEND", "OPSS", "STB" ]
5761
},
@@ -62,6 +66,7 @@
6266
"Oracle WSM Policy Manager",
6367
"Oracle Enterprise Manager"
6468
],
69+
"customExtensionTemplates": [ ],
6570
"serverGroupsToTarget": [ "JRF-MAN-SVR", "WSMPM-MAN-SVR" ],
6671
"rcuSchemas": [ "WLS", "MDS", "IAU", "IAU_VIEWER", "IAU_APPEND", "OPSS", "STB"]
6772
},
@@ -72,6 +77,7 @@
7277
"Oracle WSM Policy Manager",
7378
"Oracle Enterprise Manager"
7479
],
80+
"customExtensionTemplates": [ ],
7581
"serverGroupsToTarget": [ "JRF-MAN-SVR", "WSMPM-MAN-SVR" ],
7682
"rcuSchemas": [ "WLS", "MDS", "IAU", "IAU_VIEWER", "IAU_APPEND", "OPSS", "STB"]
7783
}

core/src/main/typedefs/RestrictedJRF.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,21 @@
1212
"RJRF_12CR2": {
1313
"baseTemplate": "Basic WebLogic Server Domain",
1414
"extensionTemplates": [ "Oracle Restricted JRF", "Oracle Enterprise Manager-Restricted JRF" ],
15+
"customExtensionTemplates": [ ],
1516
"serverGroupsToTarget": [ "JRF-MAN-SVR", "WSM-CACHE-SVR", "JRF-WS-CORE-MAN-SVR"],
1617
"rcuSchemas": [ ]
1718
},
1819
"RJRF_12213": {
1920
"baseTemplate": "Basic WebLogic Server Domain",
2021
"extensionTemplates": [ "Oracle Restricted JRF", "Oracle Enterprise Manager-Restricted JRF" ],
22+
"customExtensionTemplates": [ ],
2123
"serverGroupsToTarget": [ "JRF-MAN-SVR", "WSM-CACHE-SVR", "JRF-WS-CORE-MAN-SVR" ],
2224
"rcuSchemas": [ ]
2325
},
2426
"RJRF_19CR1": {
2527
"baseTemplate": "Basic WebLogic Server Domain",
2628
"extensionTemplates": [ "Oracle Restricted JRF", "Oracle Enterprise Manager-Restricted JRF"],
29+
"customExtensionTemplates": [ ],
2730
"serverGroupsToTarget": [ "JRF-MAN-SVR", "WSM-CACHE-SVR", "JRF-WS-CORE-MAN-SVR" ],
2831
"rcuSchemas": [ ]
2932
}

core/src/main/typedefs/WLS.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,28 @@
1515
"WLS_11G": {
1616
"baseTemplate": "@@WL_HOME@@/common/templates/domains/wls.jar",
1717
"extensionTemplates": [ ],
18+
"customExtensionTemplates": [ ],
1819
"serverGroupsToTarget": [ ],
1920
"rcuSchemas": [ ]
2021
},
2122
"WLS_12CR1": {
2223
"baseTemplate": "@@WL_HOME@@/common/templates/wls/wls.jar",
2324
"extensionTemplates": [ ],
25+
"customExtensionTemplates": [ ],
2426
"serverGroupsToTarget": [ ],
2527
"rcuSchemas": [ ]
2628
},
2729
"WLS_12CR2": {
2830
"baseTemplate": "Basic WebLogic Server Domain",
2931
"extensionTemplates": [ ],
32+
"customExtensionTemplates": [ ],
3033
"serverGroupsToTarget": [ ],
3134
"rcuSchemas": [ ]
3235
},
3336
"WLS_19CR1": {
3437
"baseTemplate": "Basic WebLogic Server Domain",
3538
"extensionTemplates": [ ],
39+
"customExtensionTemplates": [ ],
3640
"serverGroupsToTarget": [ ],
3741
"rcuSchemas": [ ]
3842
}

site/create.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,5 +207,31 @@ topology:
207207
NodeManagerPasswordEncrypted: welcome1
208208
```
209209

210+
The `customExtensionTemplates` attribute can be used to specify custom extension templates to be applied to the domain. These should be specified as absolute file paths, and can use tokens.
211+
212+
```json
213+
{
214+
"name": "MyCustom",
215+
"description": "My custom type domain definitions",
216+
"versions": {
217+
"12.2.1.3": "My_12213"
218+
},
219+
"definitions": {
220+
"My_12213": {
221+
"baseTemplate": "Basic WebLogic Server Domain",
222+
"extensionTemplates": [ ],
223+
"customExtensionTemplates": [
224+
"/user/me/templates/my-template.jar",
225+
"@@ORACLE_HOME@@/user_templates/other-template.jar"
226+
],
227+
"serverGroupsToTarget": [ "MY-MAN-SVR" ],
228+
"rcuSchemas": [ ]
229+
}
230+
}
231+
}
232+
```
233+
234+
If there are any server groups in the custom template that should be targeted to managed servers, they should be specified in the `serverGroupsToTarget` attribute, similar to `MY_MAN_SVR` in the example above.
235+
210236
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 (for example, `stdin`) to allow the tool to run without any user input.
211237

0 commit comments

Comments
 (0)