Skip to content

Commit a4fa6f3

Browse files
committed
Remove OrchestratorVlanRanges and use VlanRanges
1 parent 11f22b3 commit a4fa6f3

File tree

13 files changed

+30
-54
lines changed

13 files changed

+30
-54
lines changed

docker-compose.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,6 @@ services:
236236
- "80:80"
237237
volumes:
238238
- "./docker/nginx/nginx.conf:/etc/nginx/nginx.conf:ro"
239-
restart: always
240239
depends_on:
241240
orchestrator:
242241
condition: service_started

docker/orchestrator-ui/orchestrator-ui.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ OIDC_CONF_FULL_WELL_KNOWN_URL=""
2121
OAUTH2_ACTIVE=false
2222
AO_STACK_STATUS_URL=""
2323
ENABLE_AO_STACK_STATUS=false
24+
ACTIVATE_PYDANTIC_FORMS=true

products/product_blocks/sap.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,18 @@
1717
from pydantic import computed_field
1818

1919
from products.product_blocks.port import PortBlock, PortBlockInactive, PortBlockProvisioning
20-
from workflows.nsistp.shared.shared import OrchestratorVlanRanges
20+
from nwastdlib.vlans import VlanRanges
2121

2222

2323
class SAPBlockInactive(ProductBlockModel, product_block_name="SAP"):
2424
port: PortBlockInactive | None = None
25-
vlan: OrchestratorVlanRanges | None = None
25+
vlan: VlanRanges | None = None
2626
ims_id: int | None = None
2727

2828

2929
class SAPBlockProvisioning(SAPBlockInactive, lifecycle=[SubscriptionLifecycle.PROVISIONING]):
3030
port: PortBlockProvisioning
31-
vlan: OrchestratorVlanRanges
31+
vlan: VlanRanges
3232
ims_id: int | None = None
3333

3434
@computed_field # type: ignore[misc]
@@ -39,5 +39,5 @@ def title(self) -> str:
3939

4040
class SAPBlock(SAPBlockProvisioning, lifecycle=[SubscriptionLifecycle.ACTIVE]):
4141
port: PortBlock
42-
vlan: OrchestratorVlanRanges
42+
vlan: VlanRanges
4343
ims_id: int

products/product_types/nsistp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from orchestrator.types import SubscriptionLifecycle
1717

1818
from products.product_blocks.nsistp import NsistpBlock, NsistpBlockInactive, NsistpBlockProvisioning
19-
from workflows.nsistp.shared.shared import OrchestratorVlanRanges
19+
from nwastdlib.vlans import VlanRanges
2020

2121

2222
class NsistpInactive(SubscriptionModel, is_base=True):
@@ -31,5 +31,5 @@ class Nsistp(NsistpProvisioning, lifecycle=[SubscriptionLifecycle.ACTIVE]):
3131
nsistp: NsistpBlock
3232

3333
@property
34-
def vlan_range(self) -> OrchestratorVlanRanges:
34+
def vlan_range(self) -> VlanRanges:
3535
return self.nsistp.sap.vlan

products/services/netbox/payload/port.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ def build_port_payload(model: PortBlockProvisioning, subscription: SubscriptionM
4444
Returns: :class:`netbox.InterfacePayload`
4545
4646
"""
47-
print(model.vlan_group_ims_ids)
4847
vlan_ids = [vlan.id for group_id in model.vlan_group_ims_ids for vlan in netbox.get_vlans(group_id=group_id)]
4948
return netbox.InterfacePayload(
5049
device=model.node.ims_id,

products/services/netbox/payload/sap.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def build_sap_vlans_payload(model: SAPBlockProvisioning, subscription: Subscript
4444

4545

4646
def build_sap_vlan_group_payload(model: SAPBlockProvisioning, subscription: SubscriptionModel) -> netbox.VlanGroupPayload:
47-
"""Create and return a list of Netbox :class:`VlanGroupPayload` for a :class:`~products.product_blocks.sap.SAPBlockProvisioning`.
47+
"""Create and return a Netbox VlanGroupPayload object for a :class:`~products.product_blocks.sap.SAPBlockProvisioning`.
4848
4949
Example payload::
5050

services/netbox.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
from settings import settings
2727
from utils.singledispatch import single_dispatch_base
28-
from workflows.nsistp.shared.shared import OrchestratorVlanRanges
2928

3029
logger = structlog.get_logger(__name__)
3130

workflows/l2vpn/create_l2vpn.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
from products.services.netbox.payload.sap import build_sap_vlan_group_payload
3636
from services import netbox
3737
from workflows.l2vpn.shared.forms import ports_selector
38-
from workflows.nsistp.shared.shared import OrchestratorVlanRanges
3938
from workflows.shared import AllowedNumberOfL2vpnPorts
39+
from nwastdlib.vlans import VlanRanges
4040

4141

4242
def initial_input_form_generator(product_name: str) -> FormGenerator:
@@ -57,7 +57,7 @@ class SelectPortsForm(FormPage):
5757
model_config = ConfigDict(title=product_name)
5858

5959
ports: PortsChoiceList
60-
vlan: OrchestratorVlanRanges
60+
vlan: VlanRanges
6161

6262
select_ports = yield SelectPortsForm
6363
select_ports_dict = select_ports.model_dump()
@@ -73,7 +73,7 @@ def construct_l2vpn_model(
7373
ports: list[UUIDstr],
7474
speed: int,
7575
speed_policer: bool,
76-
vlan: OrchestratorVlanRanges,
76+
vlan: VlanRanges,
7777
) -> State:
7878
subscription = L2vpnInactive.from_product_id(
7979
product_id=product,
@@ -110,7 +110,7 @@ def ims_create_vlans(subscription: L2vpnProvisioning) -> State:
110110
group_payload = build_sap_vlan_group_payload(sap, subscription)
111111
sap.ims_id = netbox.create(group_payload)
112112
group_payloads += [group_payload]
113-
vlan_payloads += build_payload(sap, subscription)
113+
vlan_payloads += [build_payload(sap, subscription)]
114114

115115
for payload in vlan_payloads:
116116
netbox.create(payload)

workflows/nsistp/create_nsistp.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@
4242
port_selector,
4343
validate_both_aliases_empty_or_not,
4444
)
45-
from workflows.nsistp.shared.shared import OrchestratorVlanRanges
4645
from workflows.nsistp.shared.vlan import validate_vlan, validate_vlan_not_in_use
4746
from workflows.shared import create_summary_form
47+
from nwastdlib.vlans import VlanRanges
4848

4949
logger = structlog.get_logger(__name__)
5050

@@ -60,7 +60,7 @@ class CreateNsiStpForm(FormPage):
6060

6161
port: PortChoiceList
6262
vlan: Annotated[
63-
OrchestratorVlanRanges,
63+
VlanRanges,
6464
AfterValidator(validate_vlan),
6565
AfterValidator(_validate_vlan_not_in_use),
6666
]
@@ -103,7 +103,7 @@ def validate_is_alias_in_out(self) -> "CreateNsiStpForm":
103103
def construct_nsistp_model(
104104
product: UUIDstr,
105105
port: UUIDstr,
106-
vlan: OrchestratorVlanRanges,
106+
vlan: VlanRanges,
107107
topology: str,
108108
stp_id: str,
109109
stp_description: str | None,

workflows/nsistp/shared/forms.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@
3232

3333
from products.product_blocks.port import PortMode
3434
from products.product_types.nsistp import Nsistp, NsistpInactive
35-
from workflows.nsistp.shared.shared import MAX_SPEED_POSSIBLE, OrchestratorVlanRanges
35+
from workflows.nsistp.shared.shared import MAX_SPEED_POSSIBLE
3636
from workflows.shared import subscriptions_by_product_type_and_instance_value
37+
from nwastdlib.vlans import VlanRanges
3738

3839
TOPOLOGY_REGEX = r"^[-a-z0-9+,.;=_]+$"
3940
STP_ID_REGEX = r"^[-a-z0-9+,.;=_:]+$"
@@ -151,7 +152,7 @@ def validate_nurn(nurn: str | None) -> str | None:
151152
return nurn
152153

153154

154-
def nsistp_fill_sap(subscription: NsistpInactive, subscription_id: UUIDstr, vlan: OrchestratorVlanRanges) -> None:
155+
def nsistp_fill_sap(subscription: NsistpInactive, subscription_id: UUIDstr, vlan: VlanRanges) -> None:
155156
subscription.nsistp.sap.vlan = vlan
156157
subscription.nsistp.sap.port = SubscriptionModel.from_subscription(subscription_id).port # type: ignore
157158

0 commit comments

Comments
 (0)