Commit 17364bd0 authored by nanahira's avatar nanahira

exclude self-contained route plans

parent 74ea908e
......@@ -158,30 +158,35 @@ class InventoryBuilder {
}
return addresses.join(" ");
}
getAddressesFromGatewayGroup(gatewayGroup: GatewayGroup, hosts: any[]) {
isGatewayGroupContains(gatewayGroup: GatewayGroup, host: any) {
const locationPrefixes = gatewayGroup.locationPrefix.split(",");
const excludeRouters = gatewayGroup.excludeRouters.split(",");
const includeRouters = gatewayGroup.includeRouters.split(",");
const children = gatewayGroup.children.split(",");
const suitableHosts = hosts.filter(host => {
if (excludeRouters.includes(host.name)) {
return false;
}
return locationPrefixes.some(prefix => prefix !== "" && (host.location as string).startsWith(prefix)) || includeRouters.includes(host.name);
});
let addresses = suitableHosts.map(host => host.address);
if (locationPrefixes.some(prefix => prefix !== "" && (host.location as string).startsWith(prefix)) || includeRouters.includes(host.name)) {
return true;
}
for (let childName of children) {
const targetGatewayGroup = this.gatewayGroups.find(g => g.name === childName);
if (!targetGatewayGroup) {
continue;
}
addresses = addresses.concat(this.getAddressesFromGatewayGroup(targetGatewayGroup, hosts));
if (this.isGatewayGroupContains(targetGatewayGroup, host)) {
return true;
}
}
return addresses;
return false;
}
getAddressesFromGatewayGroup(gatewayGroup: GatewayGroup, hosts: any[]) {
const suitableHosts = hosts.filter(host => this.isGatewayGroupContains(gatewayGroup, host));
return suitableHosts.map(host => host.address);
}
getRoutePlansFromGatewayGroups(host: any) {
const allOtherHosts = this.connections.filter(h => h !== host.name).map(h => this.hosts[h]);
const routePlans = this.gatewayGroups.map(group => {
const routePlans = this.gatewayGroups.filter(group => !this.isGatewayGroupContains(group, host)).map(group => {
const addresses = this.getAddressesFromGatewayGroup(group, allOtherHosts);
return {
name: group.name.replace(/-/g, "_"),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment