Get node
parent
5cae4e2175
commit
4c8d37b602
|
@ -2,29 +2,33 @@ var resp = api.env.control.GetEnvs();
|
|||
if (resp.result !== 0) return resp;
|
||||
var envs = [];
|
||||
|
||||
for (var i = 0, envInfo; envInfo = resp.infos[i]; i++) {
|
||||
for (var i = 0; i < resp.infos.length; i++) {
|
||||
var envInfo = resp.infos[i];
|
||||
var env = envInfo.env;
|
||||
if (env.status == 1) { // Check if environment is active
|
||||
var hasStorageNode = false;
|
||||
for (var j = 0, node; node = envInfo.nodes[j]; j++) {
|
||||
// Correctly filter nodes by 'storage' nodeGroup
|
||||
// Assuming an environment not part of any group has an empty or undefined envGroups array
|
||||
var isGroupless = !envInfo.envGroups || envInfo.envGroups.length === 0;
|
||||
|
||||
if (env.status == 1 && isGroupless) { // Check if environment is active and not part of any envGroup
|
||||
for (var j = 0; j < envInfo.nodes.length; j++) {
|
||||
var node = envInfo.nodes[j];
|
||||
// Filter nodes by 'storage' nodeGroup
|
||||
if (node.nodeGroup === "storage") {
|
||||
hasStorageNode = true;
|
||||
break; // Exit loop once a storage node is found
|
||||
envs.push({
|
||||
value: env.envName,
|
||||
caption: (env.displayName + " (" + env.envName + ")" || env.envName)
|
||||
});
|
||||
break; // Found a storage node, no need to check further nodes in this environment
|
||||
}
|
||||
}
|
||||
if (hasStorageNode) {
|
||||
envs.push({
|
||||
value: env.envName,
|
||||
caption: (env.displayName + " (" + env.envName + ")" || env.envName)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (envs.length > 0) {
|
||||
jps.settings.main.fields[1].values = envs;
|
||||
jps.settings.main.fields[1].default = envs[0].value;
|
||||
} else {
|
||||
// Handle the case where no environments match the criteria
|
||||
console.log("No environments with storage nodes found that are not part of any envGroup.");
|
||||
}
|
||||
|
||||
import java.util.TimeZone;
|
||||
|
|
Loading…
Reference in New Issue