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
51ffc223
Verified
Commit
51ffc223
authored
1 year ago
by
Karel van Klink
Browse files
Options
Downloads
Patches
Plain Diff
use a conditional to skip a step in terminate_router
parent
3d1d07b9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!128
Feature/use conditionals
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
gso/workflows/router/create_router.py
+1
-2
1 addition, 2 deletions
gso/workflows/router/create_router.py
gso/workflows/router/terminate_router.py
+6
-7
6 additions, 7 deletions
gso/workflows/router/terminate_router.py
with
7 additions
and
9 deletions
gso/workflows/router/create_router.py
+
1
−
2
View file @
51ffc223
...
...
@@ -2,12 +2,11 @@
from
typing
import
Any
# noinspection PyProtectedMember
from
orchestrator.forms
import
FormPage
from
orchestrator.forms.validators
import
Choice
from
orchestrator.targets
import
Target
from
orchestrator.types
import
FormGenerator
,
State
,
SubscriptionLifecycle
,
UUIDstr
from
orchestrator.workflow
import
StepList
,
done
,
init
,
step
,
workflow
,
conditional
from
orchestrator.workflow
import
StepList
,
conditional
,
done
,
init
,
step
,
workflow
from
orchestrator.workflows.steps
import
resync
,
set_status
,
store_process_subscription
from
orchestrator.workflows.utils
import
wrap_create_initial_input_form
from
pydantic
import
validator
...
...
This diff is collapsed.
Click to expand it.
gso/workflows/router/terminate_router.py
+
6
−
7
View file @
51ffc223
...
...
@@ -26,7 +26,7 @@ logger = logging.getLogger(__name__)
def
initial_input_form_generator
(
subscription_id
:
UUIDstr
)
->
FormGenerator
:
"""
Let the operator decide whether to delete configuration on the router, and clear up :term:`IPAM` resources.
"""
Router
.
from_subscription
(
subscription_id
)
router
=
Router
.
from_subscription
(
subscription_id
)
class
TerminateForm
(
FormPage
):
termination_label
:
Label
=
(
...
...
@@ -38,7 +38,7 @@ def initial_input_form_generator(subscription_id: UUIDstr) -> FormGenerator:
clean_up_ipam
:
bool
=
True
user_input
=
yield
TerminateForm
return
user_input
.
dict
()
return
user_input
.
dict
()
|
{
"
router_is_nokia
"
:
router
.
router
.
vendor
==
RouterVendor
.
NOKIA
}
@step
(
"
Deprovision loopback IPs from IPAM
"
)
...
...
@@ -58,12 +58,10 @@ def remove_config_from_router() -> None:
"""
@step
(
"
Remove Device from Net
B
ox
"
)
@step
(
"
Remove Device from Net
b
ox
"
)
def
remove_device_from_netbox
(
subscription
:
Router
)
->
dict
[
str
,
Router
]:
"""
Remove the device from Netbox.
"""
if
subscription
.
router
.
vendor
==
RouterVendor
.
NOKIA
:
# TODO: This should be solved with a conditional
NetboxClient
().
delete_device
(
subscription
.
router
.
router_fqdn
)
NetboxClient
().
delete_device
(
subscription
.
router
.
router_fqdn
)
return
{
"
subscription
"
:
subscription
}
...
...
@@ -82,6 +80,7 @@ def terminate_router() -> StepList:
"""
run_ipam_steps
=
conditional
(
lambda
state
:
state
[
"
clean_up_ipam
"
])
run_config_steps
=
conditional
(
lambda
state
:
state
[
"
remove_configuration
"
])
router_is_nokia
=
conditional
(
lambda
state
:
state
[
"
router_is_nokia
"
])
return
(
init
...
...
@@ -89,7 +88,7 @@ def terminate_router() -> StepList:
>>
unsync
>>
run_ipam_steps
(
deprovision_loopback_ips
)
>>
run_config_steps
(
remove_config_from_router
)
>>
remove_device_from_netbox
>>
router_is_nokia
(
remove_device_from_netbox
)
>>
set_status
(
SubscriptionLifecycle
.
TERMINATED
)
>>
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