Skip to content

Commit 6ec5426

Browse files
rakillenddsharpe
authored andcommitted
JIRA WDT-380 Set typedef correctly for deploy (fix for ODL config) (#495)
* JIRA WDT-380 - Set the typedef correctly to support ODL configuration * JIRA WDT-380 - Set the typedef correctly for deploy to support ODL configuration * JIRA WDT-380 - Adjust whitespace
1 parent 569f940 commit 6ec5426

File tree

8 files changed

+74
-52
lines changed

8 files changed

+74
-52
lines changed

core/src/main/python/create.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@
3535
from wlsdeploy.logging.platform_logger import PlatformLogger
3636
from wlsdeploy.tool.create.rcudbinfo_helper import RcuDbInfo
3737
from wlsdeploy.tool.create.domain_creator import DomainCreator
38-
from wlsdeploy.tool.create.domain_typedef import DomainTypedef
3938
from wlsdeploy.tool.create.domain_typedef import CREATE_DOMAIN
4039
from wlsdeploy.tool.util import filter_helper
40+
from wlsdeploy.tool.util import model_context_helper
4141
from wlsdeploy.tool.util.alias_helper import AliasHelper
4242
from wlsdeploy.tool.util.archive_helper import ArchiveHelper
4343
from wlsdeploy.tool.validate.validator import Validator
@@ -48,7 +48,6 @@
4848
from wlsdeploy.util import wlst_extended
4949
from wlsdeploy.util import wlst_helper
5050
from wlsdeploy.util.cla_utils import CommandLineArgUtil
51-
from wlsdeploy.util.model_context import ModelContext
5251
from wlsdeploy.util.weblogic_helper import WebLogicHelper
5352
from wlsdeploy.tool.create import atp_helper
5453

@@ -102,19 +101,15 @@ def __process_args(args):
102101
#
103102
# Verify that the domain type is a known type and load its typedef.
104103
#
105-
domain_type = required_arg_map[CommandLineArgUtil.DOMAIN_TYPE_SWITCH]
106-
domain_typedef = DomainTypedef(_program_name, domain_type)
107-
optional_arg_map[CommandLineArgUtil.DOMAIN_TYPEDEF] = domain_typedef
104+
domain_typedef = model_context_helper.create_typedef(_program_name, required_arg_map)
108105

109-
__process_rcu_args(optional_arg_map, domain_type, domain_typedef)
106+
__process_rcu_args(optional_arg_map, domain_typedef.get_domain_type(), domain_typedef)
110107
__process_encryption_args(optional_arg_map)
111108
__process_opss_args(optional_arg_map)
112109

113110
combined_arg_map = optional_arg_map.copy()
114111
combined_arg_map.update(required_arg_map)
115-
model_context = ModelContext(_program_name, combined_arg_map)
116-
domain_typedef.set_model_context(model_context)
117-
return model_context
112+
return model_context_helper.create_context(_program_name, combined_arg_map, domain_typedef)
118113

119114

120115
def __verify_required_args_present(required_arg_map):
@@ -397,7 +392,7 @@ def main(args):
397392
cla_helper.clean_up_temp_files()
398393

399394
# create a minimal model for summary logging
400-
model_context = ModelContext(_program_name, dict())
395+
model_context = model_context_helper.create_exit_context(_program_name)
401396
tool_exit.end(model_context, exit_code)
402397

403398
variable_map = {}

core/src/main/python/deploy.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,15 @@
88
import sys
99

1010
from java.io import IOException, PrintStream
11-
from java.lang import IllegalArgumentException
1211
from java.lang import String, System
1312

1413

1514
from oracle.weblogic.deploy.deploy import DeployException
1615
from oracle.weblogic.deploy.exception import BundleAwareException
1716
from oracle.weblogic.deploy.util import CLAException
18-
from oracle.weblogic.deploy.util import FileUtils
1917
from oracle.weblogic.deploy.util import TranslateException
2018
from oracle.weblogic.deploy.util import VariableException
2119
from oracle.weblogic.deploy.util import WebLogicDeployToolingVersion
22-
from oracle.weblogic.deploy.util import WLSDeployArchive
23-
from oracle.weblogic.deploy.util import WLSDeployArchiveIOException
2420
from oracle.weblogic.deploy.validate import ValidateException
2521

2622
sys.path.append(os.path.dirname(os.path.realpath(sys.argv[0])))
@@ -35,6 +31,7 @@
3531
from wlsdeploy.tool.deploy import model_deployer
3632
from wlsdeploy.tool.validate.validator import Validator
3733
from wlsdeploy.tool.util import filter_helper
34+
from wlsdeploy.tool.util import model_context_helper
3835
from wlsdeploy.tool.util.string_output_stream import StringOutputStream
3936
from wlsdeploy.tool.util.wlst_helper import WlstHelper
4037
from wlsdeploy.util import cla_helper
@@ -44,7 +41,6 @@
4441
from wlsdeploy.util import wlst_extended
4542
from wlsdeploy.util.cla_utils import CommandLineArgUtil
4643
from wlsdeploy.util.model import Model
47-
from wlsdeploy.util.model_context import ModelContext
4844
from wlsdeploy.util.weblogic_helper import WebLogicHelper
4945

5046
wlst_extended.wlst_functions = globals()
@@ -97,8 +93,7 @@ def __process_args(args):
9793

9894
combined_arg_map = optional_arg_map.copy()
9995
combined_arg_map.update(required_arg_map)
100-
101-
return ModelContext(_program_name, combined_arg_map)
96+
return model_context_helper.create_context(_program_name, combined_arg_map)
10297

10398

10499
def __verify_required_args_present(required_arg_map):
@@ -387,7 +382,7 @@ def main(args):
387382
cla_helper.clean_up_temp_files()
388383

389384
# create a minimal model for summary logging
390-
model_context = ModelContext(_program_name, dict())
385+
model_context = model_context_helper.create_exit_context(_program_name)
391386
tool_exit.end(model_context, exit_code)
392387

393388
variable_map = {}

core/src/main/python/discover.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,30 +28,27 @@
2828
from wlsdeploy.aliases import model_constants
2929
from wlsdeploy.aliases.aliases import Aliases
3030
from wlsdeploy.aliases.location_context import LocationContext
31-
import wlsdeploy.tool.util.variable_injector as variable_injector
3231

3332
from wlsdeploy.aliases.wlst_modes import WlstModes
3433
from wlsdeploy.exception import exception_helper
3534
from wlsdeploy.logging.platform_logger import PlatformLogger
36-
from wlsdeploy.tool.create.domain_typedef import DomainTypedef
3735
from wlsdeploy.tool.discover import discoverer
3836
from wlsdeploy.tool.discover.deployments_discoverer import DeploymentsDiscoverer
3937
from wlsdeploy.tool.discover.domain_info_discoverer import DomainInfoDiscoverer
4038
from wlsdeploy.tool.discover.multi_tenant_discoverer import MultiTenantDiscoverer
4139
from wlsdeploy.tool.discover.resources_discoverer import ResourcesDiscoverer
4240
from wlsdeploy.tool.discover.topology_discoverer import TopologyDiscoverer
4341
from wlsdeploy.tool.util import filter_helper
42+
from wlsdeploy.tool.util import model_context_helper
4443
from wlsdeploy.tool.util.variable_injector import VariableInjector
4544
from wlsdeploy.tool.validate.validator import Validator
46-
from wlsdeploy.util import dictionary_utils
4745
from wlsdeploy.util import getcreds
4846
from wlsdeploy.util import model_translator
4947
from wlsdeploy.util import tool_exit
5048
from wlsdeploy.util import wlst_extended
5149
from wlsdeploy.util import wlst_helper
5250
from wlsdeploy.util.cla_utils import CommandLineArgUtil
5351
from wlsdeploy.util.model import Model
54-
from wlsdeploy.util.model_context import ModelContext
5552
from wlsdeploy.util.weblogic_helper import WebLogicHelper
5653

5754
wlst_extended.wlst_functions = globals()
@@ -90,21 +87,14 @@ def __process_args(args):
9087
cla_util = CommandLineArgUtil(_program_name, __required_arguments, __optional_arguments)
9188
required_arg_map, optional_arg_map = cla_util.process_args(args)
9289

93-
domain_type = dictionary_utils.get_element(optional_arg_map, CommandLineArgUtil.DOMAIN_TYPE_SWITCH)
94-
if domain_type is None:
95-
domain_type = 'WLS'
96-
domain_typedef = DomainTypedef(_program_name, domain_type)
97-
optional_arg_map[CommandLineArgUtil.DOMAIN_TYPEDEF] = domain_typedef
98-
9990
__verify_required_args_present(required_arg_map)
10091
__wlst_mode = __process_online_args(optional_arg_map)
10192
__process_archive_filename_arg(required_arg_map)
10293
__process_variable_filename_arg(optional_arg_map)
10394

10495
combined_arg_map = optional_arg_map.copy()
10596
combined_arg_map.update(required_arg_map)
106-
107-
return ModelContext(_program_name, combined_arg_map)
97+
return model_context_helper.create_context(_program_name, combined_arg_map)
10898

10999

110100
def __verify_required_args_present(required_arg_map):
@@ -493,7 +483,7 @@ def main(args):
493483
class_name=_class_name, method_name=_method_name)
494484

495485
# create a minimal model for summary logging
496-
model_context = ModelContext(_program_name, dict())
486+
model_context = model_context_helper.create_exit_context(_program_name)
497487
__log_and_exit(model_context, exit_code, _class_name, _method_name)
498488

499489
try:

core/src/main/python/update.py

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from oracle.weblogic.deploy.deploy import DeployException
1414
from oracle.weblogic.deploy.exception import BundleAwareException
1515
from oracle.weblogic.deploy.util import CLAException
16-
from oracle.weblogic.deploy.util import FileUtils
1716
from oracle.weblogic.deploy.util import TranslateException
1817
from oracle.weblogic.deploy.util import VariableException
1918
from oracle.weblogic.deploy.util import WebLogicDeployToolingVersion
@@ -27,24 +26,22 @@
2726
from wlsdeploy.exception import exception_helper
2827
from wlsdeploy.exception.expection_types import ExceptionType
2928
from wlsdeploy.logging.platform_logger import PlatformLogger
30-
from wlsdeploy.tool.create.domain_typedef import DomainTypedef
3129
from wlsdeploy.tool.create.domain_typedef import UPDATE_DOMAIN
3230
from wlsdeploy.tool.deploy import deployer_utils
3331
from wlsdeploy.tool.deploy import model_deployer
3432
from wlsdeploy.tool.deploy.topology_updater import TopologyUpdater
3533
from wlsdeploy.tool.validate.validator import Validator
3634
from wlsdeploy.tool.util import filter_helper
35+
from wlsdeploy.tool.util import model_context_helper
3736
from wlsdeploy.tool.util.wlst_helper import WlstHelper
3837
from wlsdeploy.tool.util.string_output_stream import StringOutputStream
3938
from wlsdeploy.util import cla_helper
40-
from wlsdeploy.util import dictionary_utils
4139
from wlsdeploy.util import getcreds
4240
from wlsdeploy.util import tool_exit
4341
from wlsdeploy.util import variables
4442
from wlsdeploy.util import wlst_extended
4543
from wlsdeploy.util.cla_utils import CommandLineArgUtil
4644
from wlsdeploy.util.model import Model
47-
from wlsdeploy.util.model_context import ModelContext
4845
from wlsdeploy.util.weblogic_helper import WebLogicHelper
4946
from wlsdeploy.util import model as model_helper
5047

