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
7d8f2630
Verified
Commit
7d8f2630
authored
1 year ago
by
Karel van Klink
Browse files
Options
Downloads
Patches
Plain Diff
use conditionals in IP trunk migration workflow
parent
02d70cb8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!128
Feature/use conditionals
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
gso/workflows/iptrunk/migrate_iptrunk.py
+37
-30
37 additions, 30 deletions
gso/workflows/iptrunk/migrate_iptrunk.py
with
37 additions
and
30 deletions
gso/workflows/iptrunk/migrate_iptrunk.py
+
37
−
30
View file @
7d8f2630
...
...
@@ -164,7 +164,6 @@ def initial_input_form_generator(subscription_id: UUIDstr) -> FormGenerator:
|
new_side_iptrunk_router_input
.
dict
()
|
new_side_input
.
dict
()
|
{
"
replace_index
"
:
replace_index
}
|
{
"
new_side_is_nokia
"
:
new_side_is_nokia
}
)
...
...
@@ -526,8 +525,8 @@ def update_subscription_model(
return
{
"
subscription
"
:
subscription
,
"
old_side_data
"
:
old_side_data
}
@step
(
"
Reserve interfaces
in Netbox
"
)
def
reserve_interfaces
_in_netbox
(
@step
(
"
Netbox:
Reserve
new
interfaces
"
)
def
netbox_
reserve_interfaces
(
subscription
:
Iptrunk
,
new_node
:
UUIDstr
,
new_lag_interface
:
str
,
...
...
@@ -560,34 +559,37 @@ def reserve_interfaces_in_netbox(
return
{
"
subscription
"
:
subscription
}
@step
(
"
Update Netbox. Allocate new interfaces and deallocate old ones.
"
)
def
update_netbox
(
subscription
:
Iptrunk
,
replace_index
:
int
,
old_side_data
:
dict
,
)
->
State
:
"""
Update Netbox, reallocating the old and new interfaces.
"""
new_side
=
subscription
.
iptrunk
.
iptrunk_sides
[
replace_index
]
@step
(
"
Netbox: Remove old LAG interface
"
)
def
netbox_remove_old_interfaces
(
old_side_data
:
dict
)
->
State
:
"""
Remove the old :term:`LAG` interface from Netbox, only relevant if the old side is a Nokia router.
"""
nbclient
=
NetboxClient
()
if
get_router_vendor
(
new_side
.
iptrunk_side_node
.
owner_subscription_id
)
==
RouterVendor
.
NOKIA
:
for
interface
in
new_side
.
iptrunk_side_ae_members
:
nbclient
.
allocate_interface
(
device_name
=
new_side
.
iptrunk_side_node
.
router_fqdn
,
iface_name
=
interface
.
interface_name
,
)
if
get_router_vendor
(
old_side_data
[
"
iptrunk_side_node
"
][
"
owner_subscription_id
"
])
==
RouterVendor
.
NOKIA
:
# Set interfaces to free
for
iface
in
old_side_data
[
"
iptrunk_side_ae_members
"
]:
nbclient
.
free_interface
(
old_side_data
[
"
iptrunk_side_node
"
][
"
router_fqdn
"
],
iface
[
"
interface_name
"
],
)
# Delete :term:`LAG` interfaces
nbclient
.
delet
e_interface
(
for
iface
in
old_side_data
[
"
iptrunk_side_ae_members
"
]:
nbclient
.
fre
e_interface
(
old_side_data
[
"
iptrunk_side_node
"
][
"
router_fqdn
"
],
old_side_data
[
"
iptrunk_side_ae_iface
"
],
iface
[
"
interface_name
"
],
)
nbclient
.
delete_interface
(
old_side_data
[
"
iptrunk_side_node
"
][
"
router_fqdn
"
],
old_side_data
[
"
iptrunk_side_ae_iface
"
],
)
return
{}
@step
(
"
Netbox: Allocate new LAG member interfaces
"
)
def
netbox_allocate_new_interfaces
(
subscription
:
Iptrunk
,
replace_index
:
int
)
->
State
:
"""
Allocate the new :term:`LAG` interface in Netbox. Only relevant if the new router is a Nokia.
"""
nbclient
=
NetboxClient
()
new_side
=
subscription
.
iptrunk
.
iptrunk_sides
[
replace_index
]
for
interface
in
new_side
.
iptrunk_side_ae_members
:
nbclient
.
allocate_interface
(
device_name
=
new_side
.
iptrunk_side_node
.
router_fqdn
,
iface_name
=
interface
.
interface_name
,
)
return
{
"
subscription
"
:
subscription
}
...
...
@@ -614,14 +616,18 @@ def migrate_iptrunk() -> StepList:
TODO: add interface checks
"""
new_side_is_nokia
=
conditional
(
lambda
state
:
state
[
"
new_side_is_nokia
"
])
new_side_is_nokia
=
conditional
(
lambda
state
:
get_router_vendor
(
state
[
"
new_node
"
])
==
RouterVendor
.
NOKIA
)
old_side_is_nokia
=
conditional
(
lambda
state
:
get_router_vendor
(
state
[
"
old_side_data
"
][
"
iptrunk_side_node
"
][
"
owner_subscription_id
"
])
==
RouterVendor
.
NOKIA
)
should_restore_isis_metric
=
conditional
(
lambda
state
:
state
[
"
restore_isis_metric
"
])
return
(
init
>>
store_process_subscription
(
Target
.
MODIFY
)
>>
unsync
>>
new_side_is_nokia
(
reserve_interfaces
_in_netbox
)
>>
new_side_is_nokia
(
netbox_
reserve_interfaces
)
>>
pp_interaction
(
set_isis_to_90000
)
>>
pp_interaction
(
disable_old_config_dry
)
>>
pp_interaction
(
disable_old_config_real
)
...
...
@@ -635,7 +641,8 @@ def migrate_iptrunk() -> StepList:
>>
pp_interaction
(
delete_old_config_real
)
>>
update_ipam
>>
update_subscription_model
>>
update_netbox
>>
old_side_is_nokia
(
netbox_remove_old_interfaces
)
>>
new_side_is_nokia
(
netbox_allocate_new_interfaces
)
>>
resync
>>
done
)
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