Skip to content

Commit 909e31a

Browse files
rakillenddsharpe
authored andcommitted
JIRA WDT-378 Use alias files for domain info folders and attributes (#496)
* JIRA WDT-378 - Create aliases for domainInfo sections, use for print-usage * JIRA WDT-378 - Use domain info aliases for model encryption * JIRA WDT-378 - Flag domainBin and domainLibraries to use path tokens, for validation against archive * JIRA WDT-378 - Use domain info aliases for model validation, fixed top-level attribute validation * JIRA WDT-378 - Removed unused methods for domainInfo fields * JIRA WDT-378 - Corrected property name in example
1 parent 6ec5426 commit 909e31a

File tree

11 files changed

+222
-222
lines changed

11 files changed

+222
-222
lines changed

core/src/main/python/wlsdeploy/aliases/alias_entries.py

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,9 @@
1212

1313
import wlsdeploy.aliases.alias_utils as alias_utils
1414
from wlsdeploy.aliases import password_utils
15-
from wlsdeploy.aliases.alias_constants import ChildFoldersTypes
16-
from wlsdeploy.aliases.location_context import LocationContext
17-
from wlsdeploy.aliases.model_constants import APPLICATION
18-
from wlsdeploy.aliases.model_constants import ODL_CONFIGURATION
19-
from wlsdeploy.aliases.model_constants import RESOURCE_MANAGER
20-
from wlsdeploy.aliases.validation_codes import ValidationCodes
21-
from wlsdeploy.aliases.wlst_modes import WlstModes
22-
from wlsdeploy.exception import exception_helper
23-
from wlsdeploy.logging.platform_logger import PlatformLogger
24-
from wlsdeploy.util import dictionary_utils
25-
from wlsdeploy.util.weblogic_helper import WebLogicHelper
26-
2715
from wlsdeploy.aliases.alias_constants import ATTRIBUTES
2816
from wlsdeploy.aliases.alias_constants import CHILD_FOLDERS_TYPE
17+
from wlsdeploy.aliases.alias_constants import ChildFoldersTypes
2918
from wlsdeploy.aliases.alias_constants import CONTAINS
3019
from wlsdeploy.aliases.alias_constants import DEFAULT_NAME_VALUE
3120
from wlsdeploy.aliases.alias_constants import FLATTENED_FOLDER_DATA
@@ -43,7 +32,6 @@
4332
from wlsdeploy.aliases.alias_constants import SINGLE
4433
from wlsdeploy.aliases.alias_constants import UNRESOLVED_ATTRIBUTES_MAP
4534
from wlsdeploy.aliases.alias_constants import UNRESOLVED_FOLDERS_MAP
46-
from wlsdeploy.aliases.alias_constants import VERSION
4735
from wlsdeploy.aliases.alias_constants import VERSION_RANGE
4836
from wlsdeploy.aliases.alias_constants import WLST_ATTRIBUTES_PATH
4937
from wlsdeploy.aliases.alias_constants import WLST_CREATE_PATH
@@ -56,6 +44,19 @@
5644
from wlsdeploy.aliases.alias_constants import WLST_SKIP_NAMES
5745
from wlsdeploy.aliases.alias_constants import WLST_SUBFOLDERS_PATH
5846
from wlsdeploy.aliases.alias_constants import WLST_TYPE
47+
from wlsdeploy.aliases.location_context import LocationContext
48+
from wlsdeploy.aliases.model_constants import APPLICATION
49+
from wlsdeploy.aliases.model_constants import RCU_DB_INFO
50+
from wlsdeploy.aliases.model_constants import WLS_ROLES
51+
from wlsdeploy.aliases.model_constants import ODL_CONFIGURATION
52+
from wlsdeploy.aliases.model_constants import DOMAIN_INFO_ALIAS
53+
from wlsdeploy.aliases.model_constants import RESOURCE_MANAGER
54+
from wlsdeploy.aliases.validation_codes import ValidationCodes
55+
from wlsdeploy.aliases.wlst_modes import WlstModes
56+
from wlsdeploy.exception import exception_helper
57+
from wlsdeploy.logging.platform_logger import PlatformLogger
58+
from wlsdeploy.util import dictionary_utils
59+
from wlsdeploy.util.weblogic_helper import WebLogicHelper
5960

6061
_class_name = 'AliasEntries'
6162
_logger = PlatformLogger('wlsdeploy.aliases')
@@ -131,23 +132,12 @@ class AliasEntries(object):
131132
'Library'
132133
]
133134