@@ -96,18 +93,9 @@ def __process_args(args):
9693

9794
__process_encryption_args(optional_arg_map)
9895

99-
domain_type = dictionary_utils.get_element(optional_arg_map, CommandLineArgUtil.DOMAIN_TYPE_SWITCH)
100-
if domain_type is None:
101-
domain_type = 'WLS'
102-
domain_typedef = DomainTypedef(_program_name, domain_type)
103-
optional_arg_map[CommandLineArgUtil.DOMAIN_TYPEDEF] = domain_typedef
104-
10596
combined_arg_map = optional_arg_map.copy()
10697
combined_arg_map.update(required_arg_map)
107-
108-
model_context = ModelContext(_program_name, combined_arg_map)
109-
domain_typedef.set_model_context(model_context)
110-
return model_context
98+
return model_context_helper.create_context(_program_name, combined_arg_map)
11199

112100

113101
def __verify_required_args_present(required_arg_map):
@@ -405,7 +393,7 @@ def main(args):
405393
cla_helper.clean_up_temp_files()
406394

407395
# create a minimal model for summary logging
408-
model_context = ModelContext(_program_name, dict())
396+
model_context = model_context_helper.create_exit_context(_program_name)
409397
tool_exit.end(model_context, exit_code)
410398

411399
variable_map = {}

core/src/main/python/validate.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121
from wlsdeploy.aliases.wlst_modes import WlstModes
2222
from wlsdeploy.exception import exception_helper
2323
from wlsdeploy.logging.platform_logger import PlatformLogger
24+
from wlsdeploy.tool.util import model_context_helper
2425
from wlsdeploy.tool.validate.validator import Validator
2526
from wlsdeploy.util import cla_helper
2627
from wlsdeploy.util import tool_exit
2728
from wlsdeploy.util import wlst_helper
2829
from wlsdeploy.util.cla_utils import CommandLineArgUtil
29-
from wlsdeploy.util.model_context import ModelContext
3030
from wlsdeploy.util.weblogic_helper import WebLogicHelper
3131

