4
4
# ------------
5
5
# Description:
6
6
# ------------
7
- # WDT filters to prepare a model for use with WKO , using the createDomain or prepareModel tools.
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
10
from wlsdeploy .aliases import alias_utils
11
+ from wlsdeploy .aliases .model_constants import AUTO_MIGRATION_ENABLED
11
12
from wlsdeploy .aliases .model_constants import CALCULATED_LISTEN_PORTS
13
+ from wlsdeploy .aliases .model_constants import CANDIDATE_MACHINE
14
+ from wlsdeploy .aliases .model_constants import CANDIDATE_MACHINES_FOR_MIGRATABLE_SERVER
12
15
from wlsdeploy .aliases .model_constants import CLUSTER
16
+ from wlsdeploy .aliases .model_constants import CLUSTER_MESSAGING_MODE
17
+ from wlsdeploy .aliases .model_constants import DATABASE_LESS_LEASING_BASIS
13
18
from wlsdeploy .aliases .model_constants import DYNAMIC_SERVERS
14
19
from wlsdeploy .aliases .model_constants import LISTEN_PORT
20
+ from wlsdeploy .aliases .model_constants import MACHINE
21
+ from wlsdeploy .aliases .model_constants import MIGRATION_BASIS
22
+ from wlsdeploy .aliases .model_constants import NM_PROPERTIES
23
+ from wlsdeploy .aliases .model_constants import NODE_MANAGER_PW_ENCRYPTED
24
+ from wlsdeploy .aliases .model_constants import NODE_MANAGER_USER_NAME
25
+ from wlsdeploy .aliases .model_constants import PARTITION
26
+ from wlsdeploy .aliases .model_constants import PARTITION_WORK_MANAGER
27
+ from wlsdeploy .aliases .model_constants import RESOURCES
28
+ from wlsdeploy .aliases .model_constants import RESOURCE_GROUP
29
+ from wlsdeploy .aliases .model_constants import RESOURCE_GROUP_TEMPLATE
30
+ from wlsdeploy .aliases .model_constants import RESOURCE_MANAGEMENT
31
+ from wlsdeploy .aliases .model_constants import RESOURCE_MANAGER
32
+ from wlsdeploy .aliases .model_constants import SECURITY_CONFIGURATION
15
33
from wlsdeploy .aliases .model_constants import SERVER
34
+ from wlsdeploy .aliases .model_constants import SERVER_START
35
+ from wlsdeploy .aliases .model_constants import SERVER_TEMPLATE
16
36
from wlsdeploy .aliases .model_constants import TOPOLOGY
37
+ from wlsdeploy .aliases .model_constants import UNIX_MACHINE
38
+ from wlsdeploy .aliases .model_constants import VIRTUAL_HOST
39
+ from wlsdeploy .aliases .model_constants import VIRTUAL_TARGET
17
40
from wlsdeploy .aliases .validation_codes import ValidationCodes
18
41
from wlsdeploy .aliases .wlst_modes import WlstModes
19
42
from wlsdeploy .exception .expection_types import ExceptionType
@@ -33,10 +56,32 @@ def filter_model(model, model_context):
33
56
:param model: the model to be filtered
34
57
:param model_context: used by nested filters
35
58
"""
59
+ filter_topology (model , model_context )
60
+ filter_resources (model , model_context )
36
61
filter_online_attributes (model , model_context )
37
62
check_clustered_server_ports (model , model_context )
38
63
39
64
65
+ def filter_model_for_wko (model , model_context ):
66
+ """
67
+ Perform filtering operations on the specified model to prepare for WKO deployment.
68
+ Currently matches the general k8s target filtering.
69
+ :param model: the model to be filtered
70
+ :param model_context: used by nested filters
71
+ """
72
+ filter_model (model , model_context )
73
+
74
+
75
+ def filter_model_for_vz (model , model_context ):
76
+ """
77
+ Perform filtering operations on the specified model to prepare for Verrazzano deployment.
78
+ Currently matches the general k8s target filtering.
79
+ :param model: the model to be filtered
80
+ :param model_context: used by nested filters
81
+ """
82
+ filter_model (model , model_context )
83
+
84
+
40
85
def filter_online_attributes (model , model_context ):
41
86
"""
42
87
Remove any online-only attributes from the specified model.
@@ -97,6 +142,64 @@ def check_clustered_server_ports(model, _model_context):
97
142
server_port_map [server_cluster ] = {"firstServer" : server_name , "serverPort" : server_port_text }
98
143
99
144
145
+ def filter_topology (model , _model_context ):
146
+ """
147
+ Remove elements from the topology section of the model that are not relevant in a Kubernetes environment.
148
+ This includes references to machine and node manager elements.
149
+ :param model: the model to be updated
150
+ :param _model_context: unused, passed by filter_helper if called independently
151
+ """
152
+ topology = dictionary_utils .get_dictionary_element (model , TOPOLOGY )
153
+ for delete_key in [NM_PROPERTIES , VIRTUAL_TARGET , MACHINE , UNIX_MACHINE ]:
154
+ if delete_key in topology :
155
+ del topology [delete_key ]
156
+
157
+ clusters = dictionary_utils .get_dictionary_element (topology , CLUSTER )
158
+ for cluster in clusters :
159
+ for delete_key in [MIGRATION_BASIS , CANDIDATE_MACHINES_FOR_MIGRATABLE_SERVER , DATABASE_LESS_LEASING_BASIS ,
160
+ CLUSTER_MESSAGING_MODE ]:
161
+ if delete_key in clusters [cluster ]:
162
+ del clusters [cluster ][delete_key ]
163
+
164
+ servers = dictionary_utils .get_dictionary_element (topology , SERVER )
165
+ for server in servers :
166
+ for delete_key in [MACHINE , CANDIDATE_MACHINE , AUTO_MIGRATION_ENABLED , SERVER_START ]:
167
+ if delete_key in servers [server ]:
168
+ del servers [server ][delete_key ]
169
+
170
+ security_configuration = dictionary_utils .get_dictionary_element (topology , SECURITY_CONFIGURATION )
171
+ for delete_key in [NODE_MANAGER_USER_NAME , NODE_MANAGER_PW_ENCRYPTED ]:
172
+ if delete_key in security_configuration :
173
+ del security_configuration [delete_key ]
174
+
175
+ if (SECURITY_CONFIGURATION in topology ) and not security_configuration :
176
+ del topology [SECURITY_CONFIGURATION ]
177
+
178
+ server_templates = dictionary_utils .get_dictionary_element (topology , SERVER_TEMPLATE )
179
+ for key in server_templates :
180
+ server_template = server_templates [key ]
181
+ auto_migration_enabled = server_template [AUTO_MIGRATION_ENABLED ]
182
+ if auto_migration_enabled is None or alias_utils .convert_boolean (auto_migration_enabled ):
183
+ server_template [AUTO_MIGRATION_ENABLED ] = PyRealBoolean (False )
184
+ for delete_key in [SERVER_START ]:
185
+ if delete_key in server_template :
186
+ del server_template [delete_key ]
187
+
188
+
189
+ def filter_resources (model , _model_context ):
190
+ """
191
+ Remove elements from the resources section of the model that are not relevant in a Kubernetes environment.
192
+ This includes references to partitions and resource groups.
193
+ :param model: the model to be updated
194
+ :param _model_context: unused, passed by filter_helper if called independently
195
+ """
196
+ resources = dictionary_utils .get_dictionary_element (model , RESOURCES )
197
+ for delete_key in [PARTITION , PARTITION_WORK_MANAGER , RESOURCE_GROUP , RESOURCE_GROUP_TEMPLATE ,
198
+ RESOURCE_MANAGEMENT , RESOURCE_MANAGER , VIRTUAL_HOST ]:
199
+ if delete_key in resources :
200
+ del resources [delete_key ]
201
+
202
+
100
203
class OnlineAttributeFilter (ModelTraverse ):
101
204
"""
102
205
Traverse the model and remove any online-only attributes.
0 commit comments