|
13 | 13 | from java.lang import IllegalStateException
|
14 | 14 | from oracle.weblogic.deploy.aliases import AliasException
|
15 | 15 | from oracle.weblogic.deploy.discover import DiscoverException
|
| 16 | +from oracle.weblogic.deploy.json import JsonException |
16 | 17 | from oracle.weblogic.deploy.util import CLAException
|
17 | 18 | from oracle.weblogic.deploy.util import FileUtils
|
| 19 | +from oracle.weblogic.deploy.util import PyOrderedDict |
18 | 20 | from oracle.weblogic.deploy.util import PyWLSTException
|
19 | 21 | from oracle.weblogic.deploy.util import TranslateException
|
20 | 22 | from oracle.weblogic.deploy.util import WLSDeployArchive
|
|
30 | 32 | from wlsdeploy.aliases.wlst_modes import WlstModes
|
31 | 33 | from wlsdeploy.exception import exception_helper
|
32 | 34 | from wlsdeploy.exception.expection_types import ExceptionType
|
| 35 | +from wlsdeploy.json import json_translator |
33 | 36 | from wlsdeploy.logging.platform_logger import PlatformLogger
|
34 | 37 | from wlsdeploy.tool.discover import discoverer
|
35 | 38 | from wlsdeploy.tool.discover.deployments_discoverer import DeploymentsDiscoverer
|
|
62 | 65 | __logger = PlatformLogger(discoverer.get_discover_logger_name())
|
63 | 66 | __wlst_mode = WlstModes.OFFLINE
|
64 | 67 |
|
| 68 | +_store_result_environment_variable = '__WLSDEPLOY_STORE_RESULT__' |
| 69 | + |
65 | 70 | __required_arguments = [
|
66 | 71 | CommandLineArgUtil.ORACLE_HOME_SWITCH,
|
67 | 72 | CommandLineArgUtil.DOMAIN_HOME_SWITCH
|
@@ -137,6 +142,11 @@ def __process_archive_filename_arg(argument_map):
|
137 | 142 |
|
138 | 143 | if CommandLineArgUtil.SKIP_ARCHIVE_FILE_SWITCH in argument_map or CommandLineArgUtil.REMOTE_SWITCH in argument_map:
|
139 | 144 | archive_file = WLSDeployArchive.noArchiveFile()
|
| 145 | + if CommandLineArgUtil.ARCHIVE_FILE_SWITCH in argument_map: |
| 146 | + ex = exception_helper.create_cla_exception(CommandLineArgUtil.ARG_VALIDATION_ERROR_EXIT_CODE, |
| 147 | + 'WLSDPLY-06033') |
| 148 | + __logger.throwing(ex, class_name=_class_name, method_name=_method_name) |
| 149 | + raise ex |
140 | 150 | else:
|
141 | 151 | archive_file_name = argument_map[CommandLineArgUtil.ARCHIVE_FILE_SWITCH]
|
142 | 152 | archive_dir_name = path_utils.get_parent_directory(archive_file_name)
|
@@ -245,20 +255,6 @@ def __discover(model_context, aliases, credential_injector, helper):
|
245 | 255 | raise ex
|
246 | 256 | __disconnect_domain(helper)
|
247 | 257 |
|
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 '' |
262 | 258 | return model
|
263 | 259 |
|
264 | 260 |
|
@@ -512,10 +508,36 @@ def __check_and_customize_model(model, model_context, aliases, credential_inject
|
512 | 508 |
|
513 | 509 |
|
514 | 510 | def __remote_report(model_context):
|
| 511 | + _method_name = '__remote_report' |
| 512 | + |
515 | 513 | if not model_context.is_remote():
|
516 | 514 | return
|
517 |
| - print '' |
| 515 | + |
518 | 516 | remote_map = discoverer.remote_dict
|
| 517 | + |
| 518 | + # write JSON output if the __WLSDEPLOY_STORE_RESULT__ environment variable is set. |
| 519 | + # write to the file before the stdout so any logging messages come first. |
| 520 | + if os.environ.has_key(_store_result_environment_variable): |
| 521 | + store_path = os.environ.get(_store_result_environment_variable) |
| 522 | + __logger.info('WLSDPLY-06034', store_path, class_name=_class_name, method_name=_method_name) |
| 523 | + missing_archive_entries = [] |
| 524 | + for key in remote_map: |
| 525 | + archive_map = remote_map[key] |
| 526 | + missing_archive_entries.append({ |
| 527 | + 'path': key, |
| 528 | + 'sourceFile': archive_map[discoverer.REMOTE_ARCHIVE_PATH], |
| 529 | + 'type': archive_map[discoverer.REMOTE_TYPE] |
| 530 | + }) |
| 531 | + result_root = PyOrderedDict() |
| 532 | + result_root['missingArchiveEntries'] = missing_archive_entries |
| 533 | + try: |
| 534 | + json_translator.PythonToJson(result_root).write_to_json_file(store_path) |
| 535 | + except JsonException, ex: |
| 536 | + __logger.warning('WLSDPLY-06035', _store_result_environment_variable, ex.getLocalizedMessage(), |
| 537 | + class_name=_class_name, method_name=_method_name) |
| 538 | + |
| 539 | + # write to stdout |
| 540 | + print '' |
519 | 541 | if len(remote_map) == 0:
|
520 | 542 | message = exception_helper.get_message('WLSDPLY-06030')
|
521 | 543 | else:
|
|
0 commit comments