134-
__all_model_categories = []
135+
__domain_info_top_level_folders = [
136+
RCU_DB_INFO,
137+
WLS_ROLES
138+
]
135139

136-
__domain_info_attributes_and_types = {
137-
'AdminUserName': 'string',
138-
'AdminPassword': 'password',
139-
'ServerStartMode': 'string',
140-
'domainBin': 'list',
141-
'domainLibraries': 'list',
142-
# A map of Server Group names to the list of servers/clusters to which they should
143-
# be targeted. The ServerGroup must appear in the domain typedef definition. If
144-
# the ServerGroup is not listed in this map, it will be targeted to all managed
145-
# servers in the domain.
146-
'ServerGroupTargetingLimits': 'dict',
147-
'RCUDbInfo': 'dict',
148-
'OPSSSecrets': 'password',
149-
'WLSRoles': 'dict'
150-
}
140+
__all_model_categories = []
151141

152142
__domain_name_token = 'DOMAIN'
153143

@@ -169,8 +159,13 @@ def __init__(self, wlst_mode=WlstModes.OFFLINE, wls_version=None):
169159
self.__all_model_categories.extend(self.__topology_top_level_folders)
170160
self.__all_model_categories.extend(self.__resources_top_level_folders)
171161
self.__all_model_categories.extend(self.__app_deployments_top_level_folders)
162+
self.__all_model_categories.extend(self.__domain_info_top_level_folders)
163+
164+
# ResourceManager is not a top-level folder, it's contained by ResourceManagement
172165
self.__all_model_categories.append(RESOURCE_MANAGER)
173166

167+
# DomainInfo is not a top-level folder, it defines domainInfo top-level attributes
168+
self.__all_model_categories.append(DOMAIN_INFO_ALIAS)
174169
return
175170

176171
def get_dictionary_for_location(self, location, resolve=True):
@@ -249,8 +244,12 @@ def get_model_app_deployments_subfolder_names(self):
249244
"""
250245
return list(self.__app_deployments_top_level_folders)
251246

252-
def get_domain_info_attribute_names_and_types(self):
253-
return dict(self.__domain_info_attributes_and_types)
247+
def get_model_domain_info_subfolder_names(self):
248+
"""
249+
Get the top-level model folder names underneath the domain info section.
250+
:return: a list of the folder names
251+
"""
252+
return list(self.__domain_info_top_level_folders)
254253

255254
def get_model_subfolder_names_for_location(self, location):
256255
"""

core/src/main/python/wlsdeploy/aliases/aliases.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,14 @@ def get_model_app_deployments_top_level_folder_names(self):
125125
"""
126126
return self._alias_entries.get_model_app_deployments_subfolder_names()
127127

128+
def get_model_domain_info_top_level_folder_names(self):
129+
"""
130+
Returns a list of the recognized top-level model folders in the domainInfo section corresponding to the
131+
known WLST top-level folders.
132+
:return: a list of the recognized top-level model folder names
133+
"""
134+
return self._alias_entries.get_model_domain_info_subfolder_names()
135+
128136
def get_model_subfolder_names(self, location):
129137
"""
130138
Get the list of model folder names for subfolders of the specified location.
@@ -1037,13 +1045,6 @@ def get_model_attribute_names_and_types(self, location):
10371045
self._logger.exiting(class_name=self._class_name, method_name=_method_name, result=result)
10381046
return result
10391047

