Get node
parent
5cae4e2175
commit
4c8d37b602
|
@ -2,22 +2,23 @@ var resp = api.env.control.GetEnvs();
|
||||||
if (resp.result !== 0) return resp;
|
if (resp.result !== 0) return resp;
|
||||||
var envs = [];
|
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;
|
var env = envInfo.env;
|
||||||
if (env.status == 1) { // Check if environment is active
|
// Assuming an environment not part of any group has an empty or undefined envGroups array
|
||||||
var hasStorageNode = false;
|
var isGroupless = !envInfo.envGroups || envInfo.envGroups.length === 0;
|
||||||
for (var j = 0, node; node = envInfo.nodes[j]; j++) {
|
|
||||||
// Correctly filter nodes by 'storage' nodeGroup
|
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") {
|
if (node.nodeGroup === "storage") {
|
||||||
hasStorageNode = true;
|
|
||||||
break; // Exit loop once a storage node is found
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hasStorageNode) {
|
|
||||||
envs.push({
|
envs.push({
|
||||||
value: env.envName,
|
value: env.envName,
|
||||||
caption: (env.displayName + " (" + env.envName + ")" || env.envName)
|
caption: (env.displayName + " (" + env.envName + ")" || env.envName)
|
||||||
});
|
});
|
||||||
|
break; // Found a storage node, no need to check further nodes in this environment
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,6 +26,9 @@ for (var i = 0, envInfo; envInfo = resp.infos[i]; i++) {
|
||||||
if (envs.length > 0) {
|
if (envs.length > 0) {
|
||||||
jps.settings.main.fields[1].values = envs;
|
jps.settings.main.fields[1].values = envs;
|
||||||
jps.settings.main.fields[1].default = envs[0].value;
|
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;
|
import java.util.TimeZone;
|
||||||
|
|
Loading…
Reference in New Issue