Skip to content

Commit 58c6786

Browse files
authored
Add new target environments wko-dii, wko-pv, vz-dii, vz-pv (#1076)
* Change exposed filters for existing targets to internal filters * Add new target environments wko-dii, wko-pv, vz-dii, vz-pv * Update unit test for additional filters * Removed typos from model constants * Corrected copyright * Added volume information to PV templates for wko and vz
1 parent 55859be commit 58c6786

File tree

16 files changed

+674
-173
lines changed

16 files changed

+674
-173
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,10 +338,14 @@
338338
ACTION = 'Action'
339339
ACTIVE_TYPE = 'ActiveType'
340340
ARGUMENTS = 'Arguments'
341+
AUTO_MIGRATION_ENABLED = 'AutoMigrationEnabled'
342+
CANDIDATE_MACHINE = 'CandidateMachine'
343+
CANDIDATE_MACHINES_FOR_MIGRATABLE_SERVER = 'CandidateMachinesForMigratableServer'
341344
COMPONENT_TYPE = 'ComponentType'
342345
CONSTRAINED_CANDIDATE_SERVER = 'ConstrainedCandidateServer'
343346
CUSTOM_IDENTITY_KEYSTORE_FILE = 'CustomIdentityKeyStoreFileName'
344347
CUSTOM_TRUST_KEYSTORE_FILE = 'CustomTrustKeyStoreFileName'
348+
DATABASE_LESS_LEASING_BASIS = 'DatabaseLessLeasingBasis'
345349
DEPLOYMENT_ORDER = 'DeploymentOrder'
346350
DESTINATION_SERVER = 'DestinationServer'
347351
DRIVER_NAME = 'DriverName'
@@ -366,6 +370,7 @@
366370
LISTEN_ADDRESS = 'ListenAddress'
367371
LISTEN_PORT = 'ListenPort'
368372
MASKED_PASSWORD = '<Masked>'
373+
MIGRATION_BASIS = 'MigrationBasis'
369374
MIME_MAPPING_FILE = 'MimeMappingFile'
370375
NAME = 'Name'
371376
NOTIFICATION = 'Notification'

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2017, 2022, Oracle Corporation and/or its affiliates. All rights reserved.
2+
Copyright (c) 2017, 2022, Oracle and/or its affiliates.
33
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
44
"""
55
import imp
@@ -18,9 +18,16 @@
1818
TARGET_CONFIG_TOKEN = '@@TARGET_CONFIG_DIR@@'
1919

2020
__id_filter_map = {
21+
# groups that execute multiple filters
2122
'k8s_filter': wko_filter.filter_model,
22-
'vz_filter': wko_filter.filter_model,
23-
'wko_filter': wko_filter.filter_model
23+
'vz_filter': wko_filter.filter_model_for_vz,
24+
'wko_filter': wko_filter.filter_model_for_wko,
25+
26+
# individual filters for custom target environments
27+
'online_attributes_filter': wko_filter.filter_online_attributes,
28+
'resources_filter': wko_filter.filter_resources,
29+
'topology_filter': wko_filter.filter_topology,
30+
'server_ports_filter': wko_filter.check_clustered_server_ports
2431
}
2532

2633

core/src/main/python/wlsdeploy/tool/util/filters/wko_filter.py

Lines changed: 104 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,39 @@
44
# ------------
55
# Description:
66
# ------------
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.
88
# These operations can be invoked as a single call, or independently of each other.
99
from oracle.weblogic.deploy.util import PyRealBoolean
1010
from wlsdeploy.aliases import alias_utils
11+
from wlsdeploy.aliases.model_constants import AUTO_MIGRATION_ENABLED
1112
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
1215
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
1318
from wlsdeploy.aliases.model_constants import DYNAMIC_SERVERS
1419
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
1533
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
1636
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
1740
from wlsdeploy.aliases.validation_codes import ValidationCodes
1841
from wlsdeploy.aliases.wlst_modes import WlstModes
1942
from wlsdeploy.exception.expection_types import ExceptionType
@@ -33,10 +56,32 @@ def filter_model(model, model_context):
3356
:param model: the model to be filtered
3457
:param model_context: used by nested filters
3558
"""
59+
filter_topology(model, model_context)
60+
filter_resources(model, model_context)
3661
filter_online_attributes(model, model_context)
3762
check_clustered_server_ports(model, model_context)
3863

3964

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+
4085
def filter_online_attributes(model, model_context):
4186
"""
4287
Remove any online-only attributes from the specified model.
@@ -97,6 +142,64 @@ def check_clustered_server_ports(model, _model_context):
97142
server_port_map[server_cluster] = {"firstServer": server_name, "serverPort": server_port_text}
98143

99144

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+
100203
class OnlineAttributeFilter(ModelTraverse):
101204
"""
102205
Traverse the model and remove any online-only attributes.

core/src/main/targetconfigs/k8s/k8s_operator_filter.py

Lines changed: 5 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -4,61 +4,11 @@
44
# ------------
55
# Description:
66
# ------------
7-
# This is a WDT filter for primordial domain creation. It filters out all resources and
8-
# apps deployments, leaving only the domainInfo and admin server in topology.
9-
#
10-
from oracle.weblogic.deploy.util import PyRealBoolean
11-
from wlsdeploy.aliases import alias_utils
7+
# This filter can be extended to prepare a model for deployment to a Kubernetes environment,
8+
# using the the createDomain or prepareModel tools.
9+
# For information about extending the filter, see the WebLogic Deployment Tooling documentation:
10+
# https://oracle.github.io/weblogic-deploy-tooling/userguide/tools-config/model_filters/
1211

1312

1413
def filter_model(model):
15-
__cleanup_topology(model)
16-
__cleanup_resources(model)
17-
18-
def __cleanup_resources(model):
19-
if model and 'resources' in model:
20-
resources = model['resources']
21-
22-
for delthis in [ 'PartitionWorkManager', 'Partition', 'ResourceGroup', 'ResourceGroupTemplate', 'VirtualHost',
23-
'ResourceManager', 'ResourceManagement' ]:
24-
if resources.has_key(delthis):
25-
del resources[delthis]
26-
27-
def __cleanup_topology(model):
28-
if model and 'topology' in model:
29-
topology = model['topology']
30-
for delthis in [ 'NMProperties', 'VirtualTarget', 'Machine', 'UnixMachine']:
31-
if topology.has_key(delthis):
32-
del topology[delthis]
33-
34-
if topology.has_key('Cluster'):
35-
clusters = topology['Cluster']
36-
for cluster in clusters:
37-
for delthis in ['MigrationBasis', 'CandidateMachinesForMigratableServer', 'DatabaseLessLeasingBasis',
38-
'ClusterMessagingMode']:
39-
if clusters[cluster].has_key(delthis):
40-
del clusters[cluster][delthis]
41-
42-
if topology.has_key('Server'):
43-
servers = topology['Server']
44-
for server in servers:
45-
for delthis in ['Machine', 'CandidateMachine', 'AutoMigrationEnabled', 'ServerStart']:
46-
if servers[server].has_key(delthis):
47-
del servers[server][delthis]
48-
49-
if topology.has_key('SecurityConfiguration'):
50-
for delthis in ['NodeManagerPasswordEncrypted', 'NodeManagerUsername' ]:
51-
if topology['SecurityConfiguration'].has_key(delthis):
52-
del topology['SecurityConfiguration'][delthis]
53-
if len(topology['SecurityConfiguration'].keys()) == 0:
54-
del topology['SecurityConfiguration']
55-
56-
if topology.has_key('ServerTemplate'):
57-
server_templates = topology['ServerTemplate']
58-
for server_template in server_templates:
59-
auto_migration_enabled = server_templates[server_template]['AutoMigrationEnabled']
60-
if auto_migration_enabled is None or alias_utils.convert_boolean(auto_migration_enabled):
61-
server_templates[server_template]['AutoMigrationEnabled'] = PyRealBoolean(False)
62-
for delthis in ['ServerStart']:
63-
if server_templates[server_template].has_key(delthis):
64-
del server_templates[server_template][delthis]
14+
pass
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"model_filters" : {
3+
"discover": [
4+
{ "id": "vz_filter" }
5+
]
6+
},
7+
"variable_injectors" : {"PORT": {},"HOST": {},"URL": {}},
8+
"validation_method" : "lax",
9+
"credentials_output_method" : "script",
10+
"exclude_domain_bin_contents": true,
11+
"additional_secrets": "runtime-encryption-secret",
12+
"additional_output" : "vz-application.yaml"
13+
}

0 commit comments

Comments
 (0)