1
1
"""
2
- Copyright (c) 2017, 2019 , Oracle Corporation and/or its affiliates. All rights reserved.
2
+ Copyright (c) 2017, 2020 , Oracle Corporation and/or its affiliates. All rights reserved.
3
3
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
4
4
"""
5
5
import copy
45
45
from wlsdeploy .aliases .alias_constants import WLST_SUBFOLDERS_PATH
46
46
from wlsdeploy .aliases .alias_constants import WLST_TYPE
47
47
from wlsdeploy .aliases .location_context import LocationContext
48
+ from wlsdeploy .aliases .model_constants import APP_DEPLOYMENTS
48
49
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
50
+ from wlsdeploy .aliases .model_constants import DOMAIN_INFO
52
51
from wlsdeploy .aliases .model_constants import DOMAIN_INFO_ALIAS
52
+ from wlsdeploy .aliases .model_constants import KUBERNETES_ALIAS
53
+ from wlsdeploy .aliases .model_constants import ODL_CONFIGURATION
54
+ from wlsdeploy .aliases .model_constants import KUBERNETES
55
+ from wlsdeploy .aliases .model_constants import RCU_DB_INFO
53
56
from wlsdeploy .aliases .model_constants import RESOURCE_MANAGER
57
+ from wlsdeploy .aliases .model_constants import RESOURCES
58
+ from wlsdeploy .aliases .model_constants import SERVER_POD
59
+ from wlsdeploy .aliases .model_constants import TOPOLOGY
60
+ from wlsdeploy .aliases .model_constants import WLS_ROLES
54
61
from wlsdeploy .aliases .validation_codes import ValidationCodes
55
62
from wlsdeploy .aliases .wlst_modes import WlstModes
56
63
from wlsdeploy .exception import exception_helper
@@ -137,6 +144,31 @@ class AliasEntries(object):
137
144
WLS_ROLES
138
145
]
139
146
147
+ __kubernetes_top_level_folders = [
148
+ 'metadata' ,
149
+ 'spec'
150
+ ]
151
+
152
+ __section_top_folders_map = {
153
+ DOMAIN_INFO : __domain_info_top_level_folders ,
154
+ TOPOLOGY : __topology_top_level_folders ,
155
+ RESOURCES : __resources_top_level_folders ,
156
+ APP_DEPLOYMENTS : __app_deployments_top_level_folders ,
157
+ KUBERNETES : __kubernetes_top_level_folders
158
+ }
159
+
160
+ # in rare cases, the alias file name does not match the folder name
161
+ __alternate_alias_file_name_map = {
162
+ APPLICATION : 'AppDeployment' ,
163
+ 'metadata' : 'Metadata' ,
164
+ 'spec' : 'Spec' ,
165
+ 'serverPod' : 'ServerPod'
166
+ }
167
+
168
+ # all the categories that appear at the top of model sections
169
+ __top_model_categories = []
170
+
171
+ # all the categories, including section-attribute and contained categories
140
172
__all_model_categories = []
141
173
142
174
__domain_name_token = 'DOMAIN'
@@ -156,16 +188,23 @@ def __init__(self, wlst_mode=WlstModes.OFFLINE, wls_version=None):
156
188
self ._wls_helper = WebLogicHelper (_logger , wls_version )
157
189
self ._wls_version = wls_version
158
190
159
- self .__all_model_categories .extend (self .__topology_top_level_folders )
160
- self .__all_model_categories .extend (self .__resources_top_level_folders )
161
- self .__all_model_categories .extend (self .__app_deployments_top_level_folders )
162
- self .__all_model_categories .extend (self .__domain_info_top_level_folders )
191
+ # top model categories
192
+ self .__top_model_categories .extend (self .__topology_top_level_folders )
193
+ self .__top_model_categories .extend (self .__resources_top_level_folders )
194
+ self .__top_model_categories .extend (self .__app_deployments_top_level_folders )
195
+ self .__top_model_categories .extend (self .__domain_info_top_level_folders )
196
+ self .__top_model_categories .extend (self .__kubernetes_top_level_folders )
163
197
164
- # ResourceManager is not a top-level folder, it's contained by ResourceManagement
198
+ # all model categories
199
+ self .__all_model_categories .extend (self .__top_model_categories )
200
+
201
+ # include contained categories
165
202
self .__all_model_categories .append (RESOURCE_MANAGER )
203
+ self .__all_model_categories .append (SERVER_POD )
166
204
167
- # DomainInfo is not a top-level folder, it defines domainInfo top-level attributes
205
+ # include section attribute categories
168
206
self .__all_model_categories .append (DOMAIN_INFO_ALIAS )
207
+ self .__all_model_categories .append (KUBERNETES_ALIAS )
169
208
return
170
209
171
210
def get_dictionary_for_location (self , location , resolve = True ):
@@ -196,15 +235,7 @@ def get_model_domain_subfolder_names(self):
196
235
_method_name = 'get_model_domain_subfolder_names'
197
236
198
237
_logger .entering (class_name = _class_name , method_name = _method_name )
199
- folder_list = list (self .__all_model_categories )
200
- #
201
- # Remove all folders that do not appear at the WLST root level
202
- #
203
- if 'Domain' in folder_list :
204
- folder_list .remove ('Domain' )
205
- if 'ResourceManager' in folder_list :
206
- folder_list .remove ('ResourceManager' )
207
-
238
+ folder_list = list (self .__top_model_categories )
208
239
_logger .exiting (class_name = _class_name , method_name = _method_name , result = folder_list )
209
240
return folder_list
210
241
@@ -244,12 +275,31 @@ def get_model_app_deployments_subfolder_names(self):
244
275
"""
245
276
return list (self .__app_deployments_top_level_folders )
246
277
247
- def get_model_domain_info_subfolder_names (self ):
278
+ def get_model_section_subfolder_names (self , section_name ):
248
279
"""
249
- Get the top-level model folder names underneath the domain info section.
280
+ Get the top-level model folder names underneath the specified section.
250
281
:return: a list of the folder names
251
282
"""
252
- return list (self .__domain_info_top_level_folders )
283
+ result = dictionary_utils .get_element (self .__section_top_folders_map , section_name )
284
+ if result is None :
285
+ result = []
286
+ return result
287
+
288
+ def get_model_section_attribute_location (self , section_name ):
289
+ """
290
+ Get the location containing the attributes for a model section (topology, domainInfo, etc.)
291
+ :return: a location, or None of the section does not have attributes.
292
+ """
293
+ if section_name == TOPOLOGY :
294
+ return LocationContext ()
295
+
296
+ if section_name == DOMAIN_INFO :
297
+ return LocationContext ().append_location (DOMAIN_INFO_ALIAS )
298
+
299
+ if section_name == KUBERNETES :
300
+ return LocationContext ().append_location (KUBERNETES_ALIAS )
301
+
302
+ return None
253
303
254
304
def get_model_subfolder_names_for_location (self , location ):
255
305
"""
@@ -883,13 +933,13 @@ def _unit_test_only_get_category_map_files(self):
883
933
def _get_category_file_prefix (self , category_name ):
884
934
"""
885
935
Return the file prefix for the specified top-level category.
886
- The file prefix should match the category name exactly.
887
- File name for Application is different for some reason
936
+ The file prefix should match the category name exactly, except in rare cases.
888
937
:param category_name: the name to be checked
889
- :return: the corressponding file name prefix
938
+ :return: the corresponding file name prefix
890
939
"""
891
- if category_name == APPLICATION :
892
- return 'AppDeployment'
940
+ alternate_name = dictionary_utils .get_element (self .__alternate_alias_file_name_map , category_name )
941
+ if alternate_name is not None :
942
+ return alternate_name
893
943
return category_name
894
944
895
945
def __get_dictionary_for_location (self , location , resolve_path_tokens = True ):
@@ -1041,9 +1091,9 @@ def __load_contains_categories(self, model_category_name, raw_model_dict, base_p
1041
1091
for key , value in raw_folders_wlst_paths .iteritems ():
1042
1092
raw_model_dict [WLST_PATHS ][key ] = base_path + value
1043
1093
1044
- for folder in raw_model_dict_folders :
1045
- raw_folder_dict = raw_model_dict_folders [folder ]
1046
- self .__load_contains_categories (folder , raw_folder_dict , base_path )
1094
+ for folder in raw_model_dict_folders :
1095
+ raw_folder_dict = raw_model_dict_folders [folder ]
1096
+ self .__load_contains_categories (folder , raw_folder_dict , base_path )
1047
1097
1048
1098
#
1049
1099
# Now that the folder paths are all updated accordingly, load any contains folders, compute the
0 commit comments