|
1 |
| -# Copyright (c) 2020, 2022, Oracle and/or its affiliates. |
| 1 | +# Copyright (c) 2020, 2023, Oracle and/or its affiliates. |
2 | 2 | # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
|
3 | 3 | #
|
4 | 4 | # Shared methods for using target environments (-target abc).
|
|
11 | 11 | from oracle.weblogic.deploy.util import FileUtils
|
12 | 12 |
|
13 | 13 | from wlsdeploy.aliases.model_constants import ADMIN_PASSWORD
|
| 14 | +from wlsdeploy.aliases.model_constants import ADMIN_SERVER_NAME |
14 | 15 | from wlsdeploy.aliases.model_constants import ADMIN_USERNAME
|
15 | 16 | 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 |
16 | 19 | from wlsdeploy.aliases.model_constants import TOPOLOGY
|
17 | 20 | from wlsdeploy.exception import exception_helper
|
18 | 21 | from wlsdeploy.logging.platform_logger import PlatformLogger
|
@@ -225,7 +228,8 @@ def generate_results_json(model_context, token_dictionary, model_dictionary, exc
|
225 | 228 | result = {
|
226 | 229 | 'domainUID': domain_uid,
|
227 | 230 | '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) |
229 | 233 | }
|
230 | 234 | json_object = PythonToJson(result)
|
231 | 235 |
|
@@ -269,6 +273,30 @@ def _build_json_cluster_result(model_dictionary):
|
269 | 273 | return clusters_map
|
270 | 274 |
|
271 | 275 |
|
| 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 | + |
272 | 300 | def format_as_secret_token(secret_id, target_config):
|
273 | 301 | """
|
274 | 302 | Format the secret identifier as an @@SECRET token for use in a model.
|
|
0 commit comments