Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cyber-sandbox-creator
Manage
Activity
Members
Labels
Plan
Issues
10
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MUNI-KYPO-CSC
cyber-sandbox-creator
Commits
528fddc9
Commit
528fddc9
authored
4 years ago
by
Attila Farkas
Browse files
Options
Downloads
Patches
Plain Diff
fix routing on debian
parent
1842ffed
No related branches found
No related tags found
1 merge request
!13
Resolve "Integrate KYPO CRP interface Ansible role to Creator"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/routing_generator.py
+9
-9
9 additions, 9 deletions
modules/routing_generator.py
with
9 additions
and
9 deletions
modules/routing_generator.py
+
9
−
9
View file @
528fddc9
...
...
@@ -114,24 +114,21 @@ def _add_default_route(default_gateway, target_interface_ip, interface_mask,
def
_configure_auto_on_ansible_interface
(
target_routes_list
,
is_border_router
=
False
):
default_route
=
"
{{ ansible_default_ipv4.gateway }}
"
):
"""
Call interfaces role on the main interface to set auto.
"""
new_interface
=
dict
()
new_interface
[
"
interface_ip
"
]
=
"
{{ ansible_default_ipv4.address |
"
\
"
default(ansible_all_ipv4_addresses[0]) }}
"
new_interface
[
"
interface_netmask
"
]
=
"
{{ ansible_default_ipv4.netmask |
"
\
"
default(
'
24
'
) }}
"
if
is_border_router
:
new_interface
[
"
interface_default_gateway
"
]
=
\
"
{{ ansible_default_ipv4.gateway }}
"
new_interface
[
"
interface_default_gateway
"
]
=
default_route
target_routes_list
.
insert
(
0
,
new_interface
)
def
_create_host_routing
(
target_host_name
,
input_definitions
,
flags
):
"""
Generate list of routes for the given host.
"""
routes
=
[]
if
"
border_router
"
in
flags
and
flags
[
"
border_router
"
]:
_configure_auto_on_ansible_interface
(
routes
)
mapping
=
None
for
host_mapping
in
input_definitions
[
"
net_mappings
"
]:
...
...
@@ -143,10 +140,12 @@ def _create_host_routing(target_host_name, input_definitions, flags):
raise
ValueError
(
"
Host was not found:
"
+
target_host_name
)
if
flags
[
"
border_router
"
]:
_configure_auto_on_ansible_interface
(
routes
,
""
)
gateway
=
_find_router_in_network
(
mapping
[
"
network
"
],
input_definitions
)
if_netmask
=
_find_netmask
(
mapping
[
"
ip
"
],
input_definitions
)
_add_default_route
(
gateway
,
mapping
[
"
ip
"
],
if_netmask
,
routes
)
else
:
_configure_auto_on_ansible_interface
(
routes
)
for
network
in
input_definitions
[
"
networks
"
]:
if
network
[
"
name
"
]
==
mapping
[
"
network
"
]:
continue
...
...
@@ -167,15 +166,16 @@ def _create_host_routing(target_host_name, input_definitions, flags):
def
_create_router_routing
(
router_name
,
input_definitions
,
flags
):
"""
Generate list of routes for the given router.
"""
routes
=
[]
if
"
border_router
"
in
flags
and
flags
[
"
border_router
"
]:
_configure_auto_on_ansible_interface
(
routes
)
if
flags
[
"
border_router
"
]:
_configure_auto_on_ansible_interface
(
routes
,
""
)
interface_ip
=
_find_iface_ip_in_network
(
router_name
,
BORDER_ROUTER_NETWORK_NAME
,
input_definitions
)
net_ip
,
mask
=
BORDER_ROUTER_NETWORK_IP
.
split
(
"
/
"
)
_add_default_route
(
BORDER_ROUTER_IP
,
interface_ip
,
mask
,
routes
)
else
:
_configure_auto_on_ansible_interface
(
routes
)
return
routes
...
...
@@ -183,7 +183,7 @@ def _create_router_routing(router_name, input_definitions, flags):
def
_create_border_router_routing
(
input_definitions
):
"""
Generate routes for the border router.
"""
routes
=
[]
_configure_auto_on_ansible_interface
(
routes
,
True
)
_configure_auto_on_ansible_interface
(
routes
)
for
network
in
input_definitions
[
"
networks
"
]:
if
network
[
"
name
"
]
==
BORDER_ROUTER_NETWORK_NAME
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment