Skip to content

Add server list to target JSON result output #1395

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions core/src/main/python/wlsdeploy/util/target_configuration_helper.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2020, 2022, Oracle and/or its affiliates.
# Copyright (c) 2020, 2023, Oracle and/or its affiliates.
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
#
# Shared methods for using target environments (-target abc).
Expand All @@ -11,8 +11,11 @@
from oracle.weblogic.deploy.util import FileUtils

from wlsdeploy.aliases.model_constants import ADMIN_PASSWORD
from wlsdeploy.aliases.model_constants import ADMIN_SERVER_NAME
from wlsdeploy.aliases.model_constants import ADMIN_USERNAME
from wlsdeploy.aliases.model_constants import CLUSTER
from wlsdeploy.aliases.model_constants import DEFAULT_ADMIN_SERVER_NAME
from wlsdeploy.aliases.model_constants import SERVER
from wlsdeploy.aliases.model_constants import TOPOLOGY
from wlsdeploy.exception import exception_helper
from wlsdeploy.logging.platform_logger import PlatformLogger
Expand Down Expand Up @@ -225,7 +228,8 @@ def generate_results_json(model_context, token_dictionary, model_dictionary, exc
result = {
'domainUID': domain_uid,
'secrets': _build_json_secrets_result(model_context, token_dictionary, model_dictionary),
'clusters': _build_json_cluster_result(model_dictionary)
'clusters': _build_json_cluster_result(model_dictionary),
'servers': _build_json_server_result(model_dictionary)
}
json_object = PythonToJson(result)

Expand Down Expand Up @@ -269,6 +273,30 @@ def _build_json_cluster_result(model_dictionary):
return clusters_map


def _build_json_server_result(model_dictionary):
"""
Build a map containing servers that are not assigned to clusters.
:param model_dictionary: the model to be searched
:return: the map of servers
"""
servers_map = {}
topology = dictionary_utils.get_dictionary_element(model_dictionary, TOPOLOGY)
servers = dictionary_utils.get_dictionary_element(topology, SERVER)
for server_name, server_values in servers.items():
assigned_cluster = dictionary_utils.get_element(server_values, CLUSTER)
if not assigned_cluster:
server_data = {}
servers_map[server_name] = server_data

# admin server may not be specified in the Server section of the model
admin_server = dictionary_utils.get_element(topology, ADMIN_SERVER_NAME, DEFAULT_ADMIN_SERVER_NAME)
if admin_server not in servers_map:
server_data = {}
servers_map[admin_server] = server_data

return servers_map


def format_as_secret_token(secret_id, target_config):
"""
Format the secret identifier as an @@SECRET token for use in a model.
Expand Down