Skip to content
Snippets Groups Projects
Commit 0f7d2317 authored by Simone Spinelli's avatar Simone Spinelli
Browse files

Fixed translation and removal of IPv4/6 networks for devices and trunks - modify trunks ISIS metric

parent 67d783d1
No related branches found
No related tags found
1 merge request!28Feature/nat178 trunks isis metric modify
{
"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"
}
}
......@@ -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"
),
}
......
......@@ -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}
......
# 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
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment