Skip to content

Commit e5afa34

Browse files
authored
Use ORACLE_HOME home environment variable (#636)
* JIRA WDT-19 - Use ORACLE_HOME in scripts if -oracle_home not specified; check required args in cla_utils, return single map * JIRA WDT-414 - Corrected error message arguments * JIRA WDT-414 - Use the ORACLE_HOME variable in script if -oracle_home not specified * JIRA WDT-19 - Show -oracle_home option as optional in Windows scripts * JIRA WDT-19 - Show -oracle_home option as optional in Unix scripts * JIRA WDT-19 - Correct typos * JIRA WDT-19 - Check each command argument is available before validating it; remove unused argument * JIRA WDT-19 - Prepend -oracle_home to protect trailing arguments * JIRA WDT-19 - Removed duplicate field in usage
1 parent 875a156 commit e5afa34

38 files changed

+243
-229
lines changed

core/src/main/python/compare_model.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
all_removed = []
6868
compare_msgs = sets.Set()
6969

70+
7071
def __process_args(args):
7172
"""
7273
Process the command-line arguments.
@@ -76,13 +77,9 @@ def __process_args(args):
7677
_method_name = '__process_args'
7778

7879
cla_util = CommandLineArgUtil(_program_name, __required_arguments, __optional_arguments)
79-
required_arg_map, optional_arg_map = cla_util.process_args(args, trailing_arg_count=2)
80-
81-
cla_helper.verify_required_args_present(_program_name, __required_arguments, required_arg_map)
80+
argument_map = cla_util.process_args(args, trailing_arg_count=2)
8281

83-
combined_arg_map = optional_arg_map.copy()
84-
combined_arg_map.update(required_arg_map)
85-
return ModelContext(_program_name, combined_arg_map)
82+
return ModelContext(_program_name, argument_map)
8683

8784
class ModelDiffer:
8885

core/src/main/python/create.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -88,28 +88,25 @@ def __process_args(args):
8888
"""
8989
cla_util = CommandLineArgUtil(_program_name, __required_arguments, __optional_arguments)
9090
cla_util.set_allow_multiple_models(True)
91-
required_arg_map, optional_arg_map = cla_util.process_args(args, TOOL_TYPE_CREATE)
92-
cla_helper.verify_required_args_present(_program_name, __required_arguments, required_arg_map)
93-
__process_java_home_arg(optional_arg_map)
94-
__process_domain_location_args(optional_arg_map)
91+
argument_map = cla_util.process_args(args, TOOL_TYPE_CREATE)
92+
__process_java_home_arg(argument_map)
93+
__process_domain_location_args(argument_map)
9594

9695
# don't verify that the archive is valid until it is needed.
9796
# this requirement is specific to create, other tools will verify it.
98-
cla_helper.validate_model_present(_program_name, optional_arg_map)
99-
cla_helper.validate_variable_file_exists(_program_name, optional_arg_map)
97+
cla_helper.validate_model_present(_program_name, argument_map)
98+
cla_helper.validate_variable_file_exists(_program_name, argument_map)
10099

101100
#
102101
# Verify that the domain type is a known type and load its typedef.
103102
#
104-
domain_typedef = model_context_helper.create_typedef(_program_name, optional_arg_map)
103+
domain_typedef = model_context_helper.create_typedef(_program_name, argument_map)
105104

106-
__process_rcu_args(optional_arg_map, domain_typedef.get_domain_type(), domain_typedef)
107-
cla_helper.process_encryption_args(optional_arg_map)
108-
__process_opss_args(optional_arg_map)
105+
__process_rcu_args(argument_map, domain_typedef.get_domain_type(), domain_typedef)
106+
cla_helper.process_encryption_args(argument_map)
107+
__process_opss_args(argument_map)
109108

110-
combined_arg_map = optional_arg_map.copy()
111-
combined_arg_map.update(required_arg_map)
112-
return model_context_helper.create_context(_program_name, combined_arg_map, domain_typedef)
109+
return model_context_helper.create_context(_program_name, argument_map, domain_typedef)
113110

114111

115112
def __process_java_home_arg(optional_arg_map):

core/src/main/python/deploy.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,19 +76,16 @@ def __process_args(args):
7676

7777
cla_util = CommandLineArgUtil(_program_name, __required_arguments, __optional_arguments)
7878
cla_util.set_allow_multiple_models(True)
79-
required_arg_map, optional_arg_map = cla_util.process_args(args)
79+
argument_map = cla_util.process_args(args)
8080

81-
cla_helper.verify_required_args_present(_program_name, __required_arguments, required_arg_map)
82-
cla_helper.validate_optional_archive(_program_name, optional_arg_map)
83-
cla_helper.validate_model_present(_program_name, optional_arg_map)
84-
cla_helper.validate_variable_file_exists(_program_name, optional_arg_map)
81+
cla_helper.validate_optional_archive(_program_name, argument_map)
82+
cla_helper.validate_model_present(_program_name, argument_map)
83+
cla_helper.validate_variable_file_exists(_program_name, argument_map)
8584

86-
__wlst_mode = cla_helper.process_online_args(optional_arg_map)
87-
cla_helper.process_encryption_args(optional_arg_map)
85+
__wlst_mode = cla_helper.process_online_args(argument_map)
86+
cla_helper.process_encryption_args(argument_map)
8887

89-
combined_arg_map = optional_arg_map.copy()
90-
combined_arg_map.update(required_arg_map)
91-
return model_context_helper.create_context(_program_name, combined_arg_map)
88+
return model_context_helper.create_context(_program_name, argument_map)
9289

9390

9491
def __deploy(model, model_context, aliases):

core/src/main/python/discover.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -89,19 +89,15 @@ def __process_args(args):
8989
global __wlst_mode
9090

9191
cla_util = CommandLineArgUtil(_program_name, __required_arguments, __optional_arguments)
92-
required_arg_map, optional_arg_map = cla_util.process_args(args)
92+
argument_map = cla_util.process_args(args)
9393

94-
cla_helper.verify_required_args_present(_program_name, __required_arguments, required_arg_map)
95-
__wlst_mode = cla_helper.process_online_args(optional_arg_map)
94+
__wlst_mode = cla_helper.process_online_args(argument_map)
95+
__process_target_arg(argument_map)
96+
__process_archive_filename_arg(argument_map)
97+
__process_variable_filename_arg(argument_map)
98+
__process_java_home(argument_map)
9699

97-
__process_target_arg(optional_arg_map)
98-
__process_archive_filename_arg(required_arg_map)
99-
__process_variable_filename_arg(optional_arg_map)
100-
__process_java_home(optional_arg_map)
101-
102-
combined_arg_map = optional_arg_map.copy()
103-
combined_arg_map.update(required_arg_map)
104-
return model_context_helper.create_context(_program_name, combined_arg_map)
100+
return model_context_helper.create_context(_program_name, argument_map)
105101

106102
def __process_target_arg(optional_arg_map):
107103

core/src/main/python/encrypt.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
from wlsdeploy.logging.platform_logger import PlatformLogger
2929
from wlsdeploy.tool.encrypt import encryption_utils
3030
from wlsdeploy.tool.util.alias_helper import AliasHelper
31-
from wlsdeploy.util import cla_helper
3231
from wlsdeploy.util import getcreds
3332
from wlsdeploy.util import variables as variable_helper
3433
from wlsdeploy.util.cla_utils import CommandLineArgUtil
@@ -63,28 +62,25 @@ def __process_args(args):
6362
_method_name = '__process_args'
6463

6564
cla_util = CommandLineArgUtil(_program_name, __required_arguments, __optional_arguments)
66-
required_arg_map, optional_arg_map = cla_util.process_args(args)
65+
argument_map = cla_util.process_args(args)
6766

68-
cla_helper.verify_required_args_present(_program_name, __required_arguments, required_arg_map)
69-
__validate_mode_args(optional_arg_map)
70-
__process_passphrase_arg(optional_arg_map)
67+
__validate_mode_args(argument_map)
68+
__process_passphrase_arg(argument_map)
7169

7270
#
7371
# Prompt for the password to encrypt if the -manual switch was specified
7472
#
75-
if CommandLineArgUtil.ENCRYPT_MANUAL_SWITCH in optional_arg_map and \
76-
CommandLineArgUtil.ONE_PASS_SWITCH not in optional_arg_map:
73+
if CommandLineArgUtil.ENCRYPT_MANUAL_SWITCH in argument_map and \
74+
CommandLineArgUtil.ONE_PASS_SWITCH not in argument_map:
7775
try:
7876
pwd = getcreds.getpass('WLSDPLY-04200')
7977
except IOException, ioe:
8078
ex = exception_helper.create_encryption_exception('WLSDPLY-04201', ioe.getLocalizedMessage(), error=ioe)
8179
__logger.throwing(ex, class_name=_class_name, method_name=_method_name)
8280
raise ex
83-
optional_arg_map[CommandLineArgUtil.ONE_PASS_SWITCH] = String(pwd)
81+
argument_map[CommandLineArgUtil.ONE_PASS_SWITCH] = String(pwd)
8482

85-
combined_arg_map = optional_arg_map.copy()
86-
combined_arg_map.update(required_arg_map)
87-
model_context = ModelContext(_program_name, combined_arg_map)
83+
model_context = ModelContext(_program_name, argument_map)
8884
return model_context
8985

9086

core/src/main/python/extract_resource.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,16 @@ def __process_args(args):
5757
"""
5858
cla_util = CommandLineArgUtil(_program_name, __required_arguments, __optional_arguments)
5959
cla_util.set_allow_multiple_models(True)
60-
required_arg_map, optional_arg_map = cla_util.process_args(args, TOOL_TYPE_EXTRACT)
60+
argument_map = cla_util.process_args(args, TOOL_TYPE_EXTRACT)
6161

62-
cla_helper.verify_required_args_present(_program_name, __required_arguments, required_arg_map)
63-
cla_helper.validate_optional_archive(_program_name, optional_arg_map)
62+
cla_helper.validate_optional_archive(_program_name, argument_map)
6463

6564
# determine if the model file was passed separately or requires extraction from the archive.
66-
cla_helper.validate_model_present(_program_name, optional_arg_map)
67-
cla_helper.validate_variable_file_exists(_program_name, optional_arg_map)
68-
cla_helper.process_encryption_args(optional_arg_map)
65+
cla_helper.validate_model_present(_program_name, argument_map)
66+
cla_helper.validate_variable_file_exists(_program_name, argument_map)
67+
cla_helper.process_encryption_args(argument_map)
6968

70-
combined_arg_map = optional_arg_map.copy()
71-
combined_arg_map.update(required_arg_map)
72-
return model_context_helper.create_context(_program_name, combined_arg_map)
69+
return model_context_helper.create_context(_program_name, argument_map)
7370

7471

7572
def __extract_resource(model, model_context, aliases):

core/src/main/python/model_help.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,12 @@ def __process_args(args):
5151
_method_name = '__process_args'
5252

5353
cla_util = CommandLineArgUtil(_program_name, __required_arguments, __optional_arguments)
54-
required_arg_map, optional_arg_map = cla_util.process_args(args, trailing_arg_count=1)
55-
56-
cla_helper.verify_required_args_present(_program_name, __required_arguments, required_arg_map)
57-
58-
combined_arg_map = optional_arg_map.copy()
59-
combined_arg_map.update(required_arg_map)
54+
argument_map = cla_util.process_args(args, trailing_arg_count=1)
6055

6156
# zero or one output type arguments should be set
6257
found = False
6358
for key in __output_types:
64-
if key in combined_arg_map:
59+
if key in argument_map:
6560
if found:
6661
types_text = ', '.join(__output_types)
6762
ex = exception_helper.create_cla_exception('WLSDPLY-10100', types_text)
@@ -70,7 +65,7 @@ def __process_args(args):
7065
raise ex
7166
found = True
7267

73-
return model_context_helper.create_context(_program_name, combined_arg_map)
68+
return model_context_helper.create_context(_program_name, argument_map)
7469

7570

7671
def print_help(model_path, model_context):

core/src/main/python/prepare_model.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
from oracle.weblogic.deploy.util import VariableException
2828
from oracle.weblogic.deploy.util import WebLogicDeployToolingVersion
2929
from oracle.weblogic.deploy.validate import ValidateException
30+
31+
from oracle.weblogic.deploy.aliases import AliasException
3032
from wlsdeploy.aliases import model_constants
3133
from wlsdeploy.aliases.aliases import Aliases
3234
from wlsdeploy.aliases.location_context import LocationContext
@@ -82,32 +84,29 @@ def __process_args(args, logger):
8284
_method_name = '__process_args'
8385

8486
cla_util = CommandLineArgUtil(_program_name, __required_arguments, __optional_arguments)
85-
required_arg_map, optional_arg_map = cla_util.process_args(args)
87+
argument_map = cla_util.process_args(args)
8688

87-
cla_helper.verify_required_args_present(_program_name, __required_arguments, required_arg_map)
89+
__process_target_arg(argument_map, logger)
8890

89-
__process_target_arg(optional_arg_map, required_arg_map, logger)
91+
return ModelContext(_program_name, argument_map)
9092

91-
combined_arg_map = optional_arg_map.copy()
92-
combined_arg_map.update(required_arg_map)
93-
return ModelContext(_program_name, combined_arg_map)
9493

95-
def __process_target_arg(optional_arg_map, required_arg_map, logger):
94+
def __process_target_arg(argument_map, logger):
9695

9796
_method_name = '__process_target_arg'
9897

9998
# if -target is specified -output_dir is required
100-
output_dir = required_arg_map[CommandLineArgUtil.OUTPUT_DIR_SWITCH]
99+
output_dir = argument_map[CommandLineArgUtil.OUTPUT_DIR_SWITCH]
101100
if output_dir is None or os.path.isdir(output_dir) is False:
102101
if not os.path.isdir(output_dir):
103102
ex = exception_helper.create_cla_exception('WLSDPLY-01642', output_dir)
104103
logger.throwing(ex, class_name=_class_name, method_name=_method_name)
105104
raise ex
106105

107106
# Set the -variable_file parameter if not present with default
108-
if CommandLineArgUtil.VARIABLE_FILE_SWITCH not in optional_arg_map:
109-
optional_arg_map[CommandLineArgUtil.VARIABLE_FILE_SWITCH] = os.path.join(output_dir,
110-
"k8s_variable.properties")
107+
if CommandLineArgUtil.VARIABLE_FILE_SWITCH not in argument_map:
108+
argument_map[CommandLineArgUtil.VARIABLE_FILE_SWITCH] = os.path.join(output_dir,
109+
"k8s_variable.properties")
111110

112111
class PrepareModel:
113112
"""
@@ -348,7 +347,7 @@ def __substitute_password_with_token(self, model_path, attribute_name, validatio
348347
if tokens_length > 1:
349348
# For AdminPassword
350349
if model_path_tokens[0] == 'domainInfo:' and model_path_tokens[1] == '':
351-
password_name = "@@SECRET:@@DOAMIN-UID@@-weblogic-credentials:%s@@" % (attribute_name.lower())
350+
password_name = "@@SECRET:@@DOMAIN-UID@@-weblogic-credentials:%s@@" % (attribute_name.lower())
352351
self.cache[attribute_name] = ''
353352
else:
354353
password_name = target_configuration_helper.format_as_secret(variable_name)

core/src/main/python/update.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -79,19 +79,16 @@ def __process_args(args):
7979

8080
cla_util = CommandLineArgUtil(_program_name, __required_arguments, __optional_arguments)
8181
cla_util.set_allow_multiple_models(True)
82-
required_arg_map, optional_arg_map = cla_util.process_args(args)
82+
argument_map = cla_util.process_args(args)
8383

84-
cla_helper.verify_required_args_present(_program_name, __required_arguments, required_arg_map)
85-
cla_helper.validate_optional_archive(_program_name, optional_arg_map)
86-
cla_helper.validate_model_present(_program_name, optional_arg_map)
87-
cla_helper.validate_variable_file_exists(_program_name, optional_arg_map)
84+
cla_helper.validate_optional_archive(_program_name, argument_map)
85+
cla_helper.validate_model_present(_program_name, argument_map)
86+
cla_helper.validate_variable_file_exists(_program_name, argument_map)
8887

89-
__wlst_mode = cla_helper.process_online_args(optional_arg_map)
90-
cla_helper.process_encryption_args(optional_arg_map)
88+
__wlst_mode = cla_helper.process_online_args(argument_map)
89+
cla_helper.process_encryption_args(argument_map)
9190

92-
combined_arg_map = optional_arg_map.copy()
93-
combined_arg_map.update(required_arg_map)
94-
return model_context_helper.create_context(_program_name, combined_arg_map)
91+
return model_context_helper.create_context(_program_name, argument_map)
9592

9693

9794
def __update(model, model_context, aliases):

core/src/main/python/validate.py

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -61,31 +61,11 @@ def __process_args(args):
6161
"""
6262
cla_util = CommandLineArgUtil(_program_name, __required_arguments, __optional_arguments)
6363
cla_util.set_allow_multiple_models(True)
64-
required_arg_map, optional_arg_map = cla_util.process_args(args)
64+
argument_map = cla_util.process_args(args)
6565

66-
__verify_required_args_present(required_arg_map)
67-
__process_model_args(optional_arg_map)
66+
__process_model_args(argument_map)
6867

69-
combined_arg_map = optional_arg_map.copy()
70-
combined_arg_map.update(required_arg_map)
71-
return model_context_helper.create_context(_program_name, combined_arg_map)
72-
73-
74-
def __verify_required_args_present(required_arg_map):
75-
"""
76-
Verify that the required args are present.
77-
:param required_arg_map: the required arguments map
78-
:raises CLAException: if one or more of the required arguments are missing
79-
"""
80-
_method_name = '__verify_required_args_present'
81-
82-
for req_arg in __required_arguments:
83-
if req_arg not in required_arg_map:
84-
ex = exception_helper.create_cla_exception('WLSDPLY-20005', _program_name, req_arg)
85-
ex.setExitCode(CommandLineArgUtil.USAGE_ERROR_EXIT_CODE)
86-
__logger.throwing(ex, class_name=_class_name, method_name=_method_name)
87-
raise ex
88-
return
68+
return model_context_helper.create_context(_program_name, argument_map)
8969

9070

9171
def __process_model_args(optional_arg_map):

core/src/main/python/variable_inject.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,15 @@ def __process_args(args):
6060
global __wlst_mode
6161

6262
cla_util = CommandLineArgUtil(_program_name, __required_arguments, __optional_arguments)
63-
required_arg_map, optional_arg_map = cla_util.process_args(args)
64-
65-
cla_helper.verify_required_args_present(_program_name, __required_arguments, required_arg_map)
63+
argument_map = cla_util.process_args(args)
6664

6765
# determine if the model file was passed separately or requires extraction from the archive.
68-
cla_helper.validate_model_present(_program_name, optional_arg_map)
69-
__process_injector_file(optional_arg_map)
70-
__process_keywords_file(optional_arg_map)
71-
__process_properties_file(optional_arg_map)
72-
73-
combined_arg_map = optional_arg_map.copy()
74-
combined_arg_map.update(required_arg_map)
75-
return model_context_helper.create_context(_program_name, combined_arg_map)
66+
cla_helper.validate_model_present(_program_name, argument_map)
67+
__process_injector_file(argument_map)
68+
__process_keywords_file(argument_map)
69+
__process_properties_file(argument_map)
70+
71+
return model_context_helper.create_context(_program_name, argument_map)
7672

7773

7874
def __process_injector_file(optional_arg_map):

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

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -133,25 +133,6 @@ def validate_variable_file_exists(program_name, optional_arg_map):
133133
return
134134

135135

136-
def verify_required_args_present(program_name, required_arguments, required_arg_map):
137-
"""
138-
Verify that the required args are present.
139-
:param program_name: the program name, for logging
140-
:param required_arguments: the required arguments to be checked
141-
:param required_arg_map: the required arguments map
142-
:raises CLAException: if one or more of the required arguments are missing
143-
"""
144-
_method_name = '__verify_required_args_present'
145-
146-
for req_arg in required_arguments:
147-
if req_arg not in required_arg_map:
148-
ex = exception_helper.create_cla_exception('WLSDPLY-20005', program_name, req_arg)
149-
ex.setExitCode(CommandLineArgUtil.USAGE_ERROR_EXIT_CODE)
150-
__logger.throwing(ex, class_name=_class_name, method_name=_method_name)
151-
raise ex
152-
return
153-
154-
155136
def process_encryption_args(optional_arg_map):
156137
"""
157138
If the user is using model encryption, get the passphrase from stdin, and put it in the argument map.

0 commit comments

Comments
 (0)