Skip to content
Snippets Groups Projects

Fixed import l3 core services bug

Merged Neda Moeini requested to merge fix/import-l3-service into develop
7 files
+ 100
88
Compare changes
  • Side-by-side
  • Inline
Files
7
+ 12
10
@@ -12,6 +12,7 @@ import typer
@@ -12,6 +12,7 @@ import typer
import yaml
import yaml
from orchestrator.db import db
from orchestrator.db import db
from orchestrator.services.processes import start_process
from orchestrator.services.processes import start_process
 
from orchestrator.services.products import get_product_by_id
from orchestrator.types import SubscriptionLifecycle
from orchestrator.types import SubscriptionLifecycle
from pydantic import BaseModel, NonNegativeInt, ValidationError, field_validator, model_validator
from pydantic import BaseModel, NonNegativeInt, ValidationError, field_validator, model_validator
from pydantic_forms.types import UUIDstr
from pydantic_forms.types import UUIDstr
@@ -53,7 +54,7 @@ from gso.utils.types.ip_address import (
@@ -53,7 +54,7 @@ from gso.utils.types.ip_address import (
PortNumber,
PortNumber,
)
)
from gso.utils.types.virtual_identifiers import VC_ID, VLAN_ID
from gso.utils.types.virtual_identifiers import VC_ID, VLAN_ID
from gso.workflows.l3_core_service.shared import L3_CREAT_IMPORTED_WF_MAP, L3ProductNameType
from gso.workflows.l3_core_service.shared import L3_CREAT_IMPORTED_WF_MAP, L3_IMPORT_WF_MAP, L3ProductNameType
app: typer.Typer = typer.Typer()
app: typer.Typer = typer.Typer()
IMPORT_WAIT_MESSAGE = "Waiting for the dust to settle before importing new products..."
IMPORT_WAIT_MESSAGE = "Waiting for the dust to settle before importing new products..."
@@ -672,18 +673,18 @@ def import_l3_core_service(filepath: str = common_filepath_option) -> None:
@@ -672,18 +673,18 @@ def import_l3_core_service(filepath: str = common_filepath_option) -> None:
l3_core_service_list = _read_data(Path(filepath))
l3_core_service_list = _read_data(Path(filepath))
for l3_core_service in l3_core_service_list:
for l3_core_service in l3_core_service_list:
partner = l3_core_service[0]["partner"]
partner = l3_core_service["partner"]
product_name = l3_core_service[0]["product_name"]
product_name = l3_core_service["product_name"]
typer.echo(f"Creating imported {product_name} for {partner}")
typer.echo(f"Creating imported {product_name} for {partner}")
try:
try:
if product_name == ProductName.IAS.value:
if product_name == ProductName.IAS.value:
initial_data = IASImportModel(**l3_core_service[0], **l3_core_service[1]).model_dump()
initial_data = IASImportModel(**l3_core_service).model_dump()
else:
else:
initial_data = L3CoreServiceImportModel(**l3_core_service[0], **l3_core_service[1]).model_dump()
initial_data = L3CoreServiceImportModel(**l3_core_service).model_dump()
start_process(L3_CREAT_IMPORTED_WF_MAP[product_name], [initial_data])
start_process(L3_CREAT_IMPORTED_WF_MAP[product_name], [initial_data])
edge_ports = [sbp["edge_port"] for sbp in l3_core_service[0]["service_binding_ports"]]
edge_ports = [sbp["edge_port"] for sbp in l3_core_service["service_binding_ports"]]
successfully_imported_data.append(edge_ports)
successfully_imported_data.append(edge_ports)
typer.echo(f"Successfully created imported {product_name} for {partner}")
typer.echo(f"Successfully created imported {product_name} for {partner}")
except ValidationError as e:
except ValidationError as e:
@@ -701,12 +702,13 @@ def import_l3_core_service(filepath: str = common_filepath_option) -> None:
@@ -701,12 +702,13 @@ def import_l3_core_service(filepath: str = common_filepath_option) -> None:
ProductType.IMPORTED_COPERNICUS,
ProductType.IMPORTED_COPERNICUS,
],
],
lifecycles=[SubscriptionLifecycle.ACTIVE],
lifecycles=[SubscriptionLifecycle.ACTIVE],
includes=["subscription_id"],
includes=["subscription_id", "product_id"],
)
)
for subscription_id in imported_products:
for subscription in imported_products:
typer.echo(f"Importing {subscription_id}")
product_name = get_product_by_id(subscription["product_id"]).name # type: ignore[union-attr]
start_process("import_l3_core_service", [subscription_id])
typer.echo(f"Importing {product_name} with {subscription["product_id"]}")
 
start_process(L3_IMPORT_WF_MAP[product_name], [{"subscription_id": subscription["subscription_id"]}])
if successfully_imported_data:
if successfully_imported_data:
typer.echo("Successfully created imported L3 Core Services:")
typer.echo("Successfully created imported L3 Core Services:")
Loading