Skip to content
Snippets Groups Projects
Commit 33b47527 authored by Karel van Klink's avatar Karel van Klink :smiley_cat: Committed by Simone Spinelli
Browse files

update intake form of device termination workflow

added two checkboxes that take care of removing config, and cleaning up IPAM
made the corresponding steps in the workflow conditional, so they are skipped if unchecked
parent 161bc453
No related branches found
No related tags found
1 merge request!52Feature/nat 212 213
...@@ -29,7 +29,9 @@ ...@@ -29,7 +29,9 @@
"iptrunk_sideB_ae_iface": "Aggregated Ethernet interface name", "iptrunk_sideB_ae_iface": "Aggregated Ethernet interface name",
"iptrunk_sideB_ae_geant_a_sid": "GÉANT A-SID", "iptrunk_sideB_ae_geant_a_sid": "GÉANT A-SID",
"iptrunk_sideB_ae_members": "Aggregated Ethernet member interface names", "iptrunk_sideB_ae_members": "Aggregated Ethernet member interface names",
"iptrunk_sideB_ae_members_descriptions": "Aggregated Ethernet member interface descriptions" "iptrunk_sideB_ae_members_descriptions": "Aggregated Ethernet member interface descriptions",
"remove_configuration": "Remove configuration from the device",
"clean_up_ipam": "Clean up related entries in IPAM"
} }
}, },
"workflow": { "workflow": {
......
...@@ -5,7 +5,7 @@ from orchestrator.forms import FormPage ...@@ -5,7 +5,7 @@ from orchestrator.forms import FormPage
from orchestrator.forms.validators import Label from orchestrator.forms.validators import Label
from orchestrator.targets import Target from orchestrator.targets import Target
from orchestrator.types import FormGenerator, SubscriptionLifecycle, UUIDstr from orchestrator.types import FormGenerator, SubscriptionLifecycle, UUIDstr
from orchestrator.workflow import StepList, done, init, step, workflow from orchestrator.workflow import StepList, conditional, done, init, step, workflow
from orchestrator.workflows.steps import resync, set_status, store_process_subscription, unsync from orchestrator.workflows.steps import resync, set_status, store_process_subscription, unsync
from orchestrator.workflows.utils import wrap_modify_initial_input_form from orchestrator.workflows.utils import wrap_modify_initial_input_form
...@@ -20,14 +20,15 @@ def initial_input_form_generator(subscription_id: UUIDstr) -> FormGenerator: ...@@ -20,14 +20,15 @@ def initial_input_form_generator(subscription_id: UUIDstr) -> FormGenerator:
subscription = Device.from_subscription(subscription_id) subscription = Device.from_subscription(subscription_id)
class TerminateForm(FormPage): class TerminateForm(FormPage):
are_you_sure: Label = f"Are you sure you want to remove {subscription.description}?" # type: ignore termination_label: Label = (
f"Please confirm whether configuration should get removed from the {subscription.device_type}, and "
"whether IPAM resources should be released." # type: ignore
)
remove_configuration: bool = True
clean_up_ipam: bool = True
return TerminateForm # type: ignore user_input = yield TerminateForm
return user_input.dict()
def _deprovision_in_user_management_system(fqdn: str) -> None:
logger.debug(fqdn)
pass
@step("Deprovision loopback IPs from IPAM/DNS") @step("Deprovision loopback IPs from IPAM/DNS")
...@@ -73,19 +74,28 @@ def deprovision_lt_ips(subscription: Device) -> dict[str, V4ServiceNetwork | V6S ...@@ -73,19 +74,28 @@ def deprovision_lt_ips(subscription: Device) -> dict[str, V4ServiceNetwork | V6S
} }
@step("Remove configuration from device")
def remove_config_from_device() -> None:
pass
@workflow( @workflow(
"Terminate device", "Terminate device",
initial_input_form=wrap_modify_initial_input_form(initial_input_form_generator), initial_input_form=wrap_modify_initial_input_form(initial_input_form_generator),
target=Target.TERMINATE, target=Target.TERMINATE,
) )
def terminate_device() -> StepList: def terminate_device() -> StepList:
run_ipam_steps = conditional(lambda state: state.get("clean_up_ipam", True))
run_config_steps = conditional(lambda state: state.get("remove_configuration", True))
ipam_steps = StepList([deprovision_loopback_ips, deprovision_si_ips, deprovision_lt_ips])
return ( return (
init init
>> store_process_subscription(Target.TERMINATE) >> store_process_subscription(Target.TERMINATE)
>> unsync >> unsync
>> deprovision_loopback_ips >> run_ipam_steps(ipam_steps)
>> deprovision_si_ips >> run_config_steps(remove_config_from_device)
>> deprovision_lt_ips
>> set_status(SubscriptionLifecycle.TERMINATED) >> set_status(SubscriptionLifecycle.TERMINATED)
>> resync >> resync
>> done >> done
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment