Commit 17364bd0 authored by nanahira's avatar nanahira

exclude self-contained route plans

parent 74ea908e
...@@ -158,30 +158,35 @@ class InventoryBuilder { ...@@ -158,30 +158,35 @@ class InventoryBuilder {
} }
return addresses.join(" "); return addresses.join(" ");
} }
getAddressesFromGatewayGroup(gatewayGroup: GatewayGroup, hosts: any[]) { isGatewayGroupContains(gatewayGroup: GatewayGroup, host: any) {
const locationPrefixes = gatewayGroup.locationPrefix.split(","); const locationPrefixes = gatewayGroup.locationPrefix.split(",");
const excludeRouters = gatewayGroup.excludeRouters.split(","); const excludeRouters = gatewayGroup.excludeRouters.split(",");
const includeRouters = gatewayGroup.includeRouters.split(","); const includeRouters = gatewayGroup.includeRouters.split(",");
const children = gatewayGroup.children.split(","); const children = gatewayGroup.children.split(",");
const suitableHosts = hosts.filter(host => { if (excludeRouters.includes(host.name)) {
if (excludeRouters.includes(host.name)) { return false;
return false; }
} if (locationPrefixes.some(prefix => prefix !== "" && (host.location as string).startsWith(prefix)) || includeRouters.includes(host.name)) {
return locationPrefixes.some(prefix => prefix !== "" && (host.location as string).startsWith(prefix)) || includeRouters.includes(host.name); return true;
}); }
let addresses = suitableHosts.map(host => host.address);
for (let childName of children) { for (let childName of children) {
const targetGatewayGroup = this.gatewayGroups.find(g => g.name === childName); const targetGatewayGroup = this.gatewayGroups.find(g => g.name === childName);
if (!targetGatewayGroup) { if (!targetGatewayGroup) {
continue; 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) { getRoutePlansFromGatewayGroups(host: any) {
const allOtherHosts = this.connections.filter(h => h !== host.name).map(h => this.hosts[h]); 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); const addresses = this.getAddressesFromGatewayGroup(group, allOtherHosts);
return { return {
name: group.name.replace(/-/g, "_"), 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