Skip to content

Commit 75bc825

Browse files
committed
Use BooleanValue class in filters to put boolean values into YAML; check for bool in 14.1.1
1 parent 2b5bdc8 commit 75bc825

File tree

7 files changed

+14
-24
lines changed

7 files changed

+14
-24
lines changed

core/src/main/java/oracle/weblogic/deploy/util/PyOrderedDict.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, 2021, Oracle Corporation and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2017, 2022, Oracle Corporation and/or its affiliates. All rights reserved.
33
* Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
44
*/
55
package oracle.weblogic.deploy.util;
@@ -521,6 +521,7 @@ private static PyObject doDeepCopy(PyObject orig, PyObject memo) {
521521
case "NoneType":
522522
case "str":
523523
case "unicode":
524+
case "BooleanValue":
524525
result = orig;
525526
break;
526527

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from wlsdeploy.logging.platform_logger import PlatformLogger
2121
from wlsdeploy.tool.util.filters.model_traverse import ModelTraverse
2222
from wlsdeploy.util import dictionary_utils
23+
from wlsdeploy.util.boolean_value import BooleanValue
2324

2425
_class_name = 'wko_filter'
2526
_logger = PlatformLogger('wlsdeploy.tool.util')
@@ -68,7 +69,7 @@ def check_clustered_server_ports(model, _model_context):
6869
if (calculated_listen_ports is None) or alias_utils.convert_boolean(calculated_listen_ports):
6970
_logger.info('WLSDPLY-20202', CALCULATED_LISTEN_PORTS, CLUSTER, cluster_name, class_name=_class_name,
7071
method_name=_method_name)
71-
dynamic_folder[CALCULATED_LISTEN_PORTS] = False
72+
dynamic_folder[CALCULATED_LISTEN_PORTS] = BooleanValue(False)
7273

7374
# be sure every server assigned to a cluster has the same listen port
7475

core/src/main/python/wlsdeploy/tool/validate/validation_utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ def is_compatible_data_type(expected_data_type, actual_data_type):
123123
elif expected_data_type == 'long':
124124
retval = (actual_data_type in ["<type 'int'>", "<type 'long'>", "<type 'str'>", "<type 'unicode'>"])
125125
elif expected_data_type in ['boolean', 'java.lang.Boolean']:
126-
retval = (actual_data_type in ["<type 'int'>", "<type 'str'>", "<type 'long'>", "<type 'unicode'>"])
126+
retval = (actual_data_type in ["<type 'int'>", "<type 'str'>", "<type 'long'>", "<type 'unicode'>",
127+
"<type 'bool'>", "<class 'wlsdeploy.util.boolean_value.BooleanValue'>"])
127128
elif expected_data_type in ['float', 'double']:
128129
retval = (actual_data_type in ["<type 'float'>", "<type 'str'>", "<type 'unicode'>"])
129130
elif expected_data_type == 'properties' or expected_data_type == 'dict':

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

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,6 @@ 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-
111102
class PythonToJava(object):
112103
"""
113104
A class that converts a Python dictionary and its contents to the Java types expected by snakeyaml.
@@ -168,14 +159,7 @@ def convert_scalar_to_java_type(self, py_value):
168159
elif type(py_value) is bool:
169160
result = JBoolean(py_value is True)
170161
elif type(py_value) in [str, unicode]:
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)
162+
result = JString(py_value)
179163
elif type(py_value) is int:
180164
result = JInteger(py_value)
181165
elif type(py_value) is long:

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#
1010

1111
from wlsdeploy.aliases import alias_utils
12+
from wlsdeploy.util.boolean_value import BooleanValue
1213

1314

1415
def filter_model(model):
@@ -58,7 +59,7 @@ def __cleanup_topology(model):
5859
for server_template in server_templates:
5960
auto_migration_enabled = server_templates[server_template]['AutoMigrationEnabled']
6061
if auto_migration_enabled is None or alias_utils.convert_boolean(auto_migration_enabled):
61-
server_templates[server_template]['AutoMigrationEnabled'] = False
62+
server_templates[server_template]['AutoMigrationEnabled'] = BooleanValue(False)
6263
for delthis in ['ServerStart']:
6364
if server_templates[server_template].has_key(delthis):
6465
del server_templates[server_template][delthis]

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

Lines changed: 3 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
# ------------
@@ -9,6 +9,7 @@
99
# Remove machine, node manager, virtual target, migration elements
1010

1111
from wlsdeploy.aliases import alias_utils
12+
from wlsdeploy.util.boolean_value import BooleanValue
1213

1314

1415
def filter_model(model):
@@ -60,7 +61,7 @@ def __cleanup_topology(model):
6061
for server_template in server_templates:
6162
auto_migration_enabled = server_templates[server_template]['AutoMigrationEnabled']
6263
if auto_migration_enabled is None or alias_utils.convert_boolean(auto_migration_enabled):
63-
server_templates[server_template]['AutoMigrationEnabled'] = False
64+
server_templates[server_template]['AutoMigrationEnabled'] = BooleanValue(False)
6465
for delthis in ['ServerStart']:
6566
if server_templates[server_template].has_key(delthis):
6667
del server_templates[server_template][delthis]

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#
1010

1111
from wlsdeploy.aliases import alias_utils
12+
from wlsdeploy.util.boolean_value import BooleanValue
1213

1314

1415
def filter_model(model):
@@ -58,7 +59,7 @@ def __cleanup_topology(model):
5859
for server_template in server_templates:
5960
auto_migration_enabled = server_templates[server_template]['AutoMigrationEnabled']
6061
if auto_migration_enabled is None or alias_utils.convert_boolean(auto_migration_enabled):
61-
server_templates[server_template]['AutoMigrationEnabled'] = False
62+
server_templates[server_template]['AutoMigrationEnabled'] = BooleanValue(False)
6263
for delthis in ['ServerStart']:
6364
if server_templates[server_template].has_key(delthis):
6465
del server_templates[server_template][delthis]

0 commit comments

Comments
 (0)