|
88 | 88 | CommandLineArgUtil.ADMIN_PASS_ENV_SWITCH,
|
89 | 89 | CommandLineArgUtil.TARGET_MODE_SWITCH,
|
90 | 90 | CommandLineArgUtil.OUTPUT_DIR_SWITCH,
|
| 91 | + CommandLineArgUtil.DISCOVER_PASSWORDS_SWITCH, |
| 92 | + CommandLineArgUtil.PASSPHRASE_SWITCH, |
| 93 | + CommandLineArgUtil.PASSPHRASE_ENV_SWITCH, |
| 94 | + CommandLineArgUtil.PASSPHRASE_FILE_SWITCH, |
91 | 95 | CommandLineArgUtil.TARGET_SWITCH,
|
92 | 96 | CommandLineArgUtil.REMOTE_SWITCH,
|
93 | 97 | CommandLineArgUtil.SSH_HOST_SWITCH,
|
@@ -125,7 +129,9 @@ def __process_args(args):
|
125 | 129 | __process_java_home(argument_map)
|
126 | 130 | __process_domain_home(argument_map, __wlst_mode)
|
127 | 131 |
|
128 |
| - return model_context_helper.create_context(_program_name, argument_map) |
| 132 | + model_context = model_context_helper.create_context(_program_name, argument_map) |
| 133 | + __validate_discover_passwords_args(model_context, argument_map) |
| 134 | + return model_context |
129 | 135 |
|
130 | 136 |
|
131 | 137 | def __process_model_arg(argument_map):
|
@@ -252,6 +258,50 @@ def __process_domain_home(arg_map, wlst_mode):
|
252 | 258 | full_path = cla_utils.validate_domain_home_arg(domain_home)
|
253 | 259 | arg_map[CommandLineArgUtil.DOMAIN_HOME_SWITCH] = full_path
|
254 | 260 |
|
| 261 | + |
| 262 | +def __validate_discover_passwords_args(model_context, argument_map): |
| 263 | + _method_name = '__validate_discover_passwords_args' |
| 264 | + if model_context.is_discover_passwords(): |
| 265 | + if model_context.is_remote(): |
| 266 | + ex = exception_helper.create_cla_exception(ExitCode.ARG_VALIDATION_ERROR, 'WLSDPLY-06050', |
| 267 | + _program_name, CommandLineArgUtil.DISCOVER_PASSWORDS_SWITCH, |
| 268 | + CommandLineArgUtil.REMOTE_SWITCH) |
| 269 | + __logger.throwing(ex, class_name=_class_name, method_name=_method_name) |
| 270 | + raise ex |
| 271 | + if model_context.is_encrypt_discovered_passwords(): |
| 272 | + if model_context.get_encryption_passphrase() is None: |
| 273 | + ex = exception_helper.create_cla_exception(ExitCode.ARG_VALIDATION_ERROR, 'WLSDPLY-06051', |
| 274 | + _program_name, CommandLineArgUtil.DISCOVER_PASSWORDS_SWITCH, |
| 275 | + CommandLineArgUtil.PASSPHRASE_ENV_SWITCH, CommandLineArgUtil.PASSPHRASE_FILE_SWITCH) |
| 276 | + __logger.throwing(ex, class_name=_class_name, method_name=_method_name) |
| 277 | + raise ex |
| 278 | + else: |
| 279 | + if model_context.get_encryption_passphrase() is not None: |
| 280 | + if CommandLineArgUtil.PASSPHRASE_ENV_SWITCH in argument_map: |
| 281 | + bad_arg = CommandLineArgUtil.PASSPHRASE_ENV_SWITCH |
| 282 | + elif CommandLineArgUtil.PASSPHRASE_FILE_SWITCH in argument_map: |
| 283 | + bad_arg = CommandLineArgUtil.PASSPHRASE_FILE_SWITCH |
| 284 | + else: |
| 285 | + bad_arg = CommandLineArgUtil.PASSPHRASE_SWITCH |
| 286 | + |
| 287 | + ex = exception_helper.create_cla_exception(ExitCode.ARG_VALIDATION_ERROR, 'WLSDPLY-06052', |
| 288 | + _program_name, CommandLineArgUtil.DISCOVER_PASSWORDS_SWITCH, bad_arg) |
| 289 | + __logger.throwing(ex, class_name=_class_name, method_name=_method_name) |
| 290 | + raise ex |
| 291 | + else: |
| 292 | + if model_context.get_encryption_passphrase() is not None: |
| 293 | + if CommandLineArgUtil.PASSPHRASE_ENV_SWITCH in argument_map: |
| 294 | + bad_arg = CommandLineArgUtil.PASSPHRASE_ENV_SWITCH |
| 295 | + elif CommandLineArgUtil.PASSPHRASE_FILE_SWITCH in argument_map: |
| 296 | + bad_arg = CommandLineArgUtil.PASSPHRASE_FILE_SWITCH |
| 297 | + else: |
| 298 | + bad_arg = CommandLineArgUtil.PASSPHRASE_SWITCH |
| 299 | + |
| 300 | + ex = exception_helper.create_cla_exception(ExitCode.ARG_VALIDATION_ERROR, 'WLSDPLY-06056', |
| 301 | + _program_name, bad_arg, CommandLineArgUtil.DISCOVER_PASSWORDS_SWITCH) |
| 302 | + __logger.throwing(ex, class_name=_class_name, method_name=_method_name) |
| 303 | + raise ex |
| 304 | + |
255 | 305 | def __discover(model_context, aliases, credential_injector, helper, extra_tokens):
|
256 | 306 | """
|
257 | 307 | Populate the model from the domain.
|
@@ -636,12 +686,19 @@ def main(model_context):
|
636 | 686 | if _exit_code == ExitCode.OK:
|
637 | 687 | aliases = Aliases(model_context, wlst_mode=__wlst_mode, exception_type=ExceptionType.DISCOVER)
|
638 | 688 | credential_injector = None
|
| 689 | + |
639 | 690 | if model_context.get_variable_file() is not None or model_context.get_target() is not None:
|
640 | 691 | credential_injector = CredentialInjector(_program_name, model_context, aliases)
|
641 |
| - |
642 |
| - __logger.info('WLSDPLY-06025', class_name=_class_name, method_name=_method_name) |
| 692 | + if model_context.is_discover_passwords(): |
| 693 | + password_key = 'WLSDPLY-06055' |
| 694 | + else: |
| 695 | + password_key = 'WLSDPLY-06025' |
643 | 696 | else:
|
644 |
| - __logger.info('WLSDPLY-06024', class_name=_class_name, method_name=_method_name) |
| 697 | + if model_context.is_discover_passwords(): |
| 698 | + password_key = 'WLSDPLY-06054' |
| 699 | + else: |
| 700 | + password_key = 'WLSDPLY-06024' |
| 701 | + __logger.info(password_key, class_name=_class_name, method_name=_method_name) |
645 | 702 |
|
646 | 703 | extra_tokens = {}
|
647 | 704 | try:
|
|
0 commit comments