Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
T
tun
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Railgun
tun
Commits
17364bd0
Commit
17364bd0
authored
Dec 29, 2020
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
exclude self-contained route plans
parent
74ea908e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
11 deletions
+16
-11
src/inventory.ts
src/inventory.ts
+16
-11
No files found.
src/inventory.ts
View file @
17364bd0
...
@@ -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
,
"
_
"
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment