Skip to content

Commit f5ee0e0

Browse files
authored
Add server list to target JSON result output (#1395)
1 parent b1f5726 commit f5ee0e0

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

core/src/main/python/wlsdeploy/util/target_configuration_helper.py

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2020, 2022, Oracle and/or its affiliates.
1+
# Copyright (c) 2020, 2023, Oracle 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
# Shared methods for using target environments (-target abc).
@@ -11,8 +11,11 @@
1111
from oracle.weblogic.deploy.util import FileUtils
1212

1313
from wlsdeploy.aliases.model_constants import ADMIN_PASSWORD
14+
from wlsdeploy.aliases.model_constants import ADMIN_SERVER_NAME
1415
from wlsdeploy.aliases.model_constants import ADMIN_USERNAME
1516
from wlsdeploy.aliases.model_constants import CLUSTER
17+
from wlsdeploy.aliases.model_constants import DEFAULT_ADMIN_SERVER_NAME
18+
from wlsdeploy.aliases.model_constants import SERVER
1619
from wlsdeploy.aliases.model_constants import TOPOLOGY
1720
from wlsdeploy.exception import exception_helper
1821
from wlsdeploy.logging.platform_logger import PlatformLogger
@@ -225,7 +228,8 @@ def generate_results_json(model_context, token_dictionary, model_dictionary, exc
225228
result = {
226229
'domainUID': domain_uid,
227230
'secrets': _build_json_secrets_result(model_context, token_dictionary, model_dictionary),
228-
'clusters': _build_json_cluster_result(model_dictionary)
231+
'clusters': _build_json_cluster_result(model_dictionary),
232+
'servers': _build_json_server_result(model_dictionary)
229233
}
230234
json_object = PythonToJson(result)
231235

@@ -269,6 +273,30 @@ def _build_json_cluster_result(model_dictionary):
269273
return clusters_map
270274

271275

276+
def _build_json_server_result(model_dictionary):
277+
"""
278+
Build a map containing servers that are not assigned to clusters.
279+
:param model_dictionary: the model to be searched
280+
:return: the map of servers
281+
"""
282+
servers_map = {}
283+
topology = dictionary_utils.get_dictionary_element(model_dictionary, TOPOLOGY)
284+
servers = dictionary_utils.get_dictionary_element(topology, SERVER)
285+
for server_name, server_values in servers.items():
286+
assigned_cluster = dictionary_utils.get_element(server_values, CLUSTER)
287+
if not assigned_cluster:
288+
server_data = {}
289+
servers_map[server_name] = server_data
290+
291+
# admin server may not be specified in the Server section of the model
292+
admin_server = dictionary_utils.get_element(topology, ADMIN_SERVER_NAME, DEFAULT_ADMIN_SERVER_NAME)
293+
if admin_server not in servers_map:
294+
server_data = {}
295+
servers_map[admin_server] = server_data
296+
297+
return servers_map
298+
299+
272300
def format_as_secret_token(secret_id, target_config):
273301
"""
274302
Format the secret identifier as an @@SECRET token for use in a model.

0 commit comments

Comments
 (0)