11"""
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.
33Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
44"""
55import copy
4545from wlsdeploy .aliases .alias_constants import WLST_SUBFOLDERS_PATH
4646from wlsdeploy .aliases .alias_constants import WLST_TYPE
4747from wlsdeploy .aliases .location_context import LocationContext
48+ from wlsdeploy .aliases .model_constants import APP_DEPLOYMENTS
4849from 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
5251from 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
5356from 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
5461from wlsdeploy .aliases .validation_codes import ValidationCodes
5562from wlsdeploy .aliases .wlst_modes import WlstModes
5663from wlsdeploy .exception import exception_helper
@@ -137,6 +144,31 @@ class AliasEntries(object):
137144 WLS_ROLES
138145 ]
139146
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
140172 __all_model_categories = []
141173
142174 __domain_name_token = 'DOMAIN'
@@ -156,16 +188,23 @@ def __init__(self, wlst_mode=WlstModes.OFFLINE, wls_version=None):
156188 self ._wls_helper = WebLogicHelper (_logger , wls_version )
157189 self ._wls_version = wls_version
158190
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 )
163197
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
165202 self .__all_model_categories .append (RESOURCE_MANAGER )
203+ self .__all_model_categories .append (SERVER_POD )
166204
167- # DomainInfo is not a top-level folder, it defines domainInfo top-level attributes
205+ # include section attribute categories
168206 self .__all_model_categories .append (DOMAIN_INFO_ALIAS )
207+ self .__all_model_categories .append (KUBERNETES_ALIAS )
169208 return
170209
171210 def get_dictionary_for_location (self , location , resolve = True ):
@@ -196,15 +235,7 @@ def get_model_domain_subfolder_names(self):
196235 _method_name = 'get_model_domain_subfolder_names'
197236
198237 _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 )
208239 _logger .exiting (class_name = _class_name , method_name = _method_name , result = folder_list )
209240 return folder_list
210241
@@ -244,12 +275,31 @@ def get_model_app_deployments_subfolder_names(self):
244275 """
245276 return list (self .__app_deployments_top_level_folders )
246277
247- def get_model_domain_info_subfolder_names (self ):
278+ def get_model_section_subfolder_names (self , section_name ):
248279 """
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.
250281 :return: a list of the folder names
251282 """
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
253303
254304 def get_model_subfolder_names_for_location (self , location ):
255305 """
@@ -883,13 +933,13 @@ def _unit_test_only_get_category_map_files(self):
883933 def _get_category_file_prefix (self , category_name ):
884934 """
885935 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.
888937 :param category_name: the name to be checked
889- :return: the corressponding file name prefix
938+ :return: the corresponding file name prefix
890939 """
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
893943 return category_name
894944
895945 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
10411091 for key , value in raw_folders_wlst_paths .iteritems ():
10421092 raw_model_dict [WLST_PATHS ][key ] = base_path + value
10431093
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 )
10471097
10481098 #
10491099 # Now that the folder paths are all updated accordingly, load any contains folders, compute the
0 commit comments