Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
GÉANT Service Orchestrator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
GÉANT Orchestration and Automation Team
GAP
GÉANT Service Orchestrator
Commits
4b015e72
Commit
4b015e72
authored
9 months ago
by
Karel van Klink
Committed by
Neda Moeini
8 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Externalise the generation of an active PE-router dict
parent
1b0e5797
No related branches found
Branches containing commit
Tags
2.0
Tags containing commit
1 merge request
!139
Feature/add validation workflows
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
gso/services/subscriptions.py
+21
-0
21 additions, 0 deletions
gso/services/subscriptions.py
gso/workflows/router/update_ibgp_mesh.py
+4
-37
4 additions, 37 deletions
gso/workflows/router/update_ibgp_mesh.py
with
25 additions
and
37 deletions
gso/services/subscriptions.py
+
21
−
0
View file @
4b015e72
...
...
@@ -20,6 +20,8 @@ from orchestrator.types import SubscriptionLifecycle
from
pydantic_forms.types
import
UUIDstr
from
gso.products
import
ProductName
,
ProductType
from
gso.products.product_blocks.router
import
RouterRole
from
gso.products.product_types.router
import
Router
from
gso.products.product_types.site
import
Site
SubscriptionType
=
dict
[
str
,
Any
]
...
...
@@ -220,3 +222,22 @@ def get_site_by_name(site_name: str) -> Site:
raise
ValueError
(
msg
)
return
Site
.
from_subscription
(
subscription
[
0
].
subscription_id
)
def
get_active_pe_router_dict
()
->
dict
[
str
,
Any
]:
"""
Generate an Ansible-compatible inventory for executing playbooks. Contains all active PE routers.
"""
all_routers
=
[
Router
.
from_subscription
(
r
[
"
subscription_id
"
])
for
r
in
get_active_router_subscriptions
()]
return
{
"
all
"
:
{
"
hosts
"
:
{
router
.
router
.
router_fqdn
:
{
"
lo4
"
:
str
(
router
.
router
.
router_lo_ipv4_address
),
"
lo6
"
:
str
(
router
.
router
.
router_lo_ipv6_address
),
"
vendor
"
:
str
(
router
.
router
.
vendor
),
}
for
router
in
all_routers
if
router
.
router
.
router_role
==
RouterRole
.
PE
}
},
}
This diff is collapsed.
Click to expand it.
gso/workflows/router/update_ibgp_mesh.py
+
4
−
37
View file @
4b015e72
...
...
@@ -12,7 +12,6 @@ from orchestrator.workflows.steps import resync, store_process_subscription, uns
from
orchestrator.workflows.utils
import
wrap_modify_initial_input_form
from
pydantic
import
ConfigDict
,
model_validator
from
gso.products.product_blocks.router
import
RouterRole
from
gso.products.product_types.router
import
Router
from
gso.services
import
librenms_client
,
lso_client
,
subscriptions
from
gso.services.lso_client
import
lso_interaction
...
...
@@ -49,37 +48,8 @@ def initial_input_form_generator(subscription_id: UUIDstr) -> FormGenerator:
return
user_input
.
model_dump
()
@step
(
"
Calculate list of all active PE routers
"
)
def
calculate_pe_router_list
()
->
State
:
"""
Calculate a list of all active PE routers in the network.
"""
all_routers
=
[
Router
.
from_subscription
(
r
[
"
subscription_id
"
])
for
r
in
subscriptions
.
get_active_router_subscriptions
()
]
all_pe_routers
=
[
router
for
router
in
all_routers
if
router
.
router
.
router_role
==
RouterRole
.
PE
]
return
{
"
pe_router_list
"
:
all_pe_routers
}
def
_generate_pe_inventory
(
pe_router_list
:
list
[
Router
])
->
dict
[
str
,
Any
]:
"""
Generate an Ansible-compatible inventory for executing playbooks. Contains all active PE routers.
"""
return
{
"
all
"
:
{
"
hosts
"
:
{
router
.
router
.
router_fqdn
:
{
"
lo4
"
:
str
(
router
.
router
.
router_lo_ipv4_address
),
"
lo6
"
:
str
(
router
.
router
.
router_lo_ipv6_address
),
"
vendor
"
:
str
(
router
.
router
.
vendor
),
}
for
router
in
pe_router_list
}
},
}
@step
(
"
[DRY RUN] Add P router to iBGP mesh
"
)
def
add_p_to_mesh_dry
(
subscription
:
dict
[
str
,
Any
],
callback_route
:
str
,
pe_router_list
:
list
[
Router
],
tt_number
:
str
,
process_id
:
UUIDstr
)
->
None
:
def
add_p_to_mesh_dry
(
subscription
:
dict
[
str
,
Any
],
callback_route
:
str
,
tt_number
:
str
,
process_id
:
UUIDstr
)
->
None
:
"""
Perform a dry run of adding the new P router to the PE router mesh.
"""
extra_vars
=
{
"
dry_run
"
:
True
,
...
...
@@ -91,15 +61,13 @@ def add_p_to_mesh_dry(
lso_client
.
execute_playbook
(
playbook_name
=
"
update_ibgp_mesh.yaml
"
,
callback_route
=
callback_route
,
inventory
=
_generate_pe_inventory
(
pe_router_
list
),
inventory
=
subscriptions
.
get_active_
pe_router_
dict
(
),
extra_vars
=
extra_vars
,
)
@step
(
"
[FOR REAL] Add P router to iBGP mesh
"
)
def
add_p_to_mesh_real
(
subscription
:
dict
[
str
,
Any
],
callback_route
:
str
,
pe_router_list
:
list
[
Router
],
tt_number
:
str
,
process_id
:
UUIDstr
)
->
None
:
def
add_p_to_mesh_real
(
subscription
:
dict
[
str
,
Any
],
callback_route
:
str
,
tt_number
:
str
,
process_id
:
UUIDstr
)
->
None
:
"""
Add the P router to the mesh of PE routers.
"""
extra_vars
=
{
"
dry_run
"
:
False
,
...
...
@@ -111,7 +79,7 @@ def add_p_to_mesh_real(
lso_client
.
execute_playbook
(
playbook_name
=
"
update_ibgp_mesh.yaml
"
,
callback_route
=
callback_route
,
inventory
=
_generate_pe_inventory
(
pe_router_
list
),
inventory
=
subscriptions
.
get_active_
pe_router_
dict
(
),
extra_vars
=
extra_vars
,
)
...
...
@@ -251,7 +219,6 @@ def update_ibgp_mesh() -> StepList:
begin
>>
store_process_subscription
(
Target
.
MODIFY
)
>>
unsync
>>
calculate_pe_router_list
>>
lso_interaction
(
add_p_to_mesh_dry
)
>>
lso_interaction
(
add_p_to_mesh_real
)
>>
lso_interaction
(
add_all_pe_to_p_dry
)
...
...
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