diff --git a/gso/translations/en-GB.json b/gso/translations/en-GB.json index da9dd95eabb247ab7439c94c2b9e28634642e78f..3ae6a39705832c4c77cd10b59c3eda0ce468f58a 100644 --- a/gso/translations/en-GB.json +++ b/gso/translations/en-GB.json @@ -1,9 +1,11 @@ { "forms": { "fields": { - "added_service_ports": "Add ports", "confirm": "Confirm you are good with this", "confirm_info": "Check the output of the playbook" } + }, + "workflow": { + "modify_isis_metric": "Modify the ISIS metric" } } diff --git a/gso/workflows/iptrunk/create_iptrunk.py b/gso/workflows/iptrunk/create_iptrunk.py index 9c0e1c8c2215d12153830b538c1ea37a99133009..3fc8c32a3c6f66b0b5c3ea709c0f2aefe397ebdd 100644 --- a/gso/workflows/iptrunk/create_iptrunk.py +++ b/gso/workflows/iptrunk/create_iptrunk.py @@ -198,10 +198,8 @@ def provision_ip_trunk_iface_dry( return { "subscription": subscription, "label_text": ( - "This is a dry run for the deployment of a new IP " - "trunk. Deployment is being taken care of by the " - "provisioning proxy, please wait for the results to " - "come back before continuing." + "Provision of the Trunk interface [DRY] " + "Please refresh to get the results of the playbook" ), } @@ -217,10 +215,8 @@ def provision_ip_trunk_iface_real( return { "subscription": subscription, "label_text": ( - "This is a live deployment of a new IP trunk. " - "Deployment is being taken care of by the " - "provisioning proxy, please wait for the results to " - "come back before continuing." + "Provision of the Trunk interface [REAL] " + "Please refresh to get the results of the playbook" ), } @@ -236,11 +232,8 @@ def provision_ip_trunk_isis_iface_dry( return { "subscription": subscription, "label_text": ( - "This is a dry run for the deployment of a new IP " - "trunk ISIS interface. " - "Deployment is being taken care of by the " - "provisioning proxy, please wait for the results to " - "come back before continuing." + "Provision of the ISIS interface [DRY]" + "Please refresh to get the results of the playbook" ), } @@ -256,11 +249,8 @@ def provision_ip_trunk_isis_iface_real( return { "subscription": subscription, "label_text": ( - "This is a live deployment of a new IP trunk " - "ISIS interface. " - "Deployment is being taken care of by the " - "provisioning proxy, please wait for the results to " - "come back before continuing." + "Provision of the ISIS interface [REAL]" + "Please refresh to get the results of the playbook" ), } @@ -276,11 +266,8 @@ def provision_ip_trunk_ldp_iface_dry( return { "subscription": subscription, "label_text": ( - "This is a dry run for the deployment of a new IP " - "trunk LDP interface. " - "Deployment is being taken care of by the " - "provisioning proxy, please wait for the results to " - "come back before continuing." + "Provision of the LDP interface [DRY]" + "Please refresh to get the results of the playbook" ), } @@ -296,11 +283,8 @@ def provision_ip_trunk_ldp_iface_real( return { "subscription": subscription, "label_text": ( - "This is a live deployment of a new IP trunk " - "LDP interface. " - "Deployment is being taken care of by the " - "provisioning proxy, please wait for the results to " - "come back before continuing." + "Provision of the LDP interface [REAL]" + "Please refresh to get the results of the playbook" ), } @@ -316,11 +300,8 @@ def provision_ip_trunk_lldp_iface_dry( return { "subscription": subscription, "label_text": ( - "This is a dry run for the deployment of a new IP " - "trunk LLDP interface. " - "Deployment is being taken care of by the " - "provisioning proxy, please wait for the results to " - "come back before continuing." + "Provision of the LLDP interface [DRY]" + "Please refresh to get the results of the playbook" ), } @@ -336,11 +317,8 @@ def provision_ip_trunk_lldp_iface_real( return { "subscription": subscription, "label_text": ( - "This is a live deployment of a new IP trunk " - "LLDP interface. " - "Deployment is being taken care of by the " - "provisioning proxy, please wait for the results to " - "come back before continuing." + "Provision of the LLDP interface [REAL]" + "Please refresh to get the results of the playbook" ), } diff --git a/gso/workflows/iptrunk/modify_isis_metric.py b/gso/workflows/iptrunk/modify_isis_metric.py index e287f8a9c38992e306d14687ec08c87491ce77ad..8d769b604b8c96cb3c33c7fe76087af21a2d636c 100644 --- a/gso/workflows/iptrunk/modify_isis_metric.py +++ b/gso/workflows/iptrunk/modify_isis_metric.py @@ -33,7 +33,6 @@ def modify_iptrunk_subscription( subscription: Iptrunk, isis_metric: int ) -> State: subscription.iptrunk.iptrunk_isis_metric = isis_metric - subscription.description = f"Iptrunk {subscription.description} updated)" return {"subscription": subscription} diff --git a/gso/workflows/iptrunk/terminate_iptrunk.py b/gso/workflows/iptrunk/terminate_iptrunk.py index 45976f235e65f092a87d9db9053e83896c3d57a6..4190ee4deb7db227f9a0d307a9c024bc2e447411 100644 --- a/gso/workflows/iptrunk/terminate_iptrunk.py +++ b/gso/workflows/iptrunk/terminate_iptrunk.py @@ -1,4 +1,5 @@ # noinspection PyProtectedMember +import ipaddress from orchestrator.forms import FormPage from orchestrator.forms.validators import Label from orchestrator.targets import Target @@ -14,9 +15,11 @@ from orchestrator.workflows.steps import ( from orchestrator.workflows.utils import wrap_modify_initial_input_form from gso.products.product_types.iptrunk import Iptrunk -from gso.services import provisioning_proxy -from gso.services.provisioning_proxy import confirm_pp_results, \ - await_pp_results +from gso.services import provisioning_proxy, ipam +from gso.services.provisioning_proxy import ( + confirm_pp_results, + await_pp_results, +) def initial_input_form_generator(subscription_id: UUIDstr) -> InputForm: @@ -24,57 +27,109 @@ def initial_input_form_generator(subscription_id: UUIDstr) -> InputForm: class TerminateForm(FormPage): are_you_sure: Label = ( - f'Are you sure you want to remove {subscription.description}?' + f"Are you sure you want to remove {subscription.description}?" ) return TerminateForm -@step('Deprovision IP trunk [DRY RUN]') -def deprovision_ip_trunk_dry(subscription: Iptrunk, - process_id: UUIDstr) -> State: - provisioning_proxy.deprovision_ip_trunk(subscription, process_id) +@step("Set iptrunk ISIS metric to 9000") +def modify_iptrunk_subscription(subscription: Iptrunk) -> State: + subscription.iptrunk.iptrunk_isis_metric = 9000 + + return {"subscription": subscription} + + +@step("Drain traffic from trunk") +def drain_traffic_from_ip_trunk( + subscription: Iptrunk, process_id: UUIDstr +) -> State: + provisioning_proxy.provision_ip_trunk( + subscription, process_id, "isis_interface", False + ) + return { + "subscription": subscription, + "label_text": "This is setting the ISIS metric of the trunk to 9000" + "trunk. " + "Press refresh to get the results\n" + "When traffic is drained, confirm to continue", + } + + +@step("Deprovision IP trunk [DRY RUN]") +def deprovision_ip_trunk_dry( + subscription: Iptrunk, process_id: UUIDstr +) -> State: + provisioning_proxy.deprovision_ip_trunk(subscription, process_id, True) - return {'subscription': subscription, - 'label_text': 'This is a dry run for the termination of an IP ' - 'trunk. ' - 'Termination is being taken care of by the ' - 'provisioning proxy, please wait for the results to ' - 'come back before continuing.' - } + return { + "subscription": subscription, + "label_text": "This is a dry run for the termination of an IP " + "trunk. " + "Press refresh to get the results", + } -@step('Deprovision IP trunk [FOR REAL]') -def deprovision_ip_trunk_real(subscription: Iptrunk, - process_id: UUIDstr) -> State: +@step("Deprovision IP trunk [FOR REAL]") +def deprovision_ip_trunk_real( + subscription: Iptrunk, process_id: UUIDstr +) -> State: provisioning_proxy.deprovision_ip_trunk(subscription, process_id, False) - return {'subscription': subscription, - 'label_text': 'This is a termination of an IP trunk. ' - 'Termination is being taken care of by the ' - 'provisioning proxy, please wait for the results to ' - 'come back before continuing.' - } + return { + "subscription": subscription, + "label_text": "This is a termination of an IP trunk. " + "Press refresh to get the results", + } + + +@step("Deprovision IPv4 networks") +def deprovision_ip_trunk_ipv4(subscription: Iptrunk) -> None: + service_network = ipam.delete_service_network( + network=ipaddress.ip_network( + subscription.iptrunk.iptrunk_ipv4_network + ), + service_type="TRUNK", + ) + return {"service_network": service_network} + + +@step("Deprovision IPv6 networks") +def deprovision_ip_trunk_ipv6(subscription: Iptrunk) -> None: + service_network = ipam.delete_service_network( + network=ipaddress.ip_network( + subscription.iptrunk.iptrunk_ipv6_network + ), + service_type="TRUNK", + ) + return {"service_network": service_network} @workflow( - 'Terminate IPtrunk', + "Terminate IPtrunk", initial_input_form=wrap_modify_initial_input_form( - initial_input_form_generator), + initial_input_form_generator + ), target=Target.TERMINATE, ) def terminate_iptrunk(): return ( - init - >> store_process_subscription(Target.TERMINATE) - >> unsync - >> deprovision_ip_trunk_dry - >> await_pp_results - >> confirm_pp_results - >> deprovision_ip_trunk_real - >> await_pp_results - >> confirm_pp_results - >> set_status(SubscriptionLifecycle.TERMINATED) - >> resync - >> done + init + >> store_process_subscription(Target.TERMINATE) + >> unsync + >> modify_iptrunk_subscription + >> drain_traffic_from_ip_trunk + >> await_pp_results + >> confirm_pp_results + >> deprovision_ip_trunk_dry + >> await_pp_results + >> confirm_pp_results + >> deprovision_ip_trunk_real + >> await_pp_results + >> confirm_pp_results + >> deprovision_ip_trunk_ipv4 + >> deprovision_ip_trunk_ipv6 + >> set_status(SubscriptionLifecycle.TERMINATED) + >> resync + >> done )