7
7
# WDT filters to prepare a model for use a target environment, using the createDomain or prepareModel tools.
8
8
# These operations can be invoked as a single call, or independently of each other.
9
9
from oracle .weblogic .deploy .util import PyRealBoolean
10
- from oracle .weblogic .deploy .util import PyOrderedDict
11
10
from wlsdeploy .aliases import alias_utils
12
- from wlsdeploy .aliases .model_constants import ADMIN_SERVER_NAME
13
11
from wlsdeploy .aliases .model_constants import AUTO_MIGRATION_ENABLED
14
12
from wlsdeploy .aliases .model_constants import CALCULATED_LISTEN_PORTS
15
13
from wlsdeploy .aliases .model_constants import CANDIDATE_MACHINE
16
14
from wlsdeploy .aliases .model_constants import CANDIDATE_MACHINES_FOR_MIGRATABLE_SERVER
17
15
from wlsdeploy .aliases .model_constants import CLUSTER
18
16
from wlsdeploy .aliases .model_constants import CLUSTER_MESSAGING_MODE
19
17
from wlsdeploy .aliases .model_constants import DATABASE_LESS_LEASING_BASIS
20
- from wlsdeploy .aliases .model_constants import DEFAULT_ADMIN_SERVER_NAME
21
18
from wlsdeploy .aliases .model_constants import DYNAMIC_SERVERS
22
19
from wlsdeploy .aliases .model_constants import LISTEN_PORT
23
20
from wlsdeploy .aliases .model_constants import MACHINE
34
31
from wlsdeploy .aliases .model_constants import RESOURCE_MANAGER
35
32
from wlsdeploy .aliases .model_constants import SECURITY_CONFIGURATION
36
33
from wlsdeploy .aliases .model_constants import SERVER
37
- from wlsdeploy .aliases .model_constants import SERVER_NAME_PREFIX
38
34
from wlsdeploy .aliases .model_constants import SERVER_START
39
35
from wlsdeploy .aliases .model_constants import SERVER_TEMPLATE
40
36
from wlsdeploy .aliases .model_constants import TOPOLOGY
49
45
from wlsdeploy .util import dictionary_utils
50
46
import wlsdeploy .util .unicode_helper as str_helper
51
47
52
- FIX_PREFIX_TEMPLATE = '-- FIX PREFIX %s --'
53
-
54
48
_class_name = 'wko_filter'
55
49
_logger = PlatformLogger ('wlsdeploy.tool.util' )
56
50
@@ -67,7 +61,6 @@ def filter_model(model, model_context):
67
61
filter_resources (model , model_context )
68
62
filter_online_attributes (model , model_context )
69
63
check_clustered_server_ports (model , model_context )
70
- check_dynamic_cluster_prefixes (model , model_context )
71
64
72
65
73
66
def filter_model_for_wko (model , model_context ):
@@ -80,17 +73,6 @@ def filter_model_for_wko(model, model_context):
80
73
filter_model (model , model_context )
81
74
82
75
83
- def filter_model_for_wko3 (model , model_context ):
84
- """
85
- Perform filtering operations on the specified model to prepare for WKO deployment.
86
- Currently matches the general k8s target filtering.
87
- :param model: the model to be filtered
88
- :param model_context: used by nested filters
89
- """
90
- filter_model (model , model_context )
91
- check_admin_server_defined (model , model_context )
92
-
93
-
94
76
def filter_model_for_vz (model , model_context ):
95
77
"""
96
78
Perform filtering operations on the specified model to prepare for Verrazzano deployment.
@@ -161,71 +143,6 @@ def check_clustered_server_ports(model, _model_context):
161
143
server_port_map [server_cluster ] = {"firstServer" : server_name , "serverPort" : server_port_text }
162
144
163
145
164
- def check_dynamic_cluster_prefixes (model , _model_context ):
165
- """
166
- All Dynamic Clusters must have a DynamicServers section with the ServerNamePrefix field explicitly declared.
167
- Ensure each cluster uses a unique value for this field.
168
- :param model: the model to be updated
169
- :param _model_context: unused, passed by filter_helper if called independently
170
- :return:
171
- """
172
- _method_name = 'check_dynamic_cluster_prefixes'
173
-
174
- server_name_prefixes = []
175
- topology_folder = dictionary_utils .get_dictionary_element (model , TOPOLOGY )
176
- clusters_folder = dictionary_utils .get_dictionary_element (topology_folder , CLUSTER )
177
- for cluster_name , cluster_fields in clusters_folder .items ():
178
- dynamic_folder = dictionary_utils .get_element (cluster_fields , DYNAMIC_SERVERS )
179
- if dynamic_folder :
180
- server_name_prefix = dictionary_utils .get_element (dynamic_folder , SERVER_NAME_PREFIX )
181
-
182
- if not server_name_prefix :
183
- _logger .warning ('WLSDPLY-20204' , cluster_name , SERVER_NAME_PREFIX , class_name = _class_name ,
184
- method_name = _method_name )
185
- server_name_prefix = _get_unused_prefix (server_name_prefixes )
186
- dynamic_folder [SERVER_NAME_PREFIX ] = server_name_prefix
187
-
188
- elif server_name_prefix in server_name_prefixes :
189
- _logger .warning ('WLSDPLY-20205' , SERVER_NAME_PREFIX , server_name_prefix , class_name = _class_name ,
190
- method_name = _method_name )
191
- server_name_prefix = _get_unused_prefix (server_name_prefixes )
192
- dynamic_folder [SERVER_NAME_PREFIX ] = server_name_prefix
193
-
194
- server_name_prefixes .append (server_name_prefix )
195
-
196
-
197
- def check_admin_server_defined (model , _model_context ):
198
- """
199
- Ensure that the AdminServerName attribute is set, and that the server is defined.
200
- This is required by WKO 3.0, and not by 4.0 and later.
201
- :param model: the model to be filtered
202
- :param _model_context: unused, passed by filter_helper if called independently
203
- """
204
- _method_name = 'check_admin_server_defined'
205
-
206
- topology_folder = dictionary_utils .get_element (model , TOPOLOGY )
207
- if topology_folder is None :
208
- # for cases with multiple models, avoid adding topology and admin server for
209
- # models with only resources, applications, etc.
210
- return
211
-
212
- admin_server_name = dictionary_utils .get_element (topology_folder , ADMIN_SERVER_NAME )
213
- if not admin_server_name :
214
- admin_server_name = DEFAULT_ADMIN_SERVER_NAME
215
- _logger .info ('WLSDPLY-20206' , ADMIN_SERVER_NAME , admin_server_name , class_name = _class_name ,
216
- method_name = _method_name )
217
- topology_folder [ADMIN_SERVER_NAME ] = admin_server_name
218
-
219
- servers_folder = dictionary_utils .get_element (topology_folder , SERVER )
220
- if servers_folder is None :
221
- servers_folder = PyOrderedDict ()
222
- topology_folder [SERVER ] = servers_folder
223
-
224
- if admin_server_name not in servers_folder :
225
- _logger .info ('WLSDPLY-20207' , SERVER , admin_server_name , class_name = _class_name , method_name = _method_name )
226
- servers_folder [admin_server_name ] = PyOrderedDict ()
227
-
228
-
229
146
def filter_topology (model , _model_context ):
230
147
"""
231
148
Remove elements from the topology section of the model that are not relevant in a Kubernetes environment.
@@ -284,18 +201,6 @@ def filter_resources(model, _model_context):
284
201
del resources [delete_key ]
285
202
286
203
287
- def _get_unused_prefix (used_prefixes ):
288
- """
289
- Find a recognizable, unused prefix that can be used in the filtered model.
290
- :param used_prefixes: prefixes that have already been used in the model
291
- :return: an unused prefix
292
- """
293
- i = 1
294
- while FIX_PREFIX_TEMPLATE % i in used_prefixes :
295
- i += 1
296
- return FIX_PREFIX_TEMPLATE % i
297
-
298
-
299
204
class OnlineAttributeFilter (ModelTraverse ):
300
205
"""
301
206
Traverse the model and remove any online-only attributes.
0 commit comments