1040-
def get_model_domain_info_attribute_names_and_types(self):
1041-
"""
1042-
Get the attribute names and types for the domainInfo section of the model
1043-
:return: a dictionary keyed on model attribute names with the type as the value
1044-
"""
1045-
return self._alias_entries.get_domain_info_attribute_names_and_types()
1046-
10471048
def attribute_values_are_equal(self, location, model_attribute_name, model_attribute_value, wlst_attribute_value):
10481049
"""
10491050
Returns whether or not the model and WLST values for a given model attribute,

core/src/main/python/wlsdeploy/aliases/model_constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
DOMAIN = 'Domain'
9595
DOMAIN_NAME = 'Name'
9696
DOMAIN_INFO = 'domainInfo'
97+
DOMAIN_INFO_ALIAS = 'DomainInfo'
9798
DOMAIN_LIBRARIES = 'domainLibraries'
9899
DOMAIN_SCRIPTS = 'domainBin'
99100
DYNAMIC_SERVERS = 'DynamicServers'

core/src/main/python/wlsdeploy/tool/encrypt/encryption_utils.py

Lines changed: 16 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,7 @@
77

88
from wlsdeploy.aliases.location_context import LocationContext
99
from wlsdeploy.aliases.model_constants import DOMAIN_INFO
10-
from wlsdeploy.aliases.model_constants import DRIVER_PARAMS_KEYSTOREPWD_PROPERTY
11-
from wlsdeploy.aliases.model_constants import DRIVER_PARAMS_TRUSTSTOREPWD_PROPERTY
12-
from wlsdeploy.aliases.model_constants import RCU_ADMIN_PASSWORD
13-
from wlsdeploy.aliases.model_constants import RCU_DB_INFO
14-
from wlsdeploy.aliases.model_constants import RCU_SCHEMA_PASSWORD
10+
from wlsdeploy.aliases.model_constants import DOMAIN_INFO_ALIAS
1511
from wlsdeploy.exception import exception_helper
1612
from wlsdeploy.logging.platform_logger import PlatformLogger
1713
from wlsdeploy.util import model
@@ -27,15 +23,6 @@ class _ModelEncrypter(object):
2723
_class_name = '_ModelEncrypter'
2824
_logger = PlatformLogger('wlsdeploy.encrypt')
2925

30-
# these elements in the domainInfo/RCUDbInfo section are passwords,
31-
# and may need to be encrypted.
32-
_rcu_password_attributes = [
33-
RCU_ADMIN_PASSWORD,
34-
RCU_SCHEMA_PASSWORD,
35-
DRIVER_PARAMS_KEYSTOREPWD_PROPERTY,
36-
DRIVER_PARAMS_TRUSTSTOREPWD_PROPERTY
37-
]
38-
3926
def __init__(self, passphrase, alias_helper, variables=None):
4027
"""
4128
Initialize variables for use throughout.
@@ -59,9 +46,8 @@ def encrypt_model_dictionary(self, model_dict):
5946
"""
6047

6148
if model.get_model_domain_info_key() in model_dict:
62-
info_name_map = self.alias_helper.get_model_domain_info_attribute_names_and_types()
6349
domain_info_dict = model_dict[model.get_model_domain_info_key()]
64-
self._encrypt_info_nodes(domain_info_dict, info_name_map)
50+
self._encrypt_info_nodes(domain_info_dict)
6551

6652
if model.get_model_topology_key() in model_dict:
6753
top_folder_names = self.alias_helper.get_model_topology_top_level_folder_names()
@@ -83,24 +69,24 @@ def encrypt_model_dictionary(self, model_dict):
8369

8470
return self.model_changes, len(self.variables_changed)
8571

86-
def _encrypt_info_nodes(self, info_nodes, info_name_map):
72+
def _encrypt_info_nodes(self, info_nodes):
8773
"""
8874
Encrypt a set of nodes from the domainInfo section of the model.
8975
:param info_nodes: the model nodes
90-
:param info_name_map: a map of model key names to type
9176
"""
92-
for key in info_nodes:
93-
if key in info_name_map:
94-
attribute_type = info_name_map[key]
95-
if attribute_type == 'password':
96-
self._encrypt_attribute(DOMAIN_INFO, info_nodes, key)
97-
98-
if RCU_DB_INFO in info_nodes:
99-
rcu_nodes = info_nodes[RCU_DB_INFO]
100-
folder_name = DOMAIN_INFO + '/' + RCU_DB_INFO
101-
for key in rcu_nodes:
102-
if key in self._rcu_password_attributes:
103-
self._encrypt_attribute(folder_name, rcu_nodes, key)
77+
info_location = LocationContext().append_location(DOMAIN_INFO_ALIAS)
78+
password_attribute_names = self.alias_helper.get_model_password_type_attribute_names(info_location)
79+
80+
subfolder_names = self.alias_helper.get_model_domain_info_top_level_folder_names()
81+
82+
for node in info_nodes:
83+
if node in subfolder_names:
84+
child_location = LocationContext().append_location(node)
85+
child_nodes = info_nodes[node]
86+
self._encrypt_nodes(child_location, child_nodes)
87+
88+
elif node in password_attribute_names:
89+
self._encrypt_attribute(DOMAIN_INFO, info_nodes, node)
10490

10591
def _encrypt_nodes(self, location, model_nodes, subfolder_names=None):
10692
"""

