Skip to content

Commit 55a33eb

Browse files
committed
fixing output of boolean filter fields already set
1 parent 7d00621 commit 55a33eb

File tree

5 files changed

+38
-6
lines changed

5 files changed

+38
-6
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2021, Oracle Corporation and/or its affiliates.
1+
# Copyright (c) 2021, 2022, Oracle Corporation and/or its affiliates.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33
#
44
# ------------

core/src/main/python/wlsdeploy/yaml/yaml_translator.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,15 @@ def parse(self):
9999
return result_dict
100100

101101

102+
def _string_value_is_boolean(value):
103+
result = False
104+
if value is not None:
105+
_lower_case_value = value.lower()
106+
if _lower_case_value == 'true' or _lower_case_value == 'false':
107+
result = True
108+
return result
109+
110+
102111
class PythonToJava(object):
103112
"""
104113
A class that converts a Python dictionary and its contents to the Java types expected by snakeyaml.
@@ -159,7 +168,14 @@ def convert_scalar_to_java_type(self, py_value):
159168
elif type(py_value) is bool:
160169
result = JBoolean(py_value is True)
161170
elif type(py_value) in [str, unicode]:
162-
result = JString(py_value)
171+
# If the string is a legal boolean value, convert to a java.lang.Boolean
172+
# to allow the SnakeYAML dump function to write the value without quotes.
173+
#
174+
if _string_value_is_boolean(py_value):
175+
is_true = py_value.lower() == 'true'
176+
result = JBoolean(is_true)
177+
else:
178+
result = JString(py_value)
163179
elif type(py_value) is int:
164180
result = JInteger(py_value)
165181
elif type(py_value) is long:

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
# This is a WDT filter for primordial domain creation. It filters out all resources and
88
# apps deployments, leaving only the domainInfo and admin server in topology.
99
#
10+
11+
from wlsdeploy.aliases import alias_utils
12+
13+
1014
def filter_model(model):
1115
__cleanup_topology(model)
1216
__cleanup_resources(model)
@@ -52,7 +56,9 @@ def __cleanup_topology(model):
5256
if topology.has_key('ServerTemplate'):
5357
server_templates = topology['ServerTemplate']
5458
for server_template in server_templates:
55-
server_templates[server_template]['AutoMigrationEnabled'] = False
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'] = False
5662
for delthis in ['ServerStart']:
5763
if server_templates[server_template].has_key(delthis):
5864
del server_templates[server_template][delthis]

core/src/main/targetconfigs/vz/vz_filter.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
# Remove partition, resource group elements.
99
# Remove machine, node manager, virtual target, migration elements
1010

11+
from wlsdeploy.aliases import alias_utils
12+
1113

1214
def filter_model(model):
1315
__cleanup_topology(model)
@@ -56,7 +58,9 @@ def __cleanup_topology(model):
5658
if topology.has_key('ServerTemplate'):
5759
server_templates = topology['ServerTemplate']
5860
for server_template in server_templates:
59-
server_templates[server_template]['AutoMigrationEnabled'] = False
61+
auto_migration_enabled = server_templates[server_template]['AutoMigrationEnabled']
62+
if auto_migration_enabled is None or alias_utils.convert_boolean(auto_migration_enabled):
63+
server_templates[server_template]['AutoMigrationEnabled'] = False
6064
for delthis in ['ServerStart']:
6165
if server_templates[server_template].has_key(delthis):
6266
del server_templates[server_template][delthis]

core/src/main/targetconfigs/wko/wko_operator_filter.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2020, 2021, Oracle Corporation and/or its affiliates.
1+
# Copyright (c) 2020, 2022, Oracle Corporation and/or its affiliates.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33
#
44
# ------------
@@ -7,6 +7,10 @@
77
# This is a WDT filter for primordial domain creation. It filters out all resources and
88
# apps deployments, leaving only the domainInfo and admin server in topology.
99
#
10+
11+
from wlsdeploy.aliases import alias_utils
12+
13+
1014
def filter_model(model):
1115
__cleanup_topology(model)
1216
__cleanup_resources(model)
@@ -52,7 +56,9 @@ def __cleanup_topology(model):
5256
if topology.has_key('ServerTemplate'):
5357
server_templates = topology['ServerTemplate']
5458
for server_template in server_templates:
55-
server_templates[server_template]['AutoMigrationEnabled'] = False
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'] = False
5662
for delthis in ['ServerStart']:
5763
if server_templates[server_template].has_key(delthis):
5864
del server_templates[server_template][delthis]

0 commit comments

Comments
 (0)