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

Update initial form for IP trunk creation

The input form for creating a new IP trunk is now a three-step process, where side A and B are steps 2 and 3.
It is no longer possible to select the same device for both sides.
parent 0713f76b
No related branches found
No related tags found
3 merge requests!26Update initial form for IP trunk creation,!25Update initial form for IP trunk creation,!24Update initial form for IP trunk creation
"""
Module that updated the domain model of GSO. Should contain all types of
Module that updates the domain model of GSO. Should contain all types of
subscriptions.
"""
from orchestrator.domain import SUBSCRIPTION_MODEL_REGISTRY
......
from enum import IntEnum
class PhyPortCapacity(IntEnum):
ONE = 1
TEN = 10
HUNDRED = 100
FOUR_HUNDRED = 400
......@@ -3,7 +3,7 @@ from uuid import uuid4
from orchestrator.db.models import ProductTable, SubscriptionTable
# noinspection PyProtectedMember
from orchestrator.forms import FormPage
from orchestrator.forms.validators import Choice, choice_list
from orchestrator.forms.validators import Choice
from orchestrator.targets import Target
from orchestrator.types import FormGenerator, State
from orchestrator.types import SubscriptionLifecycle, UUIDstr
......@@ -12,6 +12,7 @@ from orchestrator.workflows.steps import resync, set_status
from orchestrator.workflows.steps import store_process_subscription
from orchestrator.workflows.utils import wrap_create_initial_input_form
from gso.products.product_blocks import PhyPortCapacity
from gso.products.product_blocks.iptrunk import IptrunkType
from gso.products.product_types.device import Device
from gso.products.product_types.iptrunk import IptrunkInactive, \
......@@ -22,11 +23,14 @@ from gso.services.provisioning_proxy import confirm_pp_results, \
await_pp_results
def device_selector(choice_value: str) -> list:
device_subscriptions = {}
def initial_input_form_generator(product_name: str) -> FormGenerator:
# TODO: we need additional validation:
# * interface names must be validated
devices = {}
for device_id, device_description in (
SubscriptionTable.query.join(ProductTable)
.filter(
.filter(
ProductTable.product_type == 'Device',
SubscriptionTable.status == 'active',
)
......@@ -34,18 +38,8 @@ def device_selector(choice_value: str) -> list:
SubscriptionTable.description)
.all()
):
device_subscriptions[str(device_id)] = device_description
# noinspection PyTypeChecker
return choice_list(
Choice(choice_value, zip(device_subscriptions.keys(),
device_subscriptions.items())), # type:ignore
min_items=1,
max_items=1,
)
devices[str(device_id)] = device_description
def initial_input_form_generator(product_name: str) -> FormGenerator:
class CreateIptrunkForm(FormPage):
class Config:
title = product_name
......@@ -53,31 +47,44 @@ def initial_input_form_generator(product_name: str) -> FormGenerator:
geant_s_sid: str
iptrunk_description: str
iptrunk_type: IptrunkType
iptrunk_speed: str # This should be an enum: 1/10/100/400
iptrunk_speed: PhyPortCapacity
iptrunk_minimum_links: int
iptrunk_sideA_node_id: device_selector(
choice_value='DeviceEnumA') # noqa: F821
initial_user_input = yield CreateIptrunkForm
DeviceEnumA = Choice('Device A', zip(devices.keys(), devices.items()))
class CreateIptrunkSideAForm(FormPage):
class Config:
title = 'Provide subscription details for side A of the trunk.'
iptrunk_sideA_node_id: DeviceEnumA
iptrunk_sideA_ae_iface: str
iptrunk_sideA_ae_geant_a_sid: str
iptrunk_sideA_ae_members: list[str]
iptrunk_sideA_ae_members_descriptions: list[str]
iptrunk_sideB_node_id: device_selector(
choice_value='DeviceEnumB') # noqa: F821
user_input_side_a = yield CreateIptrunkSideAForm
# We remove the selected device for side A, to prevent any loops
devices.pop(str(user_input_side_a.iptrunk_sideA_node_id.name))
DeviceEnumB = Choice('Device B', zip(devices.keys(), devices.items()))
class CreateIptrunkSideBForm(FormPage):
class Config:
title = 'Provide subscription details for side B of the trunk.'
iptrunk_sideB_node_id: DeviceEnumB
iptrunk_sideB_ae_iface: str
iptrunk_sideB_ae_geant_a_sid: str
iptrunk_sideB_ae_members: list[str]
iptrunk_sideB_ae_members_descriptions: list[str]
# TODO: we need additional validation:
# * sideA fqdn must be different from sideB fqdn
# * the length of iptrunk_sideA_ae_members should
# be the same as iptrunk_sideB_ae_members
# * interface names must be validated
user_input = yield CreateIptrunkForm
user_input_side_b = yield CreateIptrunkSideBForm
return user_input.dict()
return initial_user_input.dict() | \
user_input_side_a.dict() | \
user_input_side_b.dict()
@step('Create subscription')
......
......@@ -6,7 +6,7 @@ setup(
author='GEANT',
author_email='swd@geant.org',
description='GEANT Service Orchestrator',
url=('https://gitlab.geant.org/goat/geant-service-orchestrator'),
url='https://gitlab.geant.org/goat/geant-service-orchestrator',
packages=find_packages(),
install_requires=[
'orchestrator-core==1.0.0',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment