Skip to content

Commit bd0f35e

Browse files
Merge branch 'master' into Issue#96-online-discover-domain
2 parents ce3b3e1 + fcab22f commit bd0f35e

31 files changed

+3213
-23
lines changed

README.md

Lines changed: 232 additions & 0 deletions
Large diffs are not rendered by default.

core/src/main/python/discover.py

Lines changed: 46 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,24 @@
1212
from java.lang import IllegalArgumentException
1313
from java.lang import IllegalStateException
1414
from java.lang import String
15-
1615
from oracle.weblogic.deploy.aliases import AliasException
1716
from oracle.weblogic.deploy.discover import DiscoverException
1817
from oracle.weblogic.deploy.util import CLAException
1918
from oracle.weblogic.deploy.util import FileUtils
2019
from oracle.weblogic.deploy.util import PyWLSTException
2120
from oracle.weblogic.deploy.util import TranslateException
22-
from oracle.weblogic.deploy.util import WebLogicDeployToolingVersion
2321
from oracle.weblogic.deploy.util import WLSDeployArchive
2422
from oracle.weblogic.deploy.util import WLSDeployArchiveIOException
23+
from oracle.weblogic.deploy.util import WebLogicDeployToolingVersion
2524
from oracle.weblogic.deploy.validate import ValidateException
2625

2726
sys.path.append(os.path.dirname(os.path.realpath(sys.argv[0])))
2827

2928
from wlsdeploy.aliases import model_constants
3029
from wlsdeploy.aliases.aliases import Aliases
3130
from wlsdeploy.aliases.location_context import LocationContext
31+
import wlsdeploy.tool.util.variable_injector as variable_injector
32+
3233
from wlsdeploy.aliases.wlst_modes import WlstModes
3334
from wlsdeploy.exception import exception_helper
3435
from wlsdeploy.logging.platform_logger import PlatformLogger
@@ -39,8 +40,9 @@
3940
from wlsdeploy.tool.discover.multi_tenant_discoverer import MultiTenantDiscoverer
4041
from wlsdeploy.tool.discover.resources_discoverer import ResourcesDiscoverer
4142
from wlsdeploy.tool.discover.topology_discoverer import TopologyDiscoverer
42-
from wlsdeploy.tool.validate.validator import Validator
4343
from wlsdeploy.tool.util import filter_helper
44+
from wlsdeploy.tool.util.variable_injector import VariableInjector
45+
from wlsdeploy.tool.validate.validator import Validator
4446
from wlsdeploy.util import wlst_helper
4547
from wlsdeploy.util import model_translator
4648
from wlsdeploy.util.cla_utils import CommandLineArgUtil
@@ -61,8 +63,9 @@
6163

6264
__optional_arguments = [
6365
# Used by shell script to locate WLST
64-
CommandLineArgUtil.DOMAIN_TYPE_SWITCH,
6566
CommandLineArgUtil.MODEL_FILE_SWITCH,
67+
CommandLineArgUtil.DOMAIN_TYPE_SWITCH,
68+
CommandLineArgUtil.VARIABLE_PROPERTIES_FILE_SWITCH,
6669
CommandLineArgUtil.ADMIN_URL_SWITCH,
6770
CommandLineArgUtil.ADMIN_USER_SWITCH,
6871
CommandLineArgUtil.ADMIN_PASS_SWITCH
@@ -83,6 +86,7 @@ def __process_args(args):
8386
__verify_required_args_present(required_arg_map)
8487
__wlst_mode = __process_online_args(optional_arg_map)
8588
__process_archive_filename_arg(required_arg_map)
89+
__process_variable_filename_arg(optional_arg_map)
8690

8791
combined_arg_map = optional_arg_map.copy()
8892
combined_arg_map.update(required_arg_map)
@@ -162,6 +166,28 @@ def __process_archive_filename_arg(required_arg_map):
162166
return
163167

164168

169+
def __process_variable_filename_arg(optional_arg_map):
170+
"""
171+
If the variable filename argument is present, the required model variable injector json file must exist in
172+
the WLSDEPLOY lib directory.
173+
:param optional_arg_map: containing the variable file name
174+
:raises: CLAException: if this argument is present but the model variable injector json does not exist
175+
"""
176+
_method_name = '__process_variable_filename_arg'
177+
178+
if CommandLineArgUtil.VARIABLE_PROPERTIES_FILE_SWITCH in optional_arg_map:
179+
variable_injector_file_name = variable_injector.get_default_variable_injector_file_name()
180+
try:
181+
FileUtils.validateExistingFile(variable_injector_file_name)
182+
except IllegalArgumentException, ie:
183+
ex = exception_helper.create_cla_exception('WLSDPLY-06021', optional_arg_map[
184+
CommandLineArgUtil.VARIABLE_PROPERTIES_FILE_SWITCH], variable_injector_file_name,
185+
ie.getLocalizedMessage(), error=ie)
186+
__logger.throwing(ex, class_name=_class_name, method_name=_method_name)
187+
raise ex
188+
return
189+
190+
165191
def __discover(model_context, aliases):
166192
"""
167193
Populate the model from the domain.
@@ -210,7 +236,7 @@ def _add_domain_name(location, aliases):
210236
location.add_name_token(aliases.get_name_token(location), domain_name)
211237
__logger.info('WLSDPLY-06022', domain_name, class_name=_class_name, method_name=_method_name)
212238
else:
213-
de = exception_helper.create_discover_exception('WLSDPLY-WLSDPLY-06021')
239+
de = exception_helper.create_discover_exception('WLSDPLY-WLSDPLY-06023')
214240
__logger.throwing(class_name=_class_name, method_name=_method_name, error=de)
215241
raise de
216242

@@ -370,7 +396,7 @@ def __persist_model(model, model_context):
370396
if not model_file.delete():
371397
model_file.deleteOnExit()
372398
except (WLSDeployArchiveIOException, IllegalArgumentException), arch_ex:
373-
ex = exception_helper.create_discover_exception('WLSDPLY-06009', model_file.getAbsolutePath(),
399+
ex = exception_helper.create_discover_exception('WLSDPLY-20023', model_file.getAbsolutePath(),
374400
model_file_name, arch_ex.getLocalizedMessage(),
375401
error=arch_ex)
376402
__logger.throwing(ex, class_name=_class_name, method_name=_method_name)
@@ -394,14 +420,21 @@ def __check_and_customize_model(model, model_context, aliases):
394420
if filter_helper.apply_filters(model.get_model(), "discover"):
395421
__logger.info('WLSDPLY-06014', _class_name=_class_name, method_name=_method_name)
396422

423+
inserted, variable_model, variable_file_name = VariableInjector(_program_name, model.get_model(), model_context,
424+
WebLogicHelper(
425+
__logger).get_actual_weblogic_version()).\
426+
inject_variables_keyword_file()
427+
if inserted:
428+
model = Model(variable_model)
397429
try:
398430
validator = Validator(model_context, wlst_mode=__wlst_mode, aliases=aliases)
399431

400432
# no variables are generated by the discover tool
401-
validator.validate_in_tool_mode(model.get_model(), variables_file_name=None,
433+
validator.validate_in_tool_mode(model.get_model(), variables_file_name=variable_file_name,
402434
archive_file_name=model_context.get_archive_file_name())
403435
except ValidateException, ex:
404436
__logger.warning('WLSDPLY-06015', ex.getLocalizedMessage(), class_name=_class_name, method_name=_method_name)
437+
return model
405438

406439

407440
def __log_and_exit(exit_code, class_name, method_name):
@@ -412,6 +445,7 @@ def __log_and_exit(exit_code, class_name, method_name):
412445
:param method_name: the method name to pass to the logger
413446
"""
414447
__logger.exiting(result=exit_code, class_name=class_name, method_name=method_name)
448+
415449
sys.exit(exit_code)
416450

417451

@@ -458,13 +492,14 @@ def main(args):
458492
model_context.get_domain_home(), ex.getLocalizedMessage(),
459493
error=ex, class_name=_class_name, method_name=_method_name)
460494
__log_and_exit(CommandLineArgUtil.PROG_ERROR_EXIT_CODE, _class_name, _method_name)
461-
462-
__check_and_customize_model(model, model_context, aliases)
463-
495+
496+
model = __check_and_customize_model(model, model_context)
497+
464498
try:
465499
__persist_model(model, model_context)
500+
466501
except TranslateException, ex:
467-
__logger.severe('WLSDPLY-06012', _program_name, model_context.get_archive_file_name(), ex.getLocalizedMessage(),
502+
__logger.severe('WLSDPLY-20024', _program_name, model_context.get_archive_file_name(), ex.getLocalizedMessage(),
468503
error=ex, class_name=_class_name, method_name=_method_name)
469504
__log_and_exit(CommandLineArgUtil.PROG_ERROR_EXIT_CODE, _class_name, _method_name)
470505

core/src/main/python/encrypt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def __encrypt_model_and_variables(model_context):
190190

191191
if variable_change_count > 0:
192192
try:
193-
variable_helper.write_variables(variables, variable_file)
193+
variable_helper.write_variables(_program_name, variables, variable_file)
194194
__logger.info('WLSDPLY-04209', _program_name, variable_change_count, variable_file,
195195
class_name=_class_name, method_name=_method_name)
196196
except VariableException, ve:

0 commit comments

Comments
 (0)