Skip to content

Commit eb1a3cf

Browse files
remote processing of discover (#1127)
* remote processing of discover * fix for system test * fix for system test * fix for system test * fix for system test * add unit test * change script * move remote check to discover classes * fix system test * fix system test * fix system test * fix system test * fix system test * fix system test * fix system test * fix system test * fix system test * fix system test
1 parent c5d2738 commit eb1a3cf

File tree

18 files changed

+788
-462
lines changed

18 files changed

+788
-462
lines changed

core/src/main/java/oracle/weblogic/deploy/util/WLSDeployArchive.java

Lines changed: 301 additions & 164 deletions
Large diffs are not rendered by default.

core/src/main/python/discover.py

Lines changed: 68 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,12 @@
4545
from wlsdeploy.tool.util.wlst_helper import WlstHelper
4646
from wlsdeploy.tool.validate.validator import Validator
4747
from wlsdeploy.util import cla_helper
48+
from wlsdeploy.util import cla_utils
4849
from wlsdeploy.util import model_translator
4950
from wlsdeploy.util import path_utils
5051
from wlsdeploy.util import tool_exit
5152
from wlsdeploy.util.cla_utils import CommandLineArgUtil
53+
from wlsdeploy.util.cla_utils import TOOL_TYPE_DISCOVER
5254
from wlsdeploy.util.model import Model
5355
from wlsdeploy.util.weblogic_helper import WebLogicHelper
5456
from wlsdeploy.util import target_configuration_helper
@@ -80,7 +82,8 @@
8082
CommandLineArgUtil.ADMIN_PASS_ENV_SWITCH,
8183
CommandLineArgUtil.TARGET_MODE_SWITCH,
8284
CommandLineArgUtil.OUTPUT_DIR_SWITCH,
83-
CommandLineArgUtil.TARGET_SWITCH
85+
CommandLineArgUtil.TARGET_SWITCH,
86+
CommandLineArgUtil.REMOTE_SWITCH
8487
]
8588

8689

@@ -93,14 +96,15 @@ def __process_args(args):
9396
global __wlst_mode
9497

9598
cla_util = CommandLineArgUtil(_program_name, __required_arguments, __optional_arguments)
96-
argument_map = cla_util.process_args(args)
99+
argument_map = cla_util.process_args(args, TOOL_TYPE_DISCOVER)
97100

98101
__wlst_mode = cla_helper.process_online_args(argument_map)
99102
target_configuration_helper.process_target_arguments(argument_map)
100103
__process_model_archive_args(argument_map)
101104
__process_archive_filename_arg(argument_map)
102105
__process_variable_filename_arg(argument_map)
103106
__process_java_home(argument_map)
107+
__process_domain_home(argument_map, __wlst_mode)
104108

105109
return model_context_helper.create_context(_program_name, argument_map)
106110

@@ -112,7 +116,8 @@ def __process_model_archive_args(argument_map):
112116
"""
113117
_method_name = '__process_model_archive_args'
114118
if CommandLineArgUtil.ARCHIVE_FILE_SWITCH not in argument_map:
115-
if CommandLineArgUtil.SKIP_ARCHIVE_FILE_SWITCH not in argument_map:
119+
if CommandLineArgUtil.SKIP_ARCHIVE_FILE_SWITCH not in argument_map and \
120+
CommandLineArgUtil.REMOTE_SWITCH not in argument_map:
116121
ex = exception_helper.create_cla_exception(CommandLineArgUtil.USAGE_ERROR_EXIT_CODE, 'WLSDPLY-06028')
117122
__logger.throwing(ex, class_name=_class_name, method_name=_method_name)
118123
raise ex
@@ -130,7 +135,7 @@ def __process_archive_filename_arg(argument_map):
130135
"""
131136
_method_name = '__process_archive_filename_arg'
132137

133-
if CommandLineArgUtil.SKIP_ARCHIVE_FILE_SWITCH in argument_map:
138+
if CommandLineArgUtil.SKIP_ARCHIVE_FILE_SWITCH in argument_map or CommandLineArgUtil.REMOTE_SWITCH in argument_map:
134139
archive_file = WLSDeployArchive.noArchiveFile()
135140
else:
136141
archive_file_name = argument_map[CommandLineArgUtil.ARCHIVE_FILE_SWITCH]
@@ -151,6 +156,7 @@ def __process_archive_filename_arg(argument_map):
151156
argument_map[CommandLineArgUtil.ARCHIVE_FILE] = archive_file
152157

153158

159+
154160
def __process_variable_filename_arg(optional_arg_map):
155161
"""
156162
If the variable filename argument is present, the required model variable injector json file must exist in
@@ -191,6 +197,19 @@ def __process_java_home(optional_arg_map):
191197
class_name=_class_name, method_name=_method_name)
192198

193199

200+
def __process_domain_home(arg_map, wlst_mode):
201+
domain_home = None
202+
if CommandLineArgUtil.DOMAIN_HOME_SWITCH not in arg_map:
203+
return
204+
domain_home = arg_map[CommandLineArgUtil.DOMAIN_HOME_SWITCH]
205+
skip_archive = False
206+
if CommandLineArgUtil.SKIP_ARCHIVE_FILE_SWITCH in arg_map or CommandLineArgUtil.REMOTE_SWITCH in arg_map:
207+
skip_archive = True
208+
if wlst_mode == WlstModes.OFFLINE or not skip_archive:
209+
full_path = cla_utils.validate_domain_home_arg(domain_home)
210+
arg_map[CommandLineArgUtil.DOMAIN_HOME_SWITCH] = full_path
211+
212+
194213
def __discover(model_context, aliases, credential_injector, helper):
195214
"""
196215
Populate the model from the domain.
@@ -224,8 +243,22 @@ def __discover(model_context, aliases, credential_injector, helper):
224243
ae.getLocalizedMessage(), error=ae)
225244
__logger.throwing(ex, class_name=_class_name, method_name=_method_name)
226245
raise ex
227-
228246
__disconnect_domain(helper)
247+
248+
if model_context.is_remote():
249+
print ''
250+
remote_map = WLSDeployArchive.getRemoteList()
251+
if len(remote_map) == 0:
252+
message = exception_helper.get_message('WLSDPLY-06030')
253+
else:
254+
message = exception_helper.get_message('WLSDPLY-06031')
255+
print message
256+
print ''
257+
for key in remote_map:
258+
other_map = remote_map[key]
259+
wls_archive = other_map[WLSDeployArchive.REMOTE_ARCHIVE_DIR]
260+
print key, ' ', wls_archive
261+
print ''
229262
return model
230263

231264

@@ -307,12 +340,13 @@ def __clear_archive_file(model_context):
307340
__logger.throwing(class_name=_class_name, method_name=_method_name, error=de)
308341
raise de
309342

310-
try:
311-
archive_file.removeAllBinaries()
312-
except WLSDeployArchiveIOException, wioe:
313-
de = exception_helper.create_discover_exception('WLSDPLY-06005', wioe.getLocalizedMessage())
314-
__logger.throwing(class_name=_class_name, method_name=_method_name, error=de)
315-
raise de
343+
if not model_context.skip_archive() and not model_context.is_remote():
344+
try:
345+
archive_file.removeAllBinaries()
346+
except WLSDeployArchiveIOException, wioe:
347+
de = exception_helper.create_discover_exception('WLSDPLY-06005', wioe.getLocalizedMessage())
348+
__logger.throwing(class_name=_class_name, method_name=_method_name, error=de)
349+
raise de
316350

317351

318352
def __close_archive(model_context):
@@ -373,6 +407,10 @@ def __persist_model(model, model_context):
373407
add_to_archive = False
374408
model_file_name = model_context.get_model_file()
375409
if model_file_name is None:
410+
if model_context.skip_archive() or model_context.is_remote():
411+
ex = exception_helper.create_discover_exception('WLSDPLY-06032')
412+
__logger.throwing(ex, class_name=_class_name, method_name=_method_name)
413+
raise ex
376414
add_to_archive = True
377415
try:
378416
domain_name = model_context.get_domain_name()
@@ -473,6 +511,24 @@ def __check_and_customize_model(model, model_context, aliases, credential_inject
473511
return model
474512

475513

514+
def __remote_report(model_context):
515+
if not model_context.is_remote():
516+
return
517+
print ''
518+
remote_map = discoverer.remote_dict
519+
if len(remote_map) == 0:
520+
message = exception_helper.get_message('WLSDPLY-06030')
521+
else:
522+
message = exception_helper.get_message('WLSDPLY-06031')
523+
print message
524+
print ''
525+
for key in remote_map:
526+
other_map = remote_map[key]
527+
wls_archive = other_map[discoverer.REMOTE_ARCHIVE_PATH]
528+
print key, ' ', wls_archive
529+
print ''
530+
531+
476532
def __log_and_exit(model_context, exit_code, class_name, method_name):
477533
"""
478534
Helper method to log the exiting message and call sys.exit()
@@ -538,6 +594,7 @@ def main(args):
538594

539595
model = __check_and_customize_model(model, model_context, aliases, credential_injector)
540596

597+
__remote_report(model_context)
541598
except DiscoverException, ex:
542599
__logger.severe('WLSDPLY-06011', _program_name, model_context.get_domain_name(),
543600
model_context.get_domain_home(), ex.getLocalizedMessage(),

core/src/main/python/wlsdeploy/tool/discover/coherence_resources_discoverer.py

Lines changed: 66 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
from oracle.weblogic.deploy.util import FileUtils
1212
from oracle.weblogic.deploy.util import PyOrderedDict as OrderedDict
13+
from oracle.weblogic.deploy.util import WLSDeployArchive
1314
from oracle.weblogic.deploy.util import WLSDeployArchiveIOException
1415

1516
from wlsdeploy.aliases import model_constants
@@ -163,23 +164,22 @@ def _add_custom_configuration_to_archive(self, model_name, model_value, location
163164
new_name = model_value
164165
if model_value is not None:
165166
archive_file = self._model_context.get_archive_file()
166-
file_name_path = self._convert_path(model_value)
167-
config_file = None
168-
try:
169-
config_file = FileUtils.getCanonicalFile(File(file_name_path))
170-
except (IOException, SecurityException), se:
171-
_logger.warning('WLSDPLY-06314', cluster_name, file_name_path, se.getLocalizedMessage(),
172-
class_name=_class_name, method_name=_method_name)
173-
new_name = None
167+
file_name_path = model_value
168+
if not self._model_context.is_remote():
169+
file_name_path = self._convert_path(model_value)
170+
if not self._model_context.skip_archive():
171+
try:
172+
new_name = archive_file.addCoherenceConfigFile(cluster_name, new_name)
173+
_logger.finer('WLSDPLY-06315', file_name_path, class_name=_class_name, method_name=_method_name)
174+
except (IllegalArgumentException, WLSDeployArchiveIOException), wioe:
175+
_logger.warning('WLSDPLY-06316', cluster_name, file_name_path, wioe.getLocalizedMessage(),
176+
class_name=_class_name, method_name=_method_name)
177+
new_name = None
178+
else:
179+
new_name = archive_file.getCoherenceConfigArchivePath(cluster_name, new_name)
180+
self.add_to_remote_map(file_name_path, new_name,
181+
WLSDeployArchive.ArchiveEntryType.COHERENCE_CONFIG.name())
174182

175-
if file is not None:
176-
try:
177-
new_name = archive_file.addCoherenceConfigFile(cluster_name, config_file)
178-
_logger.finer('WLSDPLY-06315', file_name_path, class_name=_class_name, method_name=_method_name)
179-
except (IllegalArgumentException, WLSDeployArchiveIOException), wioe:
180-
_logger.warning('WLSDPLY-06316', cluster_name, file_name_path, wioe.getLocalizedMessage(),
181-
class_name=_class_name, method_name=_method_name)
182-
new_name = None
183183

184184
_logger.exiting(class_name=_class_name, method_name=_method_name, result=new_name)
185185
return new_name
@@ -201,31 +201,51 @@ def _add_cache_config(self, model_name, model_value, location):
201201
_logger.entering(cluster_name, model_name, model_value, class_name=_class_name, method_name=_method_name)
202202
new_name = model_value
203203
if model_value is not None:
204-
success, url, file_name = self._get_from_url('Coherence Cluster ' + cluster_name + ' Cache Configuration', model_value)
204+
success, url, file_name = self._get_from_url('Coherence Cluster ' + cluster_name + ' Cache Configuration',
205+
model_value)
205206
archive_file = self._model_context.get_archive_file()
206207
if success:
207208
if url is not None:
208-
try:
209-
new_name = archive_file.addCoherenceConfigFileFromUrl(cluster_name, url)
210-
_logger.info('WLSDPLY-06317', cluster_name, url, new_name, class_name=_class_name,
211-
method_name=_method_name)
212-
except (IllegalArgumentException, WLSDeployArchiveIOException), wioe:
213-
_logger.warning('WLSDPLY-06318', cluster_name, model_value, 'url', wioe.getLocalizedMessage(),
214-
class_name=_class_name, method_name=_method_name)
215-
new_name = None
209+
new_name = self.get_coherence_url(cluster_name, url, file_name, archive_file)
216210
elif file_name is not None:
217-
file_name = self._convert_path(file_name)
218-
try:
219-
new_name = archive_file.addCoherenceConfigFile(cluster_name, File(file_name))
220-
_logger.info('WLSDPLY-06319', cluster_name, file_name, new_name, class_name=_class_name,
221-
method_name=_method_name)
222-
except (IllegalArgumentException, WLSDeployArchiveIOException), wioe:
223-
_logger.warning('WLSDPLY-06318', cluster_name, file_name, 'file', wioe.getLocalizedMessage())
224-
new_name = None
211+
new_name = self.get_coherence_config_file(cluster_name, file_name, archive_file)
225212

226213
_logger.exiting(class_name=_class_name, method_name=_method_name, result=new_name)
227214
return new_name
228215

216+
def get_coherence_url(self, cluster_name, url, file_name, archive_file):
217+
if self._model_context.is_remote():
218+
new_name = archive_file.getCoherenceURLArchivePath(cluster_name, url)
219+
self.add_to_remote_map(file_name, new_name,
220+
WLSDeployArchive.ArchiveEntryType.COHERENCE_CONFIG.name())
221+
elif not self._model_context.skip_archive():
222+
try:
223+
new_name = archive_file.addCoherenceConfigFileFromUrl(cluster_name, url)
224+
_logger.info('WLSDPLY-06317', cluster_name, url, new_name, class_name=_class_name,
225+
method_name=_method_name)
226+
except (IllegalArgumentException, WLSDeployArchiveIOException), wioe:
227+
_logger.warning('WLSDPLY-06318', cluster_name, model_value, 'url', wioe.getLocalizedMessage(),
228+
class_name=_class_name, method_name=_method_name)
229+
new_name = None
230+
return new_name
231+
232+
def get_coherence_config_file(self, cluster_name, file_name, archive_file):
233+
if not self._model_context.is_remote():
234+
file_name = self._convert_path(file_name)
235+
if self._model_context.is_remote():
236+
new_name = archive_file.getCoherenceConfigArchivePath(file_name)
237+
self.add_to_remote_map(file_name, new_name,
238+
WLSDeployArchive.ArchiveEntryType.COHERENCE_CONFIG.name())
239+
elif not self._model_context.skip_archive():
240+
try:
241+
new_name = archive_file.addCoherenceConfigFile(cluster_name, file_name)
242+
_logger.info('WLSDPLY-06319', cluster_name, file_name, new_name, class_name=_class_name,
243+
method_name='get_coherence_config_file')
244+
except (IllegalArgumentException, WLSDeployArchiveIOException), wioe:
245+
_logger.warning('WLSDPLY-06318', cluster_name, file_name, 'file', wioe.getLocalizedMessage())
246+
new_name = None
247+
return new_name
248+
229249
def _add_active_directory(self, model_name, model_value, location):
230250
return self._add_persistence_directory(model_name, model_value, location, 'active')
231251

@@ -253,14 +273,19 @@ def _add_persistence_directory(self, model_name, model_value, location, dir_type
253273
new_name = model_value
254274
if model_value is not None:
255275
archive_file = self._model_context.get_archive_file()
256-
try:
257-
new_name = archive_file.addCoherencePersistenceDirectory(cluster_name, dir_type)
258-
_logger.info('WLSDPLY-06320', cluster_name, model_value, dir_type, class_name=_class_name,
259-
method_name=_method_name)
260-
except WLSDeployArchiveIOException, wioe:
261-
_logger.warning('WLSDPLY-06318', cluster_name, model_value, dir_type, wioe.getLocalizedMessage(),
262-
class_name=_class_name, method_name=_method_name)
263-
new_name = None
276+
if self._model_context.is_remote():
277+
new_name = archive_file.getCoherencePersistArchivePath(cluster_name, dir_type)
278+
self.add_to_remote_map(model_value, new_name,
279+
WLSDeployArchive.ArchiveEntryType.COHERENCE_PERSISTENCE_DIR.name())
280+
elif not self._model_context.skip_archive():
281+
try:
282+
new_name = archive_file.addCoherencePersistenceDirectory(cluster_name, dir_type)
283+
_logger.info('WLSDPLY-06320', cluster_name, model_value, dir_type, class_name=_class_name,
284+
method_name=_method_name)
285+
except WLSDeployArchiveIOException, wioe:
286+
_logger.warning('WLSDPLY-06318', cluster_name, model_value, dir_type, wioe.getLocalizedMessage(),
287+
class_name=_class_name, method_name=_method_name)
288+
new_name = None
264289

265290
_logger.exiting(class_name=_class_name, method_name=_method_name, result=new_name)
266291
return new_name

core/src/main/python/wlsdeploy/tool/discover/common_resources_discoverer.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ def archive_jdbc_create_script(self, jdbc_store_name, jdbc_store_dictionary):
258258
file_name = self._convert_path(jdbc_store_dictionary[model_constants.CREATE_TABLE_DDL_FILE])
259259
_logger.info('WLSDPLY-06352', jdbc_store_name, file_name, class_name=_class_name, method_name=_method_name)
260260
try:
261-
new_source_name = archive_file.addScript(File(file_name))
261+
new_source_name = archive_file.addScript(file_name)
262262
except IllegalArgumentException, iae:
263263
_logger.warning('WLSDPLY-06353', jdbc_store_name, file_name,
264264
iae.getLocalizedMessage(), class_name=_class_name,
@@ -376,14 +376,16 @@ def _add_wldf_script(self, model_name, model_value, location):
376376
_logger.entering(model_name, class_name=_class_name, method_name=_method_name)
377377
new_script_name = model_value
378378
if model_value is not None:
379-
file_name = self._convert_path(model_value)
379+
file_name = model_value
380+
if not self._model_context.is_remote():
381+
file_name = self._convert_path(model_value)
380382
_logger.info('WLSDPLY-06359', file_name, self._aliases.get_model_folder_path(location),
381383
class_name=_class_name, method_name=_method_name)
382384
archive_file = self._model_context.get_archive_file()
383385
# Set model_value to None if unable to add it to archive file
384386
modified_name = None
385387
try:
386-
modified_name = archive_file.addScript(File(file_name))
388+
modified_name = archive_file.addScript(file_name)
387389
except IllegalArgumentException, iae:
388390
_logger.warning('WLSDPLY-06360', self._aliases.get_model_folder_path(location), file_name,
389391
iae.getLocalizedMessage(), class_name=_class_name,

0 commit comments

Comments
 (0)