core/src/main/python/wlsdeploy/tool/util/alias_helper.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,13 @@ def get_model_app_deployments_top_level_folder_names(self):
612612
"""
613613
return self.__aliases.get_model_app_deployments_top_level_folder_names()
614614

615+
def get_model_domain_info_top_level_folder_names(self):
616+
"""
617+
Get the model domain info top-level folder names.
618+
:return: the list of top-level domain info folders
619+
"""
620+
return self.__aliases.get_model_domain_info_top_level_folder_names()
621+
615622
def get_model_attribute_names(self, location):
616623
"""
617624
Get the model attribute names.
@@ -738,13 +745,6 @@ def get_model_merge_required_attribute_names(self, location):
738745
raise ex
739746
return result
740747

741-
def get_model_domain_info_attribute_names_and_types(self):
742-
"""
743-
Get the attribute names and types for the domainInfo section of the model.
744-
:return: a dictionary keyed on model attribute names with the type as the value
745-
"""
746-
return self.__aliases.get_model_domain_info_attribute_names_and_types()
747-
748748
def get_model_attribute_default_value(self, location, model_attribute_name):
749749
"""
750750
Get the default value for the specified attribute.

core/src/main/python/wlsdeploy/tool/validate/usage_printer.py

Lines changed: 14 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -77,38 +77,16 @@ def print_model_path_usage(self, model_path, control_option):
7777
if model_path_tokens[0] == model_constants.APP_DEPLOYMENTS:
7878
valid_section_folder_keys = self._aliases.get_model_app_deployments_top_level_folder_names()
7979

80+
if model_path_tokens[0] == model_constants.DOMAIN_INFO:
81+
valid_section_folder_keys = self._aliases.get_model_domain_info_top_level_folder_names()
82+
8083
if len(model_path_tokens) == 1:
81-
if model_path_tokens[0] == model_constants.DOMAIN_INFO:
82-
self.__print_domain_info_usage(model_path_tokens)
83-
else:
84-
self.__print_top_level_usage(top_level_key, valid_section_folder_keys, control_option)
84+
self.__print_top_level_usage(top_level_key, valid_section_folder_keys, control_option)
8585
else:
8686
self.__print_model_section_usage(model_path_tokens, valid_section_folder_keys, control_option)
8787

8888
return
8989

90-
def __print_domain_info_usage(self, model_path_tokens):
91-
"""
92-
Prints out the usage for the domainInfo section of a model
93-
:param model_path_tokens: A Python list of path elements built from model path
94-
:return:
95-
"""
96-
97-
_method_name = '__print_domain_info_usage'
98-
self._logger.finest('1 model_path_tokens={0}', str(model_path_tokens),
99-
class_name=_class_name, method_name=_method_name)
100-
101-
model_path = validation_utils.format_message('WLSDPLY-05103', '%s:' % model_path_tokens[0])
102-
103-
# Print 'Path: <model_section>' label and field
104-
validation_utils.print_indent(model_path, 0)
105-
validation_utils.print_blank_lines()
106-
107-
attr_infos = self._alias_helper.get_model_domain_info_attribute_names_and_types()
108-
_print_attr_infos(attr_infos, 1)
109-
110-
return
111-
11290
def __print_top_level_usage(self, top_level_key, valid_section_folder_keys, control_option):
11391
"""
11492
Prints out the usage for a section of a model, when just the section_name[:[/}} is provided
@@ -132,15 +110,20 @@ def __print_top_level_usage(self, top_level_key, valid_section_folder_keys, cont
132110

133111
# Print 'Section: <model_section>' label and field
134112
validation_utils.print_indent(model_section, 0)
135-
136-
if control_option == self.ControlOptions.ATTRIBUTES_ONLY:
137-
# Doing an ATTRIBUTES_ONLY on a top level key is a no-op
138-
return
113+
validation_utils.print_blank_lines()
139114

140115
validation_location = LocationContext()
141116

117+
# topology level has attributes, use empty location
118+
if top_level_key == model_constants.TOPOLOGY:
119+
self.__print_attributes_usage(validation_location, 1)
120+
121+
# domainInfo level has attributes, use special location
122+
if top_level_key == model_constants.DOMAIN_INFO:
123+
info_location = LocationContext().append_location("DomainInfo")
124+
self.__print_attributes_usage(info_location, 1)
125+
142126
if control_option == self.ControlOptions.FOLDERS_ONLY:
143-
validation_utils.print_blank_lines()
144127
validation_utils.print_indent(validation_utils.format_message('WLSDPLY-05105'), 1)
145128
valid_section_folder_keys.sort()
146129

0 commit comments

Comments
 (0)