3232

@@ -71,8 +71,7 @@ def __process_args(args):
7171

7272
combined_arg_map = optional_arg_map.copy()
7373
combined_arg_map.update(required_arg_map)
74-
75-
return ModelContext(_program_name, combined_arg_map)
74+
return model_context_helper.create_context(_program_name, combined_arg_map)
7675

7776

7877
def __verify_required_args_present(required_arg_map):

core/src/main/python/variable_inject.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@
2424
from wlsdeploy.aliases.wlst_modes import WlstModes
2525
from wlsdeploy.exception import exception_helper
2626
from wlsdeploy.logging.platform_logger import PlatformLogger
27+
from wlsdeploy.tool.util import model_context_helper
2728
from wlsdeploy.tool.util.variable_injector import VariableInjector
2829
from wlsdeploy.util import wlst_helper
2930
from wlsdeploy.util import model_translator
3031
from wlsdeploy.util.cla_utils import CommandLineArgUtil
3132
from wlsdeploy.util.model import Model
32-
from wlsdeploy.util.model_context import ModelContext
3333
from wlsdeploy.util.model_translator import FileToPython
3434
from wlsdeploy.util.weblogic_helper import WebLogicHelper
3535

@@ -73,8 +73,7 @@ def __process_args(args):
7373

7474
combined_arg_map = optional_arg_map.copy()
7575
combined_arg_map.update(required_arg_map)
76-
77-
return ModelContext(_program_name, combined_arg_map)
76+
return model_context_helper.create_context(_program_name, combined_arg_map)
7877

7978

8079
def __verify_required_args_present(required_arg_map):
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
"""
2+
Copyright (c) 2019, Oracle Corporation and/or its affiliates. All rights reserved.
3+
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
4+
"""
5+
from wlsdeploy.tool.create.domain_typedef import DomainTypedef
6+
from wlsdeploy.util import dictionary_utils
7+
from wlsdeploy.util.cla_utils import CommandLineArgUtil
8+
from wlsdeploy.util.model_context import ModelContext
9+
10+
11+
def create_context(program_name, combined_arg_map, domain_typedef=None):
12+
"""
13+
Create a model context object from the specified argument map, with the domain typedef set up correctly.
14+
If the domain_typedef is not specified, construct it from the argument map.
15+
:param program_name: the program name, used for logging
16+
:param combined_arg_map: all the arguments passed to the program
17+
:param domain_typedef: a domain typedef object to be used, or None
18+
:return: the new model context object
19+
"""
20+
if domain_typedef is None:
21+
domain_typedef = create_typedef(program_name, combined_arg_map)
22+
23+
combined_arg_map[CommandLineArgUtil.DOMAIN_TYPEDEF] = domain_typedef
24+
model_context = ModelContext(program_name, combined_arg_map)
25+
domain_typedef.set_model_context(model_context)
26+
return model_context
27+
28+
29+
def create_exit_context(program_name):
30+
"""
31+
Create a minimal model for use when a tool exits due to command-line parsing errors.
32+
This will provide some of the values needed for the summary logging.
33+
:param program_name: the program name, used for logging
34+
:return: the new, minimal model context object
35+
"""
36+
return create_context(program_name, dict())
37+
38+
39+
def create_typedef(program_name, argument_map):
40+
"""
41+
Create a domain typedef object for use with a model context.
42+
:param program_name: the program name, used for logging
43+
:param argument_map: the argument map that may contain a domain type
44+
:return: a typedef object
45+
"""
46+
domain_type = dictionary_utils.get_element(argument_map, CommandLineArgUtil.DOMAIN_TYPE_SWITCH)
47+
if domain_type is None:
48+
domain_type = 'WLS'
49+
return DomainTypedef(program_name, domain_type)

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ class ModelContext(object):
2626
__TEMP_DIRECTORY_TOKEN = '@@TMP@@'
2727

2828
def __init__(self, program_name, arg_map):
29+
"""
30+
Create a new model context instance.
31+
Tools should use model_context_helper.create_context(), to ensure that the typedef is initialized correctly.
32+
Unit tests should use this constructor directly, since typedef files are not deployed.
33+
:param program_name: the program name, used for logging
34+
:param arg_map: all the arguments passed to the tool
35+
"""
2936
self._program_name = program_name
3037
self._logger = platform_logger.PlatformLogger('wlsdeploy.util')
3138
self._wls_helper = WebLogicHelper(self._logger)

0 commit comments

Comments
 (0)