Skip to content
Snippets Groups Projects
Verified Commit 501326b1 authored by Karel van Klink's avatar Karel van Klink :smiley_cat:
Browse files

Rename NRENL3CoreService

Rename to L3CoreService, and add Copernicus, LHCOne, and GWS as new L3 core services
parent d27d1e42
No related branches found
No related tags found
2 merge requests!313Rename NRENL3CoreService and update BGP peer,!312Rename NRENL3CoreService
Pipeline #90566 failed
Showing
with 621 additions and 243 deletions
......@@ -238,8 +238,8 @@ class EdgePortImportModel(BaseModel):
return self
class NRENL3CoreServiceImportModel(BaseModel):
"""Import :term:`NREN` L3 Core Service model."""
class L3CoreServiceImportModel(BaseModel):
"""Import L3 Core Service model."""
class BaseBGPPeer(BaseModel):
"""Base BGP Peer model."""
......@@ -278,9 +278,9 @@ class NRENL3CoreServiceImportModel(BaseModel):
ipv6_address: IPv6AddressType
ipv6_mask: IPV6Netmask
is_multi_hop: bool = True
bgp_peers: list["NRENL3CoreServiceImportModel.BaseBGPPeer"]
v4_bfd_settings: "NRENL3CoreServiceImportModel.BFDSettingsModel"
v6_bfd_settings: "NRENL3CoreServiceImportModel.BFDSettingsModel"
bgp_peers: list["L3CoreServiceImportModel.BaseBGPPeer"]
v4_bfd_settings: "L3CoreServiceImportModel.BFDSettingsModel"
v6_bfd_settings: "L3CoreServiceImportModel.BFDSettingsModel"
partner: str
service_binding_ports: list[ServiceBindingPort]
......@@ -390,7 +390,7 @@ T = TypeVar(
OfficeRouterImportModel,
OpenGearImportModel,
EdgePortImportModel,
NRENL3CoreServiceImportModel,
L3CoreServiceImportModel,
LanSwitchInterconnectImportModel,
Layer2CircuitServiceImportModel,
)
......@@ -655,20 +655,20 @@ def import_partners(file_path: str = typer.Argument(..., help="Path to the CSV f
@app.command()
def import_nren_l3_core_service(filepath: str = common_filepath_option) -> None:
"""Import :term:`NREN` L3 Core Services into :term:`GSO`."""
def import_l3_core_service(filepath: str = common_filepath_option) -> None:
"""Import L3 Core Services into :term:`GSO`."""
successfully_imported_data = []
nren_l3_core_service_list = _read_data(Path(filepath))
l3_core_service_list = _read_data(Path(filepath))
for nren_l3_core_service in nren_l3_core_service_list:
partner = nren_l3_core_service["partner"]
service_type = nren_l3_core_service["service_type"]
for l3_core_service in l3_core_service_list:
partner = l3_core_service["partner"]
service_type = l3_core_service["service_type"]
typer.echo(f"Creating imported {service_type} for {partner}")
try:
initial_data = NRENL3CoreServiceImportModel(**nren_l3_core_service)
start_process("create_imported_nren_l3_core_service", [initial_data.model_dump()])
edge_ports = [sbp["edge_port"] for sbp in nren_l3_core_service["service_binding_ports"]]
initial_data = L3CoreServiceImportModel(**l3_core_service)
start_process("create_imported_l3_core_service", [initial_data.model_dump()])
edge_ports = [sbp["edge_port"] for sbp in l3_core_service["service_binding_ports"]]
successfully_imported_data.append(edge_ports)
typer.echo(f"Successfully created imported {service_type} for {partner}")
except ValidationError as e:
......@@ -679,17 +679,22 @@ def import_nren_l3_core_service(filepath: str = common_filepath_option) -> None:
# Migrate new products from imported to "full" counterpart.
imported_products = get_subscriptions(
product_types=[ProductType.IMPORTED_GEANT_IP, ProductType.IMPORTED_IAS],
product_types=[
ProductType.IMPORTED_GEANT_IP,
ProductType.IMPORTED_IAS,
ProductType.IMPORTED_LHCONE,
ProductType.IMPORTED_COPERNICUS,
],
lifecycles=[SubscriptionLifecycle.ACTIVE],
includes=["subscription_id"],
)
for subscription_id in imported_products:
typer.echo(f"Importing {subscription_id}")
start_process("import_nren_l3_core_service", [subscription_id])
start_process("import_l3_core_service", [subscription_id])
if successfully_imported_data:
typer.echo("Successfully created imported NREN L3 Core Services:")
typer.echo("Successfully created imported L3 Core Services:")
for item in successfully_imported_data:
typer.echo(f"- {item}")
......
"""Rename NRENL3Core service to L3Core service and add LHCOne, GWS, and Copernicus.
Revision ID: 2746f861a765
Revises: f6ceec1af371
Create Date: 2024-11-25 09:47:08.419689
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = '2746f861a765'
down_revision = 'f6ceec1af371'
branch_labels = None
depends_on = None
from orchestrator.migrations.helpers import create_workflow, delete_workflow
new_workflows = [
{
"name": "create_l3_core_service",
"target": "CREATE",
"description": "Create L3 Core Service",
"product_type": "L3CoreService"
},
{
"name": "modify_l3_core_service",
"target": "MODIFY",
"description": "Modify L3 Core Service",
"product_type": "L3CoreService"
},
{
"name": "create_imported_l3_core_service",
"target": "CREATE",
"description": "Create imported L3 Core Service",
"product_type": "ImportedL3CoreService"
},
{
"name": "import_l3_core_service",
"target": "MODIFY",
"description": "Import L3 Core Service",
"product_type": "ImportedL3CoreService"
},
{
"name": "migrate_l3_core_service",
"target": "MODIFY",
"description": "Migrate L3 Core Service",
"product_type": "L3CoreService"
}
]
old_workflows = [
{
"name": "create_nren_l3_core_service",
"target": "CREATE",
"description": "Create NREN L3 Core Service",
"product_type": "NRENL3CoreService"
},
{
"name": "modify_nren_l3_core_service",
"target": "MODIFY",
"description": "Modify NREN L3 Core Service",
"product_type": "NRENL3CoreService"
},
{
"name": "create_imported_nren_l3_core_service",
"target": "CREATE",
"description": "Create imported NREN L3 Core Service",
"product_type": "ImportedNRENL3CoreService"
},
{
"name": "import_nren_l3_core_service",
"target": "MODIFY",
"description": "Import NREN L3 Core Service",
"product_type": "ImportedNRENL3CoreService"
},
{
"name": "migrate_nren_l3_core_service",
"target": "MODIFY",
"description": "Migrate NREN L3 Core Service",
"product_type": "NRENL3CoreService"
}
]
def upgrade() -> None:
conn = op.get_bind()
for workflow in old_workflows:
delete_workflow(conn, workflow["name"])
conn.execute(sa.text("""
UPDATE fixed_inputs SET name='l3_core_service_type' WHERE fixed_inputs.product_id = (SELECT products.product_id FROM products WHERE products.name IN ('GÉANT IP')) AND fixed_inputs.name = 'nren_l3_core_service_type'
"""))
conn.execute(sa.text("""
UPDATE fixed_inputs SET name='l3_core_service_type' WHERE fixed_inputs.product_id = (SELECT products.product_id FROM products WHERE products.name IN ('Imported GÉANT IP')) AND fixed_inputs.name = 'nren_l3_core_service_type'
"""))
conn.execute(sa.text("""
UPDATE fixed_inputs SET name='l3_core_service_type' WHERE fixed_inputs.product_id = (SELECT products.product_id FROM products WHERE products.name IN ('IAS')) AND fixed_inputs.name = 'nren_l3_core_service_type'
"""))
conn.execute(sa.text("""
UPDATE fixed_inputs SET name='l3_core_service_type' WHERE fixed_inputs.product_id = (SELECT products.product_id FROM products WHERE products.name IN ('Imported IAS')) AND fixed_inputs.name = 'nren_l3_core_service_type'
"""))
conn.execute(sa.text("""
UPDATE products SET product_type='L3CoreService' WHERE product_type='NRENL3CoreService'
"""))
conn.execute(sa.text("""
UPDATE products SET product_type='ImportedL3CoreService' WHERE product_type='ImportedNRENL3CoreService'
"""))
conn.execute(sa.text("""
INSERT INTO products (name, description, product_type, tag, status) VALUES ('LHCOne', 'LHCOne', 'L3CoreService', 'LHC', 'active') RETURNING products.product_id
"""))
conn.execute(sa.text("""
INSERT INTO products (name, description, product_type, tag, status) VALUES ('Imported LHCOne', 'Imported LHCOne', 'ImportedL3CoreService', 'IMP_LHC', 'active') RETURNING products.product_id
"""))
conn.execute(sa.text("""
INSERT INTO products (name, description, product_type, tag, status) VALUES ('Copernicus', 'Copernicus', 'L3CoreService', 'COP', 'active') RETURNING products.product_id
"""))
conn.execute(sa.text("""
INSERT INTO products (name, description, product_type, tag, status) VALUES ('Imported Copernicus', 'Imported Copernicus', 'ImportedL3CoreService', 'IMP_COP', 'active') RETURNING products.product_id
"""))
conn.execute(sa.text("""
INSERT INTO products (name, description, product_type, tag, status) VALUES ('GWS', 'GWS', 'L3CoreService', 'GWS', 'active') RETURNING products.product_id
"""))
conn.execute(sa.text("""
INSERT INTO products (name, description, product_type, tag, status) VALUES ('Imported GWS', 'Imported GWS', 'ImportedL3CoreService', 'IMP_GWS', 'active') RETURNING products.product_id
"""))
conn.execute(sa.text("""
INSERT INTO fixed_inputs (name, value, product_id) VALUES ('l3_core_service_type', 'LHCONE', (SELECT products.product_id FROM products WHERE products.name IN ('LHCOne'))), ('l3_core_service_type', 'IMPORTED COPERNICUS', (SELECT products.product_id FROM products WHERE products.name IN ('Imported Copernicus'))), ('l3_core_service_type', 'COPERNICUS', (SELECT products.product_id FROM products WHERE products.name IN ('Copernicus'))), ('l3_core_service_type', 'IMPORTED LHCONE', (SELECT products.product_id FROM products WHERE products.name IN ('Imported LHCOne'))), ('l3_core_service_type', 'IMPORTED GWS', (SELECT products.product_id FROM products WHERE products.name IN ('Imported GWS'))), ('l3_core_service_type', 'GWS', (SELECT products.product_id FROM products WHERE products.name IN ('GWS')))
"""))
conn.execute(sa.text("""
INSERT INTO product_blocks (name, description, tag, status) VALUES ('L3CoreServiceBlock', 'A Core network service on Layer 3', 'L3CORE', 'active') RETURNING product_blocks.product_block_id
"""))
conn.execute(sa.text("""
INSERT INTO product_blocks (name, description, tag, status) VALUES ('AccessPort', 'An Access Port where a Layer 3 service terminates', 'AP', 'active') RETURNING product_blocks.product_block_id
"""))
conn.execute(sa.text("""
INSERT INTO product_product_blocks (product_id, product_block_id) VALUES ((SELECT products.product_id FROM products WHERE products.name IN ('Imported IAS')), (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('L3CoreServiceBlock'))), ((SELECT products.product_id FROM products WHERE products.name IN ('GÉANT IP')), (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('L3CoreServiceBlock'))), ((SELECT products.product_id FROM products WHERE products.name IN ('LHCOne')), (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('L3CoreServiceBlock'))), ((SELECT products.product_id FROM products WHERE products.name IN ('Imported LHCOne')), (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('L3CoreServiceBlock'))), ((SELECT products.product_id FROM products WHERE products.name IN ('IAS')), (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('L3CoreServiceBlock'))), ((SELECT products.product_id FROM products WHERE products.name IN ('Imported GÉANT IP')), (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('L3CoreServiceBlock'))), ((SELECT products.product_id FROM products WHERE products.name IN ('Copernicus')), (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('L3CoreServiceBlock'))), ((SELECT products.product_id FROM products WHERE products.name IN ('Imported Copernicus')), (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('L3CoreServiceBlock'))),((SELECT products.product_id FROM products WHERE products.name IN ('GWS')), (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('L3CoreServiceBlock'))), ((SELECT products.product_id FROM products WHERE products.name IN ('Imported GWS')), (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('L3CoreServiceBlock')))
"""))
conn.execute(sa.text("""
INSERT INTO product_block_relations (in_use_by_id, depends_on_id) VALUES ((SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('AccessPort')), (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('ServiceBindingPort')))
"""))
conn.execute(sa.text("""
INSERT INTO product_block_relations (in_use_by_id, depends_on_id) VALUES ((SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('L3CoreServiceBlock')), (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('AccessPort')))
"""))
conn.execute(sa.text("""
INSERT INTO product_block_resource_types (product_block_id, resource_type_id) VALUES ((SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('AccessPort')), (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('ap_type')))
"""))
for workflow in new_workflows:
create_workflow(conn, workflow)
def downgrade() -> None:
conn = op.get_bind()
for workflow in new_workflows:
delete_workflow(conn, workflow["name"])
conn.execute(sa.text("""
DELETE FROM product_block_resource_types WHERE product_block_resource_types.product_block_id IN (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('AccessPort')) AND product_block_resource_types.resource_type_id = (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('ap_type'))
"""))
conn.execute(sa.text("""
DELETE FROM subscription_instance_values USING product_block_resource_types WHERE subscription_instance_values.subscription_instance_id IN (SELECT subscription_instances.subscription_instance_id FROM subscription_instances WHERE subscription_instances.subscription_instance_id IN (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('AccessPort'))) AND product_block_resource_types.resource_type_id = (SELECT resource_types.resource_type_id FROM resource_types WHERE resource_types.resource_type IN ('ap_type'))
"""))
conn.execute(sa.text("""
DELETE FROM product_product_blocks WHERE product_product_blocks.product_id IN (SELECT products.product_id FROM products WHERE products.name IN ('Imported IAS', 'GÉANT IP', 'LHCOne', 'Imported LHCOne', 'IAS', 'Imported GÉANT IP', 'Copernicus', 'Imported Copernicus', 'GWS', 'Imported GWS')) AND product_product_blocks.product_block_id IN (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('L3CoreServiceBlock'))
"""))
conn.execute(sa.text("""
DELETE FROM product_block_relations WHERE product_block_relations.in_use_by_id IN (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('AccessPort')) AND product_block_relations.depends_on_id IN (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('ServiceBindingPort'))
"""))
conn.execute(sa.text("""
DELETE FROM product_block_relations WHERE product_block_relations.in_use_by_id IN (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('L3CoreServiceBlock')) AND product_block_relations.depends_on_id IN (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('AccessPort'))
"""))
conn.execute(sa.text("""
DELETE FROM fixed_inputs WHERE fixed_inputs.product_id IN (SELECT products.product_id FROM products WHERE products.name IN ('LHCOne', 'Imported Copernicus', 'Copernicus', 'Imported LHCOne', 'GWS', 'Imported GWS')) AND fixed_inputs.name = 'l3_core_service_type'
"""))
conn.execute(sa.text("""
DELETE FROM subscription_instances WHERE subscription_instances.product_block_id IN (SELECT product_blocks.product_block_id FROM product_blocks WHERE product_blocks.name IN ('AccessPort', 'L3CoreServiceBlock'))
"""))
conn.execute(sa.text("""
DELETE FROM product_blocks WHERE product_blocks.name IN ('AccessPort', 'L3CoreServiceBlock')
"""))
conn.execute(sa.text("""
DELETE FROM processes WHERE processes.pid IN (SELECT processes_subscriptions.pid FROM processes_subscriptions WHERE processes_subscriptions.subscription_id IN (SELECT subscriptions.subscription_id FROM subscriptions WHERE subscriptions.product_id IN (SELECT products.product_id FROM products WHERE products.name IN ('LHCOne', 'Imported Copernicus', 'Copernicus', 'Imported LHCOne', 'GWS', 'Imported GWS'))))
"""))
conn.execute(sa.text("""
DELETE FROM processes_subscriptions WHERE processes_subscriptions.subscription_id IN (SELECT subscriptions.subscription_id FROM subscriptions WHERE subscriptions.product_id IN (SELECT products.product_id FROM products WHERE products.name IN ('LHCOne', 'Imported Copernicus', 'Copernicus', 'Imported LHCOne', 'GWS', 'Imported GWS')))
"""))
conn.execute(sa.text("""
DELETE FROM subscription_instances WHERE subscription_instances.subscription_id IN (SELECT subscriptions.subscription_id FROM subscriptions WHERE subscriptions.product_id IN (SELECT products.product_id FROM products WHERE products.name IN ('LHCOne', 'Imported Copernicus', 'Copernicus', 'Imported LHCOne', 'GWS', 'Imported GWS')))
"""))
conn.execute(sa.text("""
DELETE FROM subscriptions WHERE subscriptions.product_id IN (SELECT products.product_id FROM products WHERE products.name IN ('LHCOne', 'Imported Copernicus', 'Copernicus', 'Imported LHCOne', 'GWS', 'Imported GWS'))
"""))
conn.execute(sa.text("""
DELETE FROM products WHERE products.name IN ('LHCOne', 'Imported Copernicus', 'Copernicus', 'Imported LHCOne', 'GWS', 'Imported GWS')
"""))
conn.execute(sa.text("""
UPDATE products SET product_type='NRENL3CoreService' WHERE product_type='L3CoreService'
"""))
conn.execute(sa.text("""
UPDATE products SET product_type='ImportedNRENL3CoreService' WHERE product_type='ImportedL3CoreService'
"""))
conn.execute(sa.text("""
UPDATE fixed_inputs SET name='nren_l3_core_service_type' WHERE fixed_inputs.product_id = (SELECT products.product_id FROM products WHERE products.name IN ('GÉANT IP')) AND fixed_inputs.name = 'l3_core_service_type'
"""))
conn.execute(sa.text("""
UPDATE fixed_inputs SET name='nren_l3_core_service_type' WHERE fixed_inputs.product_id = (SELECT products.product_id FROM products WHERE products.name IN ('Imported GÉANT IP')) AND fixed_inputs.name = 'l3_core_service_type'
"""))
conn.execute(sa.text("""
UPDATE fixed_inputs SET name='nren_l3_core_service_type' WHERE fixed_inputs.product_id = (SELECT products.product_id FROM products WHERE products.name IN ('IAS')) AND fixed_inputs.name = 'l3_core_service_type'
"""))
conn.execute(sa.text("""
UPDATE fixed_inputs SET name='nren_l3_core_service_type' WHERE fixed_inputs.product_id = (SELECT products.product_id FROM products WHERE products.name IN ('Imported IAS')) AND fixed_inputs.name = 'l3_core_service_type'
"""))
for workflow in old_workflows:
create_workflow(conn, workflow)
......@@ -10,9 +10,9 @@ from pydantic_forms.types import strEnum
from gso.products.product_types.edge_port import EdgePort, ImportedEdgePort
from gso.products.product_types.iptrunk import ImportedIptrunk, Iptrunk
from gso.products.product_types.l3_core_service import ImportedL3CoreService, L3CoreService
from gso.products.product_types.lan_switch_interconnect import ImportedLanSwitchInterconnect, LanSwitchInterconnect
from gso.products.product_types.layer_2_circuit import ImportedLayer2Circuit, Layer2Circuit, Layer2CircuitServiceType
from gso.products.product_types.nren_l3_core_service import ImportedNRENL3CoreService, NRENL3CoreService
from gso.products.product_types.office_router import ImportedOfficeRouter, OfficeRouter
from gso.products.product_types.opengear import ImportedOpengear, Opengear
from gso.products.product_types.pop_vlan import PopVlan
......@@ -48,6 +48,12 @@ class ProductName(strEnum):
IMPORTED_GEANT_IP = "Imported GÉANT IP"
IAS = "IAS"
IMPORTED_IAS = "Imported IAS"
GWS = "GWS"
IMPORTED_GWS = "Imported GWS"
LHCONE = "LHCOne"
IMPORTED_LHCONE = "Imported LHCOne"
COPERNICUS = "Copernicus"
IMPORTED_COPERNICUS = "Imported Copernicus"
GEANT_PLUS = Layer2CircuitServiceType.GEANT_PLUS
IMPORTED_GEANT_PLUS = Layer2CircuitServiceType.IMPORTED_GEANT_PLUS
EXPRESSROUTE = Layer2CircuitServiceType.EXPRESSROUTE
......@@ -76,10 +82,16 @@ class ProductType(strEnum):
IMPORTED_OPENGEAR = Opengear.__name__
EDGE_PORT = EdgePort.__name__
IMPORTED_EDGE_PORT = ImportedEdgePort.__name__
GEANT_IP = NRENL3CoreService.__name__
IMPORTED_GEANT_IP = ImportedNRENL3CoreService.__name__
IAS = NRENL3CoreService.__name__
IMPORTED_IAS = ImportedNRENL3CoreService.__name__
GEANT_IP = L3CoreService.__name__
IMPORTED_GEANT_IP = ImportedL3CoreService.__name__
IAS = L3CoreService.__name__
IMPORTED_IAS = ImportedL3CoreService.__name__
GWS = L3CoreService.__name__
IMPORTED_GWS = ImportedL3CoreService.__name__
LHCONE = L3CoreService.__name__
IMPORTED_LHCONE = ImportedL3CoreService.__name__
COPERNICUS = L3CoreService.__name__
IMPORTED_COPERNICUS = ImportedL3CoreService.__name__
GEANT_PLUS = Layer2Circuit.__name__
IMPORTED_GEANT_PLUS = ImportedLayer2Circuit.__name__
EXPRESSROUTE = Layer2Circuit.__name__
......@@ -107,10 +119,16 @@ SUBSCRIPTION_MODEL_REGISTRY.update(
ProductName.IMPORTED_OPENGEAR.value: ImportedOpengear,
ProductName.EDGE_PORT.value: EdgePort,
ProductName.IMPORTED_EDGE_PORT.value: ImportedEdgePort,
ProductName.GEANT_IP.value: NRENL3CoreService,
ProductName.IMPORTED_GEANT_IP.value: ImportedNRENL3CoreService,
ProductName.IAS.value: NRENL3CoreService,
ProductName.IMPORTED_IAS.value: ImportedNRENL3CoreService,
ProductName.GEANT_IP.value: L3CoreService,
ProductName.IMPORTED_GEANT_IP.value: ImportedL3CoreService,
ProductName.IAS.value: L3CoreService,
ProductName.IMPORTED_IAS.value: ImportedL3CoreService,
ProductName.GWS.value: L3CoreService,
ProductName.IMPORTED_GWS.value: ImportedL3CoreService,
ProductName.LHCONE.value: L3CoreService,
ProductName.IMPORTED_LHCONE.value: ImportedL3CoreService,
ProductName.COPERNICUS.value: L3CoreService,
ProductName.IMPORTED_COPERNICUS.value: ImportedL3CoreService,
ProductName.GEANT_PLUS.value: Layer2Circuit,
ProductName.IMPORTED_GEANT_PLUS.value: ImportedLayer2Circuit,
ProductName.EXPRESSROUTE.value: Layer2Circuit,
......
"""Product blocks for :class:`NREN` Layer 3 Core Service products."""
"""Product blocks for Layer 3 Core Service products."""
from orchestrator.domain.base import ProductBlockModel
from orchestrator.types import SubscriptionLifecycle
......@@ -12,24 +12,22 @@ from gso.products.product_blocks.service_binding_port import (
from gso.utils.shared_enums import APType
class NRENAccessPortInactive(
ProductBlockModel, lifecycle=[SubscriptionLifecycle.INITIAL], product_block_name="NRENAccessPort"
):
"""An access port for an R&E :term:`NREN` service that is inactive."""
class AccessPortInactive(ProductBlockModel, lifecycle=[SubscriptionLifecycle.INITIAL], product_block_name="AccessPort"):
"""An access port for an R&E service that is inactive."""
ap_type: APType | None = None
sbp: ServiceBindingPortInactive
class NRENAccessPortProvisioning(NRENAccessPortInactive, lifecycle=[SubscriptionLifecycle.PROVISIONING]):
"""An access port for an R&E :term:`NREN` service that is being provisioned."""
class AccessPortProvisioning(AccessPortInactive, lifecycle=[SubscriptionLifecycle.PROVISIONING]):
"""An access port for an R&E service that is being provisioned."""
ap_type: APType
sbp: ServiceBindingPortProvisioning
class NRENAccessPort(NRENAccessPortProvisioning, lifecycle=[SubscriptionLifecycle.ACTIVE]):
"""An access port for an R&E :term:`NREN` service."""
class AccessPort(AccessPortProvisioning, lifecycle=[SubscriptionLifecycle.ACTIVE]):
"""An access port for an R&E service."""
#: The type of Access Port
ap_type: APType
......@@ -37,24 +35,22 @@ class NRENAccessPort(NRENAccessPortProvisioning, lifecycle=[SubscriptionLifecycl
sbp: ServiceBindingPort
class NRENL3CoreServiceBlockInactive(
ProductBlockModel, lifecycle=[SubscriptionLifecycle.INITIAL], product_block_name="NRENL3CoreServiceBlock"
class L3CoreServiceBlockInactive(
ProductBlockModel, lifecycle=[SubscriptionLifecycle.INITIAL], product_block_name="L3CoreServiceBlock"
):
"""An inactive :term:`NREN` L3 Core service subscription. See :class:`NRENL3CoreServiceBlock`."""
"""An inactive L3 Core service subscription. See :class:`L3CoreServiceBlock`."""
nren_ap_list: list[NRENAccessPortInactive] = Field(default_factory=list)
ap_list: list[AccessPortInactive] = Field(default_factory=list)
class NRENL3CoreServiceBlockProvisioning(
NRENL3CoreServiceBlockInactive, lifecycle=[SubscriptionLifecycle.PROVISIONING]
):
"""A provisioning :term:`NREN` L3 Core Service subscription. See :class:`NRENL3CoreServiceBlock`."""
class L3CoreServiceBlockProvisioning(L3CoreServiceBlockInactive, lifecycle=[SubscriptionLifecycle.PROVISIONING]):
"""A provisioning L3 Core Service subscription. See :class:`L3CoreServiceBlock`."""
nren_ap_list: list[NRENAccessPortProvisioning] # type: ignore[assignment]
ap_list: list[AccessPortProvisioning] # type: ignore[assignment]
class NRENL3CoreServiceBlock(NRENL3CoreServiceBlockProvisioning, lifecycle=[SubscriptionLifecycle.ACTIVE]):
"""An active :term:`NREN` L3 Core Service subscription block."""
class L3CoreServiceBlock(L3CoreServiceBlockProvisioning, lifecycle=[SubscriptionLifecycle.ACTIVE]):
"""An active L3 Core Service subscription block."""
#: The list of Access Points where this service is present.
nren_ap_list: list[NRENAccessPort] # type: ignore[assignment]
ap_list: list[AccessPort] # type: ignore[assignment]
"""L3 Core Service product type."""
from orchestrator.domain import SubscriptionModel
from orchestrator.types import SubscriptionLifecycle
from pydantic_forms.types import strEnum
from gso.products.product_blocks.l3_core_service import (
L3CoreServiceBlock,
L3CoreServiceBlockInactive,
L3CoreServiceBlockProvisioning,
)
class L3CoreServiceType(strEnum):
"""Available types of Layer 3 Core Services.
The core services offered include GÉANT IP for R&E access, and the Internet Access Service.
"""
GEANT_IP = "GÉANT IP"
IMPORTED_GEANT_IP = "IMPORTED GÉANT IP"
IAS = "IAS"
IMPORTED_IAS = "IMPORTED IAS"
GWS = "GWS"
IMPORTED_GWS = "IMPORTED GWS"
LHCONE = "LHCONE"
IMPORTED_LHCONE = "IMPORTED LHCONE"
COPERNICUS = "COPERNICUS"
IMPORTED_COPERNICUS = "IMPORTED COPERNICUS"
class L3CoreServiceInactive(SubscriptionModel, is_base=True):
"""An inactive L3 Core Service subscription."""
l3_core_service_type: L3CoreServiceType
l3_core_service: L3CoreServiceBlockInactive
class L3CoreServiceProvisioning(L3CoreServiceInactive, lifecycle=[SubscriptionLifecycle.PROVISIONING]):
"""A L3 Core Service subscription that's being provisioned."""
l3_core_service_type: L3CoreServiceType
l3_core_service: L3CoreServiceBlockProvisioning
class L3CoreService(L3CoreServiceProvisioning, lifecycle=[SubscriptionLifecycle.ACTIVE]):
"""An active L3 Core Service subscription."""
l3_core_service_type: L3CoreServiceType
l3_core_service: L3CoreServiceBlock
class ImportedL3CoreServiceInactive(SubscriptionModel, is_base=True):
"""An imported, inactive L3 Core Service subscription."""
l3_core_service_type: L3CoreServiceType
l3_core_service: L3CoreServiceBlockInactive
class ImportedL3CoreService(
ImportedL3CoreServiceInactive, lifecycle=[SubscriptionLifecycle.PROVISIONING, SubscriptionLifecycle.ACTIVE]
):
"""An imported L3 Core Service subscription."""
l3_core_service_type: L3CoreServiceType
l3_core_service: L3CoreServiceBlock
""":term:`NREN` L3 Core Service product type."""
from orchestrator.domain import SubscriptionModel
from orchestrator.types import SubscriptionLifecycle
from pydantic_forms.types import strEnum
from gso.products.product_blocks.nren_l3_core_service import (
NRENL3CoreServiceBlock,
NRENL3CoreServiceBlockInactive,
NRENL3CoreServiceBlockProvisioning,
)
class NRENL3CoreServiceType(strEnum):
"""Available types of :term:`NREN` Layer 3 Core Services.
The core services offered include GÉANT IP for R&E access, and the Internet Access Service.
"""
GEANT_IP = "GÉANT IP"
IMPORTED_GEANT_IP = "IMPORTED GÉANT IP"
IAS = "IAS"
IMPORTED_IAS = "IMPORTED IAS"
class NRENL3CoreServiceInactive(SubscriptionModel, is_base=True):
"""An inactive :term:`NREN` L3 Core Service subscription."""
nren_l3_core_service_type: NRENL3CoreServiceType
nren_l3_core_service: NRENL3CoreServiceBlockInactive
class NRENL3CoreServiceProvisioning(NRENL3CoreServiceInactive, lifecycle=[SubscriptionLifecycle.PROVISIONING]):
"""A :term:`NREN` L3 Core Service subscription that's being provisioned."""
nren_l3_core_service_type: NRENL3CoreServiceType
nren_l3_core_service: NRENL3CoreServiceBlockProvisioning
class NRENL3CoreService(NRENL3CoreServiceProvisioning, lifecycle=[SubscriptionLifecycle.ACTIVE]):
"""An active :term:`NREN` L3 Core Service subscription."""
nren_l3_core_service_type: NRENL3CoreServiceType
nren_l3_core_service: NRENL3CoreServiceBlock
class ImportedNRENL3CoreServiceInactive(SubscriptionModel, is_base=True):
"""An imported, inactive :term:`NREN` L3 Core Service subscription."""
nren_l3_core_service_type: NRENL3CoreServiceType
nren_l3_core_service: NRENL3CoreServiceBlockInactive
class ImportedNRENL3CoreService(
ImportedNRENL3CoreServiceInactive, lifecycle=[SubscriptionLifecycle.PROVISIONING, SubscriptionLifecycle.ACTIVE]
):
"""An imported :term:`NREN` L3 Core Service subscription."""
nren_l3_core_service_type: NRENL3CoreServiceType
nren_l3_core_service: NRENL3CoreServiceBlock
......@@ -52,18 +52,18 @@
"create_site": "Create Site",
"create_switch": "Create Switch",
"create_edge_port": "Create Edge Port",
"create_nren_l3_core_service": "Create NREN L3 Core Service",
"create_l3_core_service": "Create L3 Core Service",
"create_lan_switch_interconnect": "Create LAN Switch Interconnect",
"deploy_twamp": "Deploy TWAMP",
"migrate_iptrunk": "Migrate IP Trunk",
"migrate_nren_l3_core_service": "Migrate NREN L3 Core Service",
"migrate_l3_core_service": "Migrate L3 Core Service",
"modify_isis_metric": "Modify the ISIS metric",
"modify_site": "Modify Site",
"modify_trunk_interface": "Modify IP Trunk interface",
"modify_connection_strategy": "Modify connection strategy",
"modify_router_kentik_license": "Modify device license in Kentik",
"modify_edge_port": "Modify Edge Port",
"modify_nren_l3_core_service": "Modify NREN L3 Core Service",
"modify_l3_core_service": "Modify L3 Core Service",
"terminate_iptrunk": "Terminate IP Trunk",
"terminate_router": "Terminate Router",
"terminate_site": "Terminate Site",
......@@ -79,7 +79,7 @@
"create_imported_office_router": "NOT FOR HUMANS -- Import existing office router",
"create_imported_opengear": "NOT FOR HUMANS -- Import existing OpenGear",
"create_imported_edge_port": "NOT FOR HUMANS -- Import existing Edge Port",
"create_imported_nren_l3_core_service": "NOT FOR HUMANS -- Import existing NREN L3 Core Service",
"create_imported_l3_core_service": "NOT FOR HUMANS -- Import existing L3 Core Service",
"create_imported_switch": "NOT FOR HUMANS -- Import existing Switch",
"create_imported_lan_switch_interconnect": "NOT FOR HUMANS -- Import existing LAN Switch Interconnect",
"import_site": "NOT FOR HUMANS -- Finalize import into a Site product",
......@@ -89,7 +89,7 @@
"import_super_pop_switch": "NOT FOR HUMANS -- Finalize import into a Super PoP switch",
"import_opengear": "NOT FOR HUMANS -- Finalize import into an OpenGear",
"import_edge_port": "NOT FOR HUMANS -- Finalize import into an Edge Port",
"import_nren_l3_core_service": "NOT FOR HUMANS -- Finalize import into a NREN L3 Core Service",
"import_l3_core_service": "NOT FOR HUMANS -- Finalize import into an L3 Core Service",
"import_switch": "NOT FOR HUMANS -- Finalize import into a Switch",
"import_lan_switch_interconnect": "NOT FOR HUMANS -- Finalize import into a LAN Switch Interconnect",
"validate_iptrunk": "Validate IP Trunk configuration",
......
......@@ -116,14 +116,12 @@ LazyWorkflowInstance("gso.workflows.edge_port.validate_edge_port", "validate_edg
LazyWorkflowInstance("gso.workflows.edge_port.create_imported_edge_port", "create_imported_edge_port")
LazyWorkflowInstance("gso.workflows.edge_port.import_edge_port", "import_edge_port")
# NREN L3 Core Service workflows
LazyWorkflowInstance("gso.workflows.nren_l3_core_service.create_nren_l3_core_service", "create_nren_l3_core_service")
LazyWorkflowInstance("gso.workflows.nren_l3_core_service.modify_nren_l3_core_service", "modify_nren_l3_core_service")
LazyWorkflowInstance(
"gso.workflows.nren_l3_core_service.create_imported_nren_l3_core_service", "create_imported_nren_l3_core_service"
)
LazyWorkflowInstance("gso.workflows.nren_l3_core_service.import_nren_l3_core_service", "import_nren_l3_core_service")
LazyWorkflowInstance("gso.workflows.nren_l3_core_service.migrate_nren_l3_core_service", "migrate_nren_l3_core_service")
# L3 Core Service workflows
LazyWorkflowInstance("gso.workflows.l3_core_service.create_l3_core_service", "create_l3_core_service")
LazyWorkflowInstance("gso.workflows.l3_core_service.modify_l3_core_service", "modify_l3_core_service")
LazyWorkflowInstance("gso.workflows.l3_core_service.create_imported_l3_core_service", "create_imported_l3_core_service")
LazyWorkflowInstance("gso.workflows.l3_core_service.import_l3_core_service", "import_l3_core_service")
LazyWorkflowInstance("gso.workflows.l3_core_service.migrate_l3_core_service", "migrate_l3_core_service")
# Layer 2 Circuit workflows
LazyWorkflowInstance("gso.workflows.l2_circuit.create_layer_2_circuit", "create_layer_2_circuit")
......
"""Layer 3 core service workflows."""
"""A creation workflow for adding an existing NREN L3 Core Service to the service database."""
"""A creation workflow for adding an existing L3 Core Service to the service database."""
from uuid import uuid4
......@@ -6,6 +6,7 @@ from orchestrator import workflow
from orchestrator.forms import FormPage
from orchestrator.targets import Target
from orchestrator.types import FormGenerator, SubscriptionLifecycle
from orchestrator.utils.errors import ProcessFailureError
from orchestrator.workflow import StepList, begin, done, step
from orchestrator.workflows.steps import resync, set_status, store_process_subscription
from pydantic import BaseModel
......@@ -13,10 +14,10 @@ from pydantic_forms.types import UUIDstr
from gso.products import ProductName
from gso.products.product_blocks.bgp_session import BGPSession, IPFamily, IPTypes
from gso.products.product_blocks.nren_l3_core_service import NRENAccessPortInactive
from gso.products.product_blocks.l3_core_service import AccessPortInactive
from gso.products.product_blocks.service_binding_port import BFDSettings, ServiceBindingPortInactive
from gso.products.product_types.edge_port import EdgePort
from gso.products.product_types.nren_l3_core_service import ImportedNRENL3CoreServiceInactive, NRENL3CoreServiceType
from gso.products.product_types.l3_core_service import ImportedL3CoreServiceInactive, L3CoreServiceType
from gso.services.partners import get_partner_by_name
from gso.services.subscriptions import get_product_id_by_name
from gso.utils.shared_enums import SBPType
......@@ -63,30 +64,40 @@ def initial_input_form_generator() -> FormGenerator:
v4_bfd_settings: BFDSettingsModel
v6_bfd_settings: BFDSettingsModel
class ImportNRENL3CoreServiceForm(FormPage):
class ImportL3CoreServiceForm(FormPage):
partner: str
service_binding_ports: list[ServiceBindingPort]
service_type: NRENL3CoreServiceType
service_type: L3CoreServiceType
user_input = yield ImportNRENL3CoreServiceForm
user_input = yield ImportL3CoreServiceForm
return user_input.model_dump()
@step("Create subscription")
def create_subscription(partner: str, service_type: NRENL3CoreServiceType) -> dict:
def create_subscription(partner: str, service_type: L3CoreServiceType) -> dict:
"""Create a new subscription object in the database."""
partner_id = get_partner_by_name(partner)["partner_id"]
if service_type == NRENL3CoreServiceType.GEANT_IP:
product_id = get_product_id_by_name(ProductName.IMPORTED_GEANT_IP)
elif service_type == NRENL3CoreServiceType.IAS:
product_id = get_product_id_by_name(ProductName.IMPORTED_IAS)
subscription = ImportedNRENL3CoreServiceInactive.from_product_id(product_id, partner_id)
match service_type:
case L3CoreServiceType.GEANT_IP:
product_id = get_product_id_by_name(ProductName.IMPORTED_GEANT_IP)
case L3CoreServiceType.IAS:
product_id = get_product_id_by_name(ProductName.IMPORTED_IAS)
case L3CoreServiceType.GWS:
product_id = get_product_id_by_name(ProductName.IMPORTED_GWS)
case L3CoreServiceType.LHCONE:
product_id = get_product_id_by_name(ProductName.IMPORTED_LHCONE)
case L3CoreServiceType.COPERNICUS:
product_id = get_product_id_by_name(ProductName.IMPORTED_COPERNICUS)
case _:
msg = "L3 Core service type not defined. Cannot create subscription."
raise ProcessFailureError(msg, details=service_type)
subscription = ImportedL3CoreServiceInactive.from_product_id(product_id, partner_id)
return {"subscription": subscription, "subscription_id": subscription.subscription_id}
@step("Initialize subscription")
def initialize_subscription(subscription: ImportedNRENL3CoreServiceInactive, service_binding_ports: list) -> dict:
def initialize_subscription(subscription: ImportedL3CoreServiceInactive, service_binding_ports: list) -> dict:
"""Initialize the subscription with the user input."""
for service_binding_port in service_binding_ports:
edge_port_subscription = EdgePort.from_subscription(service_binding_port.pop("edge_port"))
......@@ -109,8 +120,8 @@ def initialize_subscription(subscription: ImportedNRENL3CoreServiceInactive, ser
v6_bfd_settings=BFDSettings.new(subscription_id=uuid4(), **(service_binding_port.pop("v6_bfd_settings"))),
**service_binding_port,
)
subscription.nren_l3_core_service.nren_ap_list.append(
NRENAccessPortInactive.new(
subscription.l3_core_service.ap_list.append(
AccessPortInactive.new(
subscription_id=uuid4(),
ap_type=service_binding_port["ap_type"],
sbp=service_binding_port_subscription,
......@@ -123,11 +134,11 @@ def initialize_subscription(subscription: ImportedNRENL3CoreServiceInactive, ser
@workflow(
"Create imported NREN L3 Core Service",
"Create imported L3 Core Service",
initial_input_form=initial_input_form_generator,
target=Target.CREATE,
)
def create_imported_nren_l3_core_service() -> StepList:
def create_imported_l3_core_service() -> StepList:
"""Import a GÉANT IP without provisioning it."""
return (
begin
......
"""Create a new NREN L3 Core Service subscription including GÉANT IP and IAS."""
"""Create a new L3 Core Service subscription including GÉANT IP and IAS."""
from typing import Any
from uuid import uuid4
......@@ -14,10 +14,10 @@ from pydantic import BaseModel, ConfigDict, Field, computed_field
from pydantic_forms.validators import Divider
from gso.products.product_blocks.bgp_session import BGPSession, IPFamily, IPTypes
from gso.products.product_blocks.nren_l3_core_service import NRENAccessPortInactive
from gso.products.product_blocks.l3_core_service import AccessPortInactive
from gso.products.product_blocks.service_binding_port import BFDSettings, ServiceBindingPortInactive
from gso.products.product_types.edge_port import EdgePort
from gso.products.product_types.nren_l3_core_service import NRENL3CoreService, NRENL3CoreServiceInactive
from gso.products.product_types.l3_core_service import L3CoreService, L3CoreServiceInactive
from gso.services.lso_client import LSOState, lso_interaction
from gso.services.partners import get_partner_by_id
from gso.utils.helpers import (
......@@ -33,13 +33,13 @@ from gso.utils.types.virtual_identifiers import VLAN_ID
def initial_input_form_generator(product_name: str) -> FormGenerator:
"""Gather input from the operator to build a new subscription object."""
class CreateNRENCoreServiceForm(FormPage):
class CreateL3CoreServiceForm(FormPage):
model_config = ConfigDict(title=f"{product_name} - Select partner")
tt_number: TTNumber
partner: partner_choice() # type: ignore[valid-type]
initial_user_input = yield CreateNRENCoreServiceForm
initial_user_input = yield CreateL3CoreServiceForm
class EdgePortSelection(BaseModel):
edge_port: active_edge_port_selector(partner_id=initial_user_input.partner) # type: ignore[valid-type]
......@@ -146,25 +146,20 @@ def initial_input_form_generator(product_name: str) -> FormGenerator:
@step("Create subscription")
def create_subscription(product: UUIDstr, partner: str) -> State:
"""Create a new subscription object in the database."""
subscription = NRENL3CoreServiceInactive.from_product_id(product, partner)
subscription = L3CoreServiceInactive.from_product_id(product, partner)
return {"subscription": subscription, "subscription_id": subscription.subscription_id}
@step("Initialize subscription")
def initialize_subscription(
subscription: NRENL3CoreServiceInactive, edge_port: dict, binding_port_input: dict, product_name: str
subscription: L3CoreServiceInactive, edge_port: dict, binding_port_input: dict, product_name: str
) -> State:
"""Take all user inputs and use them to populate the subscription model."""
edge_port_fqdn_list = []
edge_port_subscription = EdgePort.from_subscription(edge_port["edge_port"])
sbp_bgp_session_list = [
BGPSession.new(
subscription_id=uuid4(),
rtbh_enabled=True,
is_multi_hop=True,
**session,
)
BGPSession.new(subscription_id=uuid4(), rtbh_enabled=True, is_multi_hop=True, **session)
for session in binding_port_input["bgp_peers"]
]
service_binding_port = ServiceBindingPortInactive.new(
......@@ -176,8 +171,8 @@ def initialize_subscription(
sbp_type=SBPType.L3,
edge_port=edge_port_subscription.edge_port,
)
subscription.nren_l3_core_service.nren_ap_list.append(
NRENAccessPortInactive.new(
subscription.l3_core_service.ap_list.append(
AccessPortInactive.new(
subscription_id=uuid4(),
ap_type=edge_port["ap_type"],
sbp=service_binding_port,
......@@ -206,7 +201,7 @@ def provision_sbp_dry(
}
return {
"playbook_name": "gap_ansible/playbooks/nren_l3_core_service.yaml",
"playbook_name": "gap_ansible/playbooks/l3_core_service.yaml",
"inventory": {"all": {"hosts": dict.fromkeys(edge_port_fqdn_list)}},
"extra_vars": extra_vars,
}
......@@ -228,7 +223,7 @@ def provision_sbp_real(
}
return {
"playbook_name": "gap_ansible/playbooks/nren_l3_core_service.yaml",
"playbook_name": "gap_ansible/playbooks/l3_core_service.yaml",
"inventory": {"all": {"hosts": dict.fromkeys(edge_port_fqdn_list)}},
"extra_vars": extra_vars,
}
......@@ -240,7 +235,7 @@ def check_sbp_functionality(subscription: dict[str, Any], edge_port_fqdn_list: l
extra_vars = {"subscription": subscription, "verb": "check", "object": "sbp"}
return {
"playbook_name": "gap_ansible/playbooks/nren_l3_core_service.yaml",
"playbook_name": "gap_ansible/playbooks/l3_core_service.yaml",
"inventory": {"all": {"hosts": dict.fromkeys(edge_port_fqdn_list)}},
"extra_vars": extra_vars,
}
......@@ -262,7 +257,7 @@ def deploy_bgp_peers_dry(
}
return {
"playbook_name": "gap_ansible/playbooks/nren_l3_core_service.yaml",
"playbook_name": "gap_ansible/playbooks/l3_core_service.yaml",
"inventory": {"all": {"hosts": dict.fromkeys(edge_port_fqdn_list)}},
"extra_vars": extra_vars,
}
......@@ -284,7 +279,7 @@ def deploy_bgp_peers_real(
}
return {
"playbook_name": "gap_ansible/playbooks/nren_l3_core_service.yaml",
"playbook_name": "gap_ansible/playbooks/l3_core_service.yaml",
"inventory": {"all": {"hosts": dict.fromkeys(edge_port_fqdn_list)}},
"extra_vars": extra_vars,
}
......@@ -296,26 +291,26 @@ def check_bgp_peers(subscription: dict[str, Any], edge_port_fqdn_list: list[str]
extra_vars = {"subscription": subscription, "verb": "check", "object": "bgp"}
return {
"playbook_name": "gap_ansible/playbooks/nren_l3_core_service.yaml",
"playbook_name": "gap_ansible/playbooks/l3_core_service.yaml",
"inventory": {"all": {"hosts": dict.fromkeys(edge_port_fqdn_list)}},
"extra_vars": extra_vars,
}
@step("Update Infoblox")
def update_dns_records(subscription: NRENL3CoreService) -> State:
def update_dns_records(subscription: L3CoreService) -> State:
"""Update :term:`DNS` records in Infoblox."""
# TODO: implement
return {"subscription": subscription}
@workflow(
"Create NREN L3 Core Service",
"Create L3 Core Service",
initial_input_form=wrap_create_initial_input_form(initial_input_form_generator),
target=Target.CREATE,
)
def create_nren_l3_core_service() -> StepList:
"""Create a new :term:`NREN` L3 Core Service subscription including GÉANT IP and IAS.
def create_l3_core_service() -> StepList:
"""Create a new L3 Core Service subscription including GÉANT IP and IAS.
* Create subscription object in the service database
* Deploy service binding ports
......
......@@ -8,38 +8,45 @@ from orchestrator.workflows.steps import resync, store_process_subscription, uns
from orchestrator.workflows.utils import wrap_modify_initial_input_form
from gso.products import ProductName
from gso.products.product_types.nren_l3_core_service import (
ImportedNRENL3CoreService,
NRENL3CoreService,
NRENL3CoreServiceType,
from gso.products.product_types.l3_core_service import (
ImportedL3CoreService,
L3CoreService,
L3CoreServiceType,
)
from gso.services.subscriptions import get_product_id_by_name
@step("Create imported subscription")
def import_nren_l3_core_service_subscription(subscription_id: UUIDstr) -> State:
"""Take an imported subscription, and turn it into an :term:`NREN` L3 Core Service subscription."""
old_nren_l3_core_service = ImportedNRENL3CoreService.from_subscription(subscription_id)
if old_nren_l3_core_service.nren_l3_core_service_type == NRENL3CoreServiceType.IMPORTED_GEANT_IP:
new_subscription_id = get_product_id_by_name(ProductName.GEANT_IP)
elif old_nren_l3_core_service.nren_l3_core_service_type == NRENL3CoreServiceType.IMPORTED_IAS:
new_subscription_id = get_product_id_by_name(ProductName.IAS)
else:
msg = f"This {old_nren_l3_core_service.nren_l3_core_service_type} is already imported, nothing to do."
raise ProcessFailureError(message=msg, details=old_nren_l3_core_service)
new_subscription = NRENL3CoreService.from_other_product(old_nren_l3_core_service, new_subscription_id) # type: ignore[arg-type]
def import_l3_core_service_subscription(subscription_id: UUIDstr) -> State:
"""Take an imported subscription, and turn it into an L3 Core Service subscription."""
old_l3_core_service = ImportedL3CoreService.from_subscription(subscription_id)
match old_l3_core_service.l3_core_service_type:
case L3CoreServiceType.IMPORTED_GEANT_IP:
new_subscription_id = get_product_id_by_name(ProductName.GEANT_IP)
case L3CoreServiceType.IMPORTED_IAS:
new_subscription_id = get_product_id_by_name(ProductName.IAS)
case L3CoreServiceType.IMPORTED_GWS:
new_subscription_id = get_product_id_by_name(ProductName.GWS)
case L3CoreServiceType.IMPORTED_LHCONE:
new_subscription_id = get_product_id_by_name(ProductName.LHCONE)
case L3CoreServiceType.IMPORTED_COPERNICUS:
new_subscription_id = get_product_id_by_name(ProductName.COPERNICUS)
case _:
msg = f"This {old_l3_core_service.l3_core_service_type} is already imported, nothing to do."
raise ProcessFailureError(message=msg, details=old_l3_core_service)
new_subscription = L3CoreService.from_other_product(old_l3_core_service, new_subscription_id) # type: ignore[arg-type]
return {"subscription": new_subscription}
@workflow("Import NREN L3 Core Service", target=Target.MODIFY, initial_input_form=wrap_modify_initial_input_form(None))
def import_nren_l3_core_service() -> StepList:
"""Modify an imported subscription into an :term:`NREN` L3 Core Service subscription to complete the import."""
@workflow("Import L3 Core Service", target=Target.MODIFY, initial_input_form=wrap_modify_initial_input_form(None))
def import_l3_core_service() -> StepList:
"""Modify an imported subscription into an L3 Core Service subscription to complete the import."""
return (
init
>> store_process_subscription(Target.MODIFY)
>> unsync
>> import_nren_l3_core_service_subscription
>> import_l3_core_service_subscription
>> resync
>> done
)
......@@ -14,21 +14,19 @@ from pydantic_forms.types import FormGenerator, State, UUIDstr
from pydantic_forms.validators import Choice, Divider
from gso.products.product_types.edge_port import EdgePort
from gso.products.product_types.nren_l3_core_service import NRENL3CoreService
from gso.products.product_types.l3_core_service import L3CoreService
from gso.services.subscriptions import get_active_edge_port_subscriptions
from gso.utils.types.tt_number import TTNumber
def initial_input_form_generator(subscription_id: UUIDstr) -> FormGenerator:
"""Gather input from the operator on what new Edge Ports this L3 Core Service should be migrated to."""
subscription = NRENL3CoreService.from_subscription(subscription_id)
subscription = L3CoreService.from_subscription(subscription_id)
partner_id = subscription.customer_id
edge_port_count = len(subscription.nren_l3_core_service.nren_ap_list)
edge_port_count = len(subscription.l3_core_service.ap_list)
def _new_edge_port_selector(pid: UUIDstr) -> Choice:
existing_ep_name_list = [
ap.sbp.edge_port.owner_subscription_id for ap in subscription.nren_l3_core_service.nren_ap_list
]
existing_ep_name_list = [ap.sbp.edge_port.owner_subscription_id for ap in subscription.l3_core_service.ap_list]
edge_port_subscriptions = list(
filter(
lambda ep: bool(ep["customer_id"] == pid) and ep["subscription_id"] not in existing_ep_name_list,
......@@ -54,7 +52,7 @@ def initial_input_form_generator(subscription_id: UUIDstr) -> FormGenerator:
raise ValueError(msg)
return edge_ports
class NRENL3CoreServiceEdgePortSelectionForm(FormPage):
class L3CoreServiceEdgePortSelectionForm(FormPage):
model_config = ConfigDict(title=f"Migrating {subscription.product.name} to a new set of Edge Ports")
tt_number: TTNumber
......@@ -70,19 +68,19 @@ def initial_input_form_generator(subscription_id: UUIDstr) -> FormGenerator:
})",
new_edge_port="",
)
for ap in subscription.nren_l3_core_service.nren_ap_list
for ap in subscription.l3_core_service.ap_list
]
ep_user_input = yield NRENL3CoreServiceEdgePortSelectionForm
ep_user_input = yield L3CoreServiceEdgePortSelectionForm
return {"subscription_id": subscription_id, "subscription": subscription} | ep_user_input.model_dump()
@step("Update subscription model")
def update_subscription_model(subscription: NRENL3CoreService, edge_port_selection: list[dict]) -> State:
def update_subscription_model(subscription: L3CoreService, edge_port_selection: list[dict]) -> State:
"""Update the subscription model with the new list of Access Ports."""
for index, selected_port in enumerate(edge_port_selection):
subscription.nren_l3_core_service.nren_ap_list[index].sbp.edge_port = EdgePort.from_subscription(
subscription.l3_core_service.ap_list[index].sbp.edge_port = EdgePort.from_subscription(
selected_port["new_edge_port"]
).edge_port
......@@ -90,10 +88,10 @@ def update_subscription_model(subscription: NRENL3CoreService, edge_port_selecti
@workflow(
"Migrate NREN L3 Core Service",
"Migrate L3 Core Service",
initial_input_form=wrap_modify_initial_input_form(initial_input_form_generator),
target=Target.MODIFY,
)
def migrate_nren_l3_core_service() -> StepList:
"""Migrate a :term:`NREN` L3 Core Service to a new set of Edge Ports."""
def migrate_l3_core_service() -> StepList:
"""Migrate a L3 Core Service to a new set of Edge Ports."""
return begin >> store_process_subscription(Target.MODIFY) >> unsync >> update_subscription_model >> resync >> done
"""A modification workflow for a :term:`NREN` L3 Core Service subscription."""
"""A modification workflow for a L3 Core Service subscription."""
from typing import Annotated, Any
from uuid import uuid4
......@@ -15,10 +15,10 @@ from pydantic_forms.types import State
from pydantic_forms.validators import Divider, Label
from gso.products.product_blocks.bgp_session import BGPSession, IPFamily, IPTypes
from gso.products.product_blocks.nren_l3_core_service import NRENAccessPort
from gso.products.product_blocks.l3_core_service import AccessPort
from gso.products.product_blocks.service_binding_port import BFDSettings, ServiceBindingPort
from gso.products.product_types.edge_port import EdgePort
from gso.products.product_types.nren_l3_core_service import NRENL3CoreService
from gso.products.product_types.l3_core_service import L3CoreService
from gso.utils.helpers import active_edge_port_selector
from gso.utils.shared_enums import APType, SBPType
from gso.utils.types.ip_address import IPv4AddressType, IPV4Netmask, IPv6AddressType, IPV6Netmask
......@@ -27,7 +27,7 @@ from gso.utils.types.virtual_identifiers import VLAN_ID
def initial_input_form_generator(subscription_id: UUIDstr) -> FormGenerator:
"""Get input about added, removed, and modified Access Ports."""
subscription = NRENL3CoreService.from_subscription(subscription_id)
subscription = L3CoreService.from_subscription(subscription_id)
product_name = subscription.product.name
class AccessPortSelection(BaseModel):
......@@ -49,15 +49,13 @@ def initial_input_form_generator(subscription_id: UUIDstr) -> FormGenerator:
edge_port=str(access_port.sbp.edge_port.owner_subscription_id),
ap_type=access_port.ap_type,
)
for access_port in subscription.nren_l3_core_service.nren_ap_list
for access_port in subscription.l3_core_service.ap_list
]
access_port_input = yield ModifyAccessPortsForm
input_ap_list = access_port_input.access_ports
input_ep_list = [str(ap.edge_port) for ap in input_ap_list]
existing_ep_list = [
str(ap.sbp.edge_port.owner_subscription_id) for ap in subscription.nren_l3_core_service.nren_ap_list
]
existing_ep_list = [str(ap.sbp.edge_port.owner_subscription_id) for ap in subscription.l3_core_service.ap_list]
class BFDInputModel(BaseModel):
bfd_enabled: bool = False
......@@ -109,7 +107,7 @@ def initial_input_form_generator(subscription_id: UUIDstr) -> FormGenerator:
# modified.
removed_ap_list = [
access_port.subscription_instance_id
for access_port in subscription.nren_l3_core_service.nren_ap_list
for access_port in subscription.l3_core_service.ap_list
if str(access_port.sbp.edge_port.owner_subscription_id) not in input_ep_list
]
modified_ap_list = [
......@@ -124,7 +122,7 @@ def initial_input_form_generator(subscription_id: UUIDstr) -> FormGenerator:
None,
),
)
for access_port in subscription.nren_l3_core_service.nren_ap_list
for access_port in subscription.l3_core_service.ap_list
if str(access_port.sbp.edge_port.owner_subscription_id) in input_ep_list
]
added_ap_list = [
......@@ -245,11 +243,11 @@ def initial_input_form_generator(subscription_id: UUIDstr) -> FormGenerator:
@step("Clean up removed Edge Ports")
def remove_old_sbp_blocks(subscription: NRENL3CoreService, removed_access_ports: list[UUIDstr]) -> State:
def remove_old_sbp_blocks(subscription: L3CoreService, removed_access_ports: list[UUIDstr]) -> State:
"""Remove old :term:`SBP` product blocks from the GÉANT IP subscription."""
subscription.nren_l3_core_service.nren_ap_list = [
subscription.l3_core_service.ap_list = [
ap
for ap in subscription.nren_l3_core_service.nren_ap_list
for ap in subscription.l3_core_service.ap_list
if str(ap.subscription_instance_id) not in removed_access_ports
]
......@@ -257,9 +255,9 @@ def remove_old_sbp_blocks(subscription: NRENL3CoreService, removed_access_ports:
@step("Modify existing Service Binding Ports")
def modify_existing_sbp_blocks(subscription: NRENL3CoreService, modified_sbp_list: list[dict[str, Any]]) -> State:
def modify_existing_sbp_blocks(subscription: L3CoreService, modified_sbp_list: list[dict[str, Any]]) -> State:
"""Update the subscription model."""
for access_port in subscription.nren_l3_core_service.nren_ap_list:
for access_port in subscription.l3_core_service.ap_list:
current_sbp = access_port.sbp
modified_sbp_data = next(
sbp for sbp in modified_sbp_list if sbp["current_sbp_id"] == str(current_sbp.subscription_instance_id)
......@@ -290,8 +288,8 @@ def modify_existing_sbp_blocks(subscription: NRENL3CoreService, modified_sbp_lis
@step("Instantiate new Service Binding Ports")
def create_new_sbp_blocks(subscription: NRENL3CoreService, added_service_binding_ports: list[dict[str, Any]]) -> State:
"""Add new two :term:`SBP` to the :term:`NREN` L3 Core Service subscription."""
def create_new_sbp_blocks(subscription: L3CoreService, added_service_binding_ports: list[dict[str, Any]]) -> State:
"""Add new two :term:`SBP` to the L3 Core Service subscription."""
for sbp_input in added_service_binding_ports:
edge_port = EdgePort.from_subscription(sbp_input["edge_port_id"])
bgp_session_list = [
......@@ -309,8 +307,8 @@ def create_new_sbp_blocks(subscription: NRENL3CoreService, added_service_binding
sbp_type=SBPType.L3,
edge_port=edge_port.edge_port,
)
subscription.nren_l3_core_service.nren_ap_list.append(
NRENAccessPort.new(
subscription.l3_core_service.ap_list.append(
AccessPort.new(
subscription_id=uuid4(),
ap_type=sbp_input["ap_type"],
sbp=service_binding_port,
......@@ -321,11 +319,11 @@ def create_new_sbp_blocks(subscription: NRENL3CoreService, added_service_binding
@workflow(
"Modify NREN L3 Core Service",
"Modify L3 Core Service",
initial_input_form=wrap_modify_initial_input_form(initial_input_form_generator),
target=Target.MODIFY,
)
def modify_nren_l3_core_service() -> StepList:
def modify_l3_core_service() -> StepList:
"""Modify a NRN L3 Core Service subscription."""
access_ports_are_removed = conditional(lambda state: bool(len(state["removed_access_ports"]) > 0))
access_ports_are_modified = conditional(lambda state: bool(len(state["modified_sbp_list"]) > 0))
......
""":term:`NREN` layer 3 core service workflows."""
......@@ -7,9 +7,9 @@ import pytest
from gso.cli.imports import (
import_edge_port,
import_iptrunks,
import_l3_core_service,
import_lan_switch_interconnect,
import_layer_2_circuit_service,
import_nren_l3_core_service,
import_office_routers,
import_opengear,
import_routers,
......@@ -296,9 +296,9 @@ def edge_port_data(temp_file, faker, router_subscription_factory, partner_factor
@pytest.fixture()
def nren_l3_core_service_data(temp_file, faker, partner_factory, edge_port_subscription_factory):
def _nren_l3_core_service_data(**kwargs):
nren_l3_core_service_data = {
def l3_core_service_data(temp_file, faker, partner_factory, edge_port_subscription_factory):
def _l3_core_service_data(**kwargs):
l3_core_service_data = {
"partner": partner_factory()["name"],
"service_type": "IMPORTED IAS",
"service_binding_ports": [
......@@ -400,12 +400,12 @@ def nren_l3_core_service_data(temp_file, faker, partner_factory, edge_port_subsc
},
],
}
nren_l3_core_service_data.update(**kwargs)
l3_core_service_data.update(**kwargs)
temp_file.write_text(json.dumps([nren_l3_core_service_data]))
return {"path": str(temp_file), "data": nren_l3_core_service_data}
temp_file.write_text(json.dumps([l3_core_service_data]))
return {"path": str(temp_file), "data": l3_core_service_data}
return _nren_l3_core_service_data
return _l3_core_service_data
@pytest.fixture()
......@@ -670,18 +670,16 @@ def test_import_edge_port_with_invalid_partner(mock_start_process, mock_sleep, e
@patch("gso.cli.imports.time.sleep")
@patch("gso.cli.imports.start_process")
def test_import_nren_l3_core_service_success(mock_start_process, mock_sleep, nren_l3_core_service_data, capfd):
import_nren_l3_core_service(nren_l3_core_service_data()["path"])
def test_import_l3_core_service_success(mock_start_process, mock_sleep, l3_core_service_data, capfd):
import_l3_core_service(l3_core_service_data()["path"])
assert mock_start_process.call_count == 1
@patch("gso.cli.imports.time.sleep")
@patch("gso.cli.imports.start_process")
def test_import_nren_l3_core_service_with_invalid_partner(
mock_start_process, mock_sleep, nren_l3_core_service_data, capfd
):
broken_data = nren_l3_core_service_data(partner="INVALID")
import_nren_l3_core_service(broken_data["path"])
def test_import_l3_core_service_with_invalid_partner(mock_start_process, mock_sleep, l3_core_service_data, capfd):
broken_data = l3_core_service_data(partner="INVALID")
import_l3_core_service(broken_data["path"])
captured_output, _ = capfd.readouterr()
assert "Partner INVALID not found" in captured_output
......@@ -690,11 +688,11 @@ def test_import_nren_l3_core_service_with_invalid_partner(
@patch("gso.cli.imports.time.sleep")
@patch("gso.cli.imports.start_process")
def test_import_nren_l3_core_service_with_invalid_edge_port(
mock_start_process, mock_sleep, faker, nren_l3_core_service_data, edge_port_subscription_factory, capfd
def test_import_l3_core_service_with_invalid_edge_port(
mock_start_process, mock_sleep, faker, l3_core_service_data, edge_port_subscription_factory, capfd
):
fake_uuid = faker.uuid4()
broken_data = nren_l3_core_service_data(
broken_data = l3_core_service_data(
service_binding_ports=[
{
"edge_port": fake_uuid,
......@@ -778,7 +776,7 @@ def test_import_nren_l3_core_service_with_invalid_edge_port(
},
]
)
import_nren_l3_core_service(broken_data["path"])
import_l3_core_service(broken_data["path"])
captured_output, _ = capfd.readouterr()
assert f"Edge Port {fake_uuid} not found" in captured_output
......
from test.fixtures.edge_port_fixtures import edge_port_subscription_factory
from test.fixtures.iptrunk_fixtures import iptrunk_side_subscription_factory, iptrunk_subscription_factory
from test.fixtures.lan_switch_interconnect_fixtures import lan_switch_interconnect_subscription_factory
from test.fixtures.layer_2_circuit_fixtures import layer_2_circuit_subscription_factory
from test.fixtures.nren_l3_core_service_fixtures import (
from test.fixtures.l3_core_service_fixtures import (
access_port_factory,
bfd_settings_factory,
bgp_session_subscription_factory,
nren_access_port_factory,
nren_l3_core_service_subscription_factory,
l3_core_service_subscription_factory,
service_binding_port_factory,
)
from test.fixtures.lan_switch_interconnect_fixtures import lan_switch_interconnect_subscription_factory
from test.fixtures.layer_2_circuit_fixtures import layer_2_circuit_subscription_factory
from test.fixtures.office_router_fixtures import office_router_subscription_factory
from test.fixtures.opengear_fixtures import opengear_subscription_factory
from test.fixtures.router_fixtures import router_subscription_factory
......@@ -17,15 +17,15 @@ from test.fixtures.super_pop_switch_fixtures import super_pop_switch_subscriptio
from test.fixtures.switch_fixtures import switch_subscription_factory
__all__ = [
"access_port_factory",
"bfd_settings_factory",
"bgp_session_subscription_factory",
"edge_port_subscription_factory",
"iptrunk_side_subscription_factory",
"iptrunk_subscription_factory",
"l3_core_service_subscription_factory",
"lan_switch_interconnect_subscription_factory",
"layer_2_circuit_subscription_factory",
"nren_access_port_factory",
"nren_l3_core_service_subscription_factory",
"office_router_subscription_factory",
"opengear_subscription_factory",
"router_subscription_factory",
......
......@@ -8,13 +8,13 @@ from orchestrator.types import SubscriptionLifecycle, UUIDstr
from gso.products import ProductName
from gso.products.product_blocks.bgp_session import BGPSession, IPFamily, IPTypes
from gso.products.product_blocks.nren_l3_core_service import NRENAccessPort
from gso.products.product_blocks.l3_core_service import AccessPort
from gso.products.product_blocks.service_binding_port import BFDSettings, ServiceBindingPort
from gso.products.product_types.edge_port import EdgePort
from gso.products.product_types.nren_l3_core_service import (
ImportedNRENL3CoreService,
NRENL3CoreServiceInactive,
NRENL3CoreServiceType,
from gso.products.product_types.l3_core_service import (
ImportedL3CoreService,
L3CoreServiceInactive,
L3CoreServiceType,
)
from gso.services import subscriptions
from gso.utils.shared_enums import APType, SBPType
......@@ -120,78 +120,108 @@ def service_binding_port_factory(
@pytest.fixture()
def nren_access_port_factory(faker, service_binding_port_factory):
def create_nren_access_port(
nren_ap_type: APType | None = None,
def access_port_factory(faker, service_binding_port_factory):
def create_access_port(
ap_type: APType | None = None,
service_binding_port: ServiceBindingPort | None = None,
):
return NRENAccessPort.new(
return AccessPort.new(
subscription_id=uuid4(),
ap_type=nren_ap_type or random.choice(list(APType)), # noqa: S311
ap_type=ap_type or random.choice(list(APType)), # noqa: S311
sbp=service_binding_port or service_binding_port_factory(),
)
return create_nren_access_port
return create_access_port
@pytest.fixture()
def nren_l3_core_service_subscription_factory(
def l3_core_service_subscription_factory(
faker,
partner_factory,
nren_access_port_factory,
access_port_factory,
):
def create_nren_l3_core_service_subscription(
nren_l3_core_service_type: NRENL3CoreServiceType,
def create_l3_core_service_subscription(
l3_core_service_type: L3CoreServiceType,
description=None,
partner: dict | None = None,
nren_ap_list: list[NRENAccessPort] | None = None,
ap_list: list[AccessPort] | None = None,
start_date="2023-05-24T00:00:00+00:00",
status: SubscriptionLifecycle | None = None,
) -> UUIDstr:
partner = partner or partner_factory()
match nren_l3_core_service_type:
case NRENL3CoreServiceType.GEANT_IP:
match l3_core_service_type:
case L3CoreServiceType.GEANT_IP:
product_id = subscriptions.get_product_id_by_name(ProductName.GEANT_IP)
nren_l3_core_service_subscription = NRENL3CoreServiceInactive.from_product_id(
l3_core_service_subscription = L3CoreServiceInactive.from_product_id(
product_id, customer_id=partner["partner_id"], insync=True
)
case NRENL3CoreServiceType.IMPORTED_GEANT_IP:
case L3CoreServiceType.IMPORTED_GEANT_IP:
product_id = subscriptions.get_product_id_by_name(ProductName.IMPORTED_GEANT_IP)
nren_l3_core_service_subscription = ImportedNRENL3CoreService.from_product_id(
l3_core_service_subscription = ImportedL3CoreService.from_product_id(
product_id, customer_id=partner["partner_id"], insync=True
)
case NRENL3CoreServiceType.IAS:
case L3CoreServiceType.IAS:
product_id = subscriptions.get_product_id_by_name(ProductName.IAS)
nren_l3_core_service_subscription = NRENL3CoreServiceInactive.from_product_id(
l3_core_service_subscription = L3CoreServiceInactive.from_product_id(
product_id, customer_id=partner["partner_id"], insync=True
)
case NRENL3CoreServiceType.IMPORTED_IAS:
case L3CoreServiceType.IMPORTED_IAS:
product_id = subscriptions.get_product_id_by_name(ProductName.IMPORTED_IAS)
nren_l3_core_service_subscription = ImportedNRENL3CoreService.from_product_id(
l3_core_service_subscription = ImportedL3CoreService.from_product_id(
product_id, customer_id=partner["partner_id"], insync=True
)
case L3CoreServiceType.GWS:
product_id = subscriptions.get_product_id_by_name(ProductName.GWS)
l3_core_service_subscription = L3CoreServiceInactive.from_product_id(
product_id, customer_id=partner["partner_id"], insync=True
)
case L3CoreServiceType.IMPORTED_GWS:
product_id = subscriptions.get_product_id_by_name(ProductName.IMPORTED_GWS)
l3_core_service_subscription = ImportedL3CoreService.from_product_id(
product_id, customer_id=partner["partner_id"], insync=True
)
case L3CoreServiceType.LHCONE:
product_id = subscriptions.get_product_id_by_name(ProductName.LHCONE)
l3_core_service_subscription = L3CoreServiceInactive.from_product_id(
product_id, customer_id=partner["partner_id"], insync=True
)
case L3CoreServiceType.IMPORTED_LHCONE:
product_id = subscriptions.get_product_id_by_name(ProductName.IMPORTED_LHCONE)
l3_core_service_subscription = ImportedL3CoreService.from_product_id(
product_id, customer_id=partner["partner_id"], insync=True
)
case L3CoreServiceType.COPERNICUS:
product_id = subscriptions.get_product_id_by_name(ProductName.COPERNICUS)
l3_core_service_subscription = L3CoreServiceInactive.from_product_id(
product_id, customer_id=partner["partner_id"], insync=True
)
case L3CoreServiceType.IMPORTED_COPERNICUS:
product_id = subscriptions.get_product_id_by_name(ProductName.IMPORTED_COPERNICUS)
l3_core_service_subscription = ImportedL3CoreService.from_product_id(
product_id, customer_id=partner["partner_id"], insync=True
)
case _:
msg = f"NREN L3 Core Service type not found: {nren_l3_core_service_type}"
msg = f"L3 Core Service type not found: {l3_core_service_type}"
raise ValueError(msg)
# Default nren_ap_list creation with primary and backup access ports
nren_l3_core_service_subscription.nren_l3_core_service.nren_ap_list = nren_ap_list or [
nren_access_port_factory(nren_ap_type=APType.PRIMARY),
nren_access_port_factory(nren_ap_type=APType.BACKUP),
# Default ap_list creation with primary and backup access ports
l3_core_service_subscription.l3_core_service.ap_list = ap_list or [
access_port_factory(ap_type=APType.PRIMARY),
access_port_factory(ap_type=APType.BACKUP),
]
# Update subscription with description, start date, and status
nren_l3_core_service_subscription = SubscriptionModel.from_other_lifecycle(
nren_l3_core_service_subscription,
l3_core_service_subscription = SubscriptionModel.from_other_lifecycle(
l3_core_service_subscription,
SubscriptionLifecycle.ACTIVE,
)
nren_l3_core_service_subscription.description = description or faker.sentence()
nren_l3_core_service_subscription.start_date = start_date
nren_l3_core_service_subscription.status = status or SubscriptionLifecycle.ACTIVE
nren_l3_core_service_subscription.save()
l3_core_service_subscription.description = description or faker.sentence()
l3_core_service_subscription.start_date = start_date
l3_core_service_subscription.status = status or SubscriptionLifecycle.ACTIVE
l3_core_service_subscription.save()
db.session.commit()
return str(nren_l3_core_service_subscription.subscription_id)
return str(l3_core_service_subscription.subscription_id)
return create_nren_l3_core_service_subscription
return create_l3_core_service_subscription
......@@ -62,7 +62,7 @@ def _set_up_host_responses():
responses.add(
method=responses.GET,
url="https://10.0.0.1/wapi/v2.12/record%3Ahost?name=test.lo.geant.net&_return_fields=extattrs%2Cipv4addrs%2Cnam"
"e%2Cview%2Caliases",
"e%2Cview%2Ciases",
json=[],
)
......
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