Skip to content

Commit d958add

Browse files
committed
Issue#95 - Provide update of domain and classpath libraries
1 parent b9c9557 commit d958add

File tree

3 files changed

+100
-56
lines changed

3 files changed

+100
-56
lines changed

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

Lines changed: 11 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from wlsdeploy.aliases.model_constants import CLUSTER
1414
from wlsdeploy.aliases.model_constants import DEFAULT_ADMIN_SERVER_NAME
1515
from wlsdeploy.aliases.model_constants import DEFAULT_WLS_DOMAIN_NAME
16-
from wlsdeploy.aliases.model_constants import DOMAIN_LIBRARIES
1716
from wlsdeploy.aliases.model_constants import DOMAIN_NAME
1817
from wlsdeploy.aliases.model_constants import DRIVER_NAME
1918
from wlsdeploy.aliases.model_constants import DRIVER_PARAMS_PROPERTY_VALUE
@@ -50,6 +49,7 @@
5049
from wlsdeploy.tool.create.security_provider_creator import SecurityProviderCreator
5150
from wlsdeploy.tool.deploy import model_deployer
5251
from wlsdeploy.tool.util.archive_helper import ArchiveHelper
52+
from wlsdeploy.tool.util.library_helper import LibraryHelper
5353
from wlsdeploy.tool.util.topology_helper import TopologyHelper
5454
from wlsdeploy.util import dictionary_utils
5555
from wlsdeploy.util import model as model_helper
@@ -66,10 +66,6 @@ def __init__(self, model_dictionary, model_context, aliases):
6666
_method_name = '__init__'
6767
Creator.__init__(self, model_dictionary, model_context, aliases)
6868

69-
self.topology_helper = TopologyHelper(self.aliases, ExceptionType.CREATE, self.logger)
70-
self.security_provider_creator = SecurityProviderCreator(model_dictionary, model_context, aliases,
71-
ExceptionType.CREATE, self.logger)
72-
7369
# domainInfo section is required to get the admin password, everything else
7470
# is optional and will use the template defaults
7571
if model_helper.get_model_domain_info_key() not in model_dictionary:
@@ -79,6 +75,10 @@ def __init__(self, model_dictionary, model_context, aliases):
7975
self.logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
8076
raise ex
8177

78+
self.topology_helper = TopologyHelper(self.aliases, ExceptionType.CREATE, self.logger)
79+
self.security_provider_creator = SecurityProviderCreator(model_dictionary, model_context, aliases,
80+
ExceptionType.CREATE, self.logger)
81+
8282
self._domain_typedef = self.model_context.get_domain_typedef()
8383
self._topology = self.model.get_model_topology()
8484
self._domain_info = self.model.get_model_domain_info()
@@ -102,6 +102,10 @@ def __init__(self, model_dictionary, model_context, aliases):
102102
if archive_file_name is not None:
103103
self.archive_helper = ArchiveHelper(archive_file_name, self._domain_home, self.logger,
104104
exception_helper.ExceptionType.CREATE)
105+
106+
self.library_helper = LibraryHelper(self.model, self.model_context, self.aliases, self._domain_home,
107+
ExceptionType.CREATE, self.logger)
108+
105109
#
106110
# Creating domains with the wls.jar template is busted for pre-12.1.2 domains with regards to the
107111
# names of the default authentication providers (both the DefaultAuthenticator and the
@@ -227,8 +231,8 @@ def __create_domain(self):
227231
for file_to_extract in self.files_to_extract_from_archive:
228232
self.archive_helper.extract_file(file_to_extract)
229233

230-
self.__install_domain_libraries(self._domain_home)
231-
self.__extract_classpath_libraries(self._domain_home)
234+
self.library_helper.install_domain_libraries()
235+
self.library_helper.extract_classpath_libraries()
232236
self.logger.exiting(class_name=self.__class_name, method_name=_method_name)
233237
return
234238

@@ -350,55 +354,6 @@ def __create_domain_with_select_template(self, domain_home):
350354
self.logger.exiting(class_name=self.__class_name, method_name=_method_name)
351355
return
352356

353-
def __install_domain_libraries(self, domain_home):
354-
"""
355-
Extract the domain libraries listed in the model, if any, to the <DOMAIN_HOME>/lib directory.
356-
:param domain_home: the domain home directory
357-
:raises: CreateException: if an error occurs
358-
"""
359-
_method_name = '__install_domain_libraries'
360-
361-
self.logger.entering(domain_home, class_name=self.__class_name, method_name=_method_name)
362-
domain_info_dict = self.model.get_model_domain_info()
363-
if DOMAIN_LIBRARIES not in domain_info_dict or len(domain_info_dict[DOMAIN_LIBRARIES]) == 0:
364-
self.logger.info('WLSDPLY-12213', class_name=self.__class_name, method_name=_method_name)
365-
else:
366-
domain_libs = dictionary_utils.get_dictionary_element(domain_info_dict, DOMAIN_LIBRARIES)
367-
if self.archive_helper is None:
368-
ex = exception_helper.create_create_exception('WLSDPLY-12214', domain_libs)
369-
self.logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
370-
raise ex
371-
372-
for domain_lib in domain_libs:
373-
self.logger.info('WLSDPLY-12215', domain_lib, domain_home,
374-
class_name=self.__class_name, method_name=_method_name)
375-
self.archive_helper.extract_domain_library(domain_lib)
376-
377-
self.logger.exiting(class_name=self.__class_name, method_name=_method_name)
378-
return
379-
380-
def __extract_classpath_libraries(self, domain_home):
381-
"""
382-
Extract any classpath libraries in the archive to the domain home.
383-
:param domain_home: the domain home directory
384-
:raises: CreateException: if an error occurs
385-
"""
386-
_method_name = '__extract_classpath_libraries'
387-
388-
self.logger.entering(domain_home, class_name=self.__class_name, method_name=_method_name)
389-
if self.archive_helper is None:
390-
self.logger.info('WLSDPLY-12216', class_name=self.__class_name, method_name=_method_name)
391-
else:
392-
num_cp_libs = self.archive_helper.extract_classpath_libraries()
393-
if num_cp_libs > 0:
394-
self.logger.info('WLSDPLY-12217', num_cp_libs, domain_home,
395-
class_name=self.__class_name, method_name=_method_name)
396-
else:
397-
self.logger.info('WLSDPLY-12218', self.model_context.get_archive_file_name(),
398-
class_name=self.__class_name, method_name=_method_name)
399-
self.logger.exiting(class_name=self.__class_name, method_name=_method_name)
400-
return
401-
402357
def __apply_base_domain_config(self, topology_folder_list):
403358
"""
404359
Apply the base domain configuration from the model topology section.

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from wlsdeploy.tool.create.security_provider_creator import SecurityProviderCreator
1717
from wlsdeploy.tool.deploy import deployer_utils
1818
from wlsdeploy.tool.deploy.deployer import Deployer
19+
from wlsdeploy.tool.util.library_helper import LibraryHelper
1920
from wlsdeploy.tool.util.topology_helper import TopologyHelper
2021
from wlsdeploy.util import dictionary_utils
2122

@@ -34,6 +35,9 @@ def __init__(self, model, model_context, aliases, wlst_mode=WlstModes.OFFLINE):
3435
self._security_provider_creator = SecurityProviderCreator(model.get_model(), model_context, aliases,
3536
ExceptionType.DEPLOY, self.logger)
3637

38+
self.library_helper = LibraryHelper(self.model, self.model_context, self.aliases,
39+
model_context.get_domain_home(), ExceptionType.DEPLOY, self.logger)
40+
3741
# Override
3842
def _add_named_elements(self, type_name, model_nodes, location):
3943
"""
@@ -84,6 +88,11 @@ def update(self):
8488

8589
# TODO: update targeting
8690

91+
# files referenced in attributes are extracted as attributes are processed
92+
93+
self.library_helper.install_domain_libraries()
94+
self.library_helper.extract_classpath_libraries()
95+
8796
def _process_section(self, folder_dict, folder_list, key, location):
8897
if key in folder_dict:
8998
nodes = dictionary_utils.get_dictionary_element(folder_dict, key)
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
"""
2+
Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
3+
The Universal Permissive License (UPL), Version 1.0
4+
"""
5+
6+
import wlsdeploy.util.dictionary_utils as dictionary_utils
7+
8+
from wlsdeploy.aliases.model_constants import DOMAIN_LIBRARIES
9+
from wlsdeploy.exception import exception_helper
10+
from wlsdeploy.tool.util.alias_helper import AliasHelper
11+
from wlsdeploy.tool.util.archive_helper import ArchiveHelper
12+
from wlsdeploy.tool.util.wlst_helper import WlstHelper
13+
14+
15+
class LibraryHelper(object):
16+
"""
17+
Shared code for updating domain and classpath libraries. Domain create and update use this code.
18+
"""
19+
__class_name = 'LibraryHelper'
20+
21+
def __init__(self, model, model_context, aliases, domain_home, exception_type, logger):
22+
self.logger = logger
23+
self.model = model
24+
self.model_context = model_context
25+
self.domain_home = domain_home
26+
self.alias_helper = AliasHelper(aliases, self.logger, exception_type)
27+
self.wlst_helper = WlstHelper(self.logger, exception_type)
28+
29+
archive_file_name = self.model_context.get_archive_file_name()
30+
if archive_file_name is not None:
31+
self.archive_helper = ArchiveHelper(archive_file_name, self.domain_home, self.logger, exception_type)
32+
33+
def install_domain_libraries(self):
34+
"""
35+
Extract the domain libraries listed in the model, if any, to the <DOMAIN_HOME>/lib directory.
36+
:raises: BundleAwareException of the specified type: if an error occurs
37+
"""
38+
_method_name = 'install_domain_libraries'
39+
print('\n' + _method_name)
40+
41+
self.logger.entering(self.domain_home, class_name=self.__class_name, method_name=_method_name)
42+
domain_info_dict = self.model.get_model_domain_info()
43+
if DOMAIN_LIBRARIES not in domain_info_dict or len(domain_info_dict[DOMAIN_LIBRARIES]) == 0:
44+
self.logger.info('WLSDPLY-12213', class_name=self.__class_name, method_name=_method_name)
45+
else:
46+
domain_libs = dictionary_utils.get_dictionary_element(domain_info_dict, DOMAIN_LIBRARIES)
47+
if self.archive_helper is None:
48+
ex = exception_helper.create_create_exception('WLSDPLY-12214', domain_libs)
49+
self.logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
50+
raise ex
51+
52+
for domain_lib in domain_libs:
53+
self.logger.info('WLSDPLY-12215', domain_lib, self.domain_home,
54+
class_name=self.__class_name, method_name=_method_name)
55+
self.archive_helper.extract_domain_library(domain_lib)
56+
57+
self.logger.exiting(class_name=self.__class_name, method_name=_method_name)
58+
return
59+
60+
def extract_classpath_libraries(self):
61+
"""
62+
Extract any classpath libraries in the archive to the domain home.
63+
:raises: BundleAwareException of the specified type: if an error occurs
64+
"""
65+
_method_name = 'extract_classpath_libraries'
66+
print('\n' + _method_name)
67+
68+
self.logger.entering(self.domain_home, class_name=self.__class_name, method_name=_method_name)
69+
if self.archive_helper is None:
70+
self.logger.info('WLSDPLY-12216', class_name=self.__class_name, method_name=_method_name)
71+
else:
72+
num_cp_libs = self.archive_helper.extract_classpath_libraries()
73+
if num_cp_libs > 0:
74+
self.logger.info('WLSDPLY-12217', num_cp_libs, self.domain_home,
75+
class_name=self.__class_name, method_name=_method_name)
76+
else:
77+
self.logger.info('WLSDPLY-12218', self.model_context.get_archive_file_name(),
78+
class_name=self.__class_name, method_name=_method_name)
79+
self.logger.exiting(class_name=self.__class_name, method_name=_method_name)
80+
return

0 commit comments

Comments
 (0)