diff --git a/data/routers.json b/data/routers.json index 8c648b5763c91c577065b07a6b3d880376bb0279..0fa3c5043d7f0861f2585b1d634aa62a4e1ee9fd 100644 --- a/data/routers.json +++ b/data/routers.json @@ -1,6 +1,5 @@ [ { - "customer": "GÉANT", "router_site": "AMS", "hostname": "rt1", "ts_port": 22111, @@ -9,12 +8,11 @@ "router_lo_ipv4_address": "62.40.119.2", "router_lo_ipv6_address": "2001:798:1ab::2", "router_lo_iso_address": "49.51e5.0001.0620.4011.9002.00", - "is_ias_connected": false + "is_ias_connected": true }, { - "customer": "GÉANT", - "router_site": "AMS2", - "hostname": "rt2", + "router_site": "ATH", + "hostname": "rt1", "ts_port": 22111, "router_vendor": "juniper", "router_role": "p", @@ -22,5 +20,38 @@ "router_lo_ipv6_address": "2001:798:1ab::1", "router_lo_iso_address": "49.51e5.0001.0620.4011.9001.00", "is_ias_connected": false + }, + { + "router_site": "BIL", + "hostname": "rt1", + "ts_port": 22111, + "router_vendor": "juniper", + "router_role": "p", + "router_lo_ipv4_address": "62.40.119.3", + "router_lo_ipv6_address": "2001:798:1ab::3", + "router_lo_iso_address": "49.51e5.0001.0620.4011.9003.00", + "is_ias_connected": false + }, + { + "router_site": "DUB", + "hostname": "rt1", + "ts_port": 22111, + "router_vendor": "juniper", + "router_role": "p", + "router_lo_ipv4_address": "62.40.119.4", + "router_lo_ipv6_address": "2001:798:1ab::4", + "router_lo_iso_address": "49.51e5.0001.0620.4011.9004.00", + "is_ias_connected": false + }, + { + "router_site": "LON", + "hostname": "rt1", + "ts_port": 22111, + "router_vendor": "juniper", + "router_role": "p", + "router_lo_ipv4_address": "62.40.119.5", + "router_lo_ipv6_address": "2001:798:1ab::5", + "router_lo_iso_address": "49.51e5.0001.0620.4011.9005.00", + "is_ias_connected": true } ] diff --git a/data/sites.json b/data/sites.json index 87bfd5c7c7c16999ee97eddea845801dd2e9f806..3dc257eccf5f2290b7c4f2caf16a0bf8e0555842 100644 --- a/data/sites.json +++ b/data/sites.json @@ -1,15 +1,62 @@ [ { - "site_name": "AMS2", + "site_name": "AMS", "site_city": "Amsterdam", "site_country": "The Netherlands", "site_country_code": "NL", - "site_latitude": 0, - "site_longitude": 0, - "site_bgp_community_id": 4, + "site_latitude": 52.35640299542275, + "site_longitude": 4.952931412236851, + "site_bgp_community_id": 13, + "site_internal_id": 2, + "site_tier": "1", + "site_ts_address": "62.40.111.195", + }, + { + "site_name": "ATH", + "site_city": "Athens", + "site_country": "Greece", + "site_country_code": "GR", + "site_latitude": 37.973573902105514, + "site_longitude": 23.74551842723506, + "site_bgp_community_id": 14, "site_internal_id": 4, "site_tier": "1", - "site_ts_address": "0.1.1.1", - "customer": "GÉANT" + "site_ts_address": "62.40.111.196", + }, + { + "site_name": "BIL", + "site_city": "Bilbao", + "site_country": "Spain", + "site_country_code": "ES", + "site_latitude": 43.32311388825037, + "site_longitude": -2.996764830318336, + "site_bgp_community_id": 47, + "site_internal_id": 3, + "site_tier": "1", + "site_ts_address": "62.40.111.197", + }, + { + "site_name": "DUB", + "site_city": "Dublin", + "site_country": "Ireland", + "site_country_code": "IE", + "site_latitude": 53.29025463849949, + "site_longitude": -6.4207320574310165, + "site_bgp_community_id": 20, + "site_internal_id": 5, + "site_tier": "1", + "site_ts_address": "62.40.111.198" + }, + { + "site_name": "LON", + "site_city": "London", + "site_country": "England", + "site_country_code": "UK", + "site_latitude": 51.49821912962843, + "site_longitude": -0.015228819041376851, + "site_bgp_community_id": 28, + "site_internal_id": "1", + "site_tier": "1", + "site_ts_address": "62.40.111.199" } ] \ No newline at end of file diff --git a/data/trunks.json b/data/trunks.json index 38fd0d9e8525a1beeb80ab90e8954c83249f377d..eb2cb2c9f75d784396090c40f40b44ca2bb126b2 100644 --- a/data/trunks.json +++ b/data/trunks.json @@ -1,30 +1,300 @@ [ { - "customer": "GÉANT", - "geant_s_sid": "12", - "iptrunk_type": "Dark_fiber", - "iptrunk_description": "Description", - "iptrunk_speed": "100G", - "iptrunk_minimum_links": 1, - "side_a_node_id": "", - "side_a_ae_iface": "string", - "side_a_ae_geant_a_sid": "string", - "side_a_ae_members": [ - { - "interface_name": "string", - "interface_description": "string" - } - ], - "side_b_node_id": "string", - "side_b_ae_iface": "string", - "side_b_ae_geant_a_sid": "string", - "side_b_ae_members": [ - { - "interface_name": "string", - "interface_description": "string" - } - ], - "iptrunk_ipv4_network": "string", - "iptrunk_ipv6_network": "string" + "id": "LGS-00001", + "config": { + "common": { + "link_speed": "100G", + "minimum_links": 1, + "isis_metric": 500, + "type": "Leased" + }, + "nodeA": { + "name": "rt1.ath.gr.lab.office.geant.net", + "ae_name": "ae0", + "port_sid": "LGA-00001", + "members": [ + { + "interface_name": "et-0/0/2", + "interface_description": "et-0/0/2" + } + ], + "ipv4_address": "62.40.98.0/31", + "ipv6_address": "2001:798:cc::1/126" + }, + "nodeB": { + "name": "rt1.ams.nl.lab.office.geant.net", + "ae_name": "ae0", + "port_sid": "LGA-00002", + "members": [ + { + "interface_name": "et-9/0/2", + "interface_description": "et-9/0/2" + } + ], + "ipv4_address": "62.40.98.1/31", + "ipv6_address": "2001:798:cc::2/126" + } + } + }, + { + "id": "LGS-00003", + "config": { + "common": { + "link_speed": "100g", + "minimum_links": 1, + "isis_metric": 500, + "type": "Leased" + }, + "nodeA": { + "name": "rt1.ath.gr.lab.office.geant.net", + "ae_name": "ae1", + "port_sid": "LGA-00005", + "members": [ + { + "interface_name": "et-0/0/1", + "interface_description": "et-0/0/1" + } + ], + "ipv4_address": "62.40.98.2/31", + "ipv6_address": "2001:798:cc::9/126" + }, + "nodeB": { + "name": "rt1.lon.uk.lab.office.geant.net", + "ae_name": "ae1", + "port_sid": "LGA-00006", + "members": [ + { + "interface_name": "et-2/0/0", + "interface_description": "et-2/0/0" + } + ], + "ipv4_address": "62.40.98.3/31", + "ipv6_address": "2001:798:cc::a/126" + } + } + }, + { + "id": "LGS-00004", + "config": { + "common": { + "link_speed": "400g", + "minimum_links": 1, + "isis_metric": 100, + "type": "Dark_fiber" + }, + "nodeA": { + "name": "rt1.lon.uk.lab.office.geant.net", + "ae_name": "ae6", + "port_sid": "LGA-00004", + "members": [ + { + "interface_name": "et-1/0/4", + "interface_description": "et-1/0/4" + } + ], + "ipv4_address": "62.40.98.55/31", + "ipv6_address": "2001:798:cc::6e/126" + }, + "nodeB": { + "name": "rt1.ams.nl.lab.office.geant.net", + "ae_name": "ae6", + "port_sid": "LGA-00004", + "members": [ + { + "interface_name": "et-3/0/4", + "interface_description": "et-3/0/4" + } + ], + "ipv4_address": "62.40.98.54/31", + "ipv6_address": "2001:798:cc::6d/126" + } + } + }, + { + "id": "LGS-00006", + "config": { + "common": { + "link_speed": "100g", + "minimum_links": 1, + "isis_metric": 500, + "type": "Dark_fiber" + }, + "nodeA": { + "name": "rt1.ams.nl.lab.office.geant.net", + "ae_name": "ae1", + "port_sid": "LGA-00011", + "members": [ + { + "interface_name": "et-9/0/5", + "interface_description": "et-9/0/5" + } + ], + "ipv4_address": "62.40.98.4/31", + "ipv6_address": "2001:798:cc::d/126" + }, + "nodeB": { + "name": "rt1.bil.es.lab.office.geant.net", + "ae_name": "ae1", + "port_sid": "LGA-00012", + "members": [ + { + "interface_name": "et-0/0/0", + "interface_description": "et-0/0/0" + } + ], + "ipv4_address": "62.40.98.5/31", + "ipv6_address": "2001:798:cc::e/126" + } + } + }, + { + "id": "LGS-00007", + "config": { + "common": { + "link_speed": "100g", + "minimum_links": 1, + "isis_metric": 500, + "type": "Dark_fiber" + }, + "nodeA": { + "name": "rt1.lon.uk.lab.office.geant.net", + "ae_name": "ae0", + "port_sid": "LGA-00013", + "members": [ + { + "interface_name": "et-5/2/0", + "interface_description": "et-5/2/0" + } + ], + "ipv4_address": "62.40.98.17/31", + "ipv6_address": "2001:798:cc::22/126" + }, + "nodeB": { + "name": "rt1.dub.ie.lab.office.geant.net", + "ae_name": "ae0", + "port_sid": "LGA-00014", + "members": [ + { + "interface_name": "et-0/0/1", + "interface_description": "et-0/0/1" + } + ], + "ipv4_address": "62.40.98.16/31", + "ipv6_address": "2001:798:cc::21/126" + } + } + }, + { + "id": "LGS-00008", + "config": { + "common": { + "link_speed": "100g", + "minimum_links": 1, + "isis_metric": 500, + "type": "Dark_fiber" + }, + "nodeA": { + "name": "rt1.bil.es.lab.office.geant.net", + "ae_name": "ae2", + "port_sid": "LGA-00016", + "members": [ + { + "interface_name": "et-0/0/1", + "interface_description": "et-0/0/1" + } + ], + "ipv4_address": "62.40.98.8/31", + "ipv6_address": "2001:798:cc::15/126" + }, + "nodeB": { + "name": "rt1.dub.ie.lab.office.geant.net", + "ae_name": "ae2", + "port_sid": "LGA-00015", + "members": [ + { + "interface_name": "et-0/0/0", + "interface_description": "et-0/0/0" + } + ], + "ipv4_address": "62.40.98.9/31", + "ipv6_address": "2001:798:cc::16/126" + } + } + }, + { + "id": "LGS-00012", + "config": { + "common": { + "link_speed": "100g", + "minimum_links": 1, + "isis_metric": 500, + "type": "Dark_fiber" + }, + "nodeA": { + "name": "rt1.ams.nl.lab.office.geant.net", + "ae_name": "ae5", + "port_sid": "LGA-00023", + "members": [ + { + "interface_name": "et-1/0/2", + "interface_description": "et-1/0/2" + } + ], + "ipv4_address": "62.40.98.52/31", + "ipv6_address": "2001:798:cc::69/126" + }, + "nodeB": { + "name": "rt2.lon.uk.lab.office.geant.net", + "ae_name": "ae1", + "port_sid": "LGA-00024", + "members": [ + { + "interface_name": "et-0/0/0", + "interface_description": "et-0/0/0" + } + ], + "ipv4_address": "62.40.98.53/31", + "ipv6_address": "2001:798:cc::6a/126" + } + } + }, + { + "id": "LGS-00013", + "config": { + "common": { + "link_speed": "100g", + "minimum_links": 1, + "isis_metric": 500, + "type": "Dark_fiber" + }, + "nodeA": { + "name": "rt1.lon.uk.lab.office.geant.net", + "ae_name": "ae3", + "port_sid": "LGA-00025", + "members": [ + { + "interface_name": "et-0/0/2", + "interface_description": "et-0/0/2" + } + ], + "ipv4_address": "62.40.98.36/31", + "ipv6_address": "2001:798:cc::65/126" + }, + "nodeB": { + "name": "rt2.lon.uk.lab.office.geant.net", + "ae_name": "ae2", + "port_sid": "LGA-00026", + "members": [ + { + "interface_name": "et-0/0/1", + "interface_description": "et-0/0/1" + } + ], + "ipv4_address": "62.40.98.37/31", + "ipv6_address": "2001:798:cc::66/126" + } + } } ] + + diff --git a/gso/api/v1/imports.py b/gso/api/v1/imports.py index 5ae848a47ef3b874c94ad1cd0d74aa665a497a47..03eb49596e6da0aeaa4f87ec0ba72e513c6d07a8 100644 --- a/gso/api/v1/imports.py +++ b/gso/api/v1/imports.py @@ -66,6 +66,7 @@ class IptrunkImportModel(BaseModel): iptrunk_description: str iptrunk_speed: PhyPortCapacity iptrunk_minimum_links: int + iptrunk_isis_metric: int side_a_node_id: str side_a_ae_iface: str side_a_ae_geant_a_sid: str diff --git a/gso/cli/imports.py b/gso/cli/imports.py index 07389ea34372a39eba09f818053e1aa47a9843ae..514143a2150d7244b4e3a4dcaf09332150dac930 100644 --- a/gso/cli/imports.py +++ b/gso/cli/imports.py @@ -149,6 +149,7 @@ def import_iptrunks(filepath: str = common_filepath_option) -> None: iptrunk_description=trunk["config"]["common"].get("description", ""), iptrunk_speed=trunk["config"]["common"]["link_speed"], iptrunk_minimum_links=trunk["config"]["common"]["minimum_links"], + iptrunk_isis_metric=trunk["config"]["common"]["isis_metric"], side_a_node_id=get_router_subscription_id( trunk["config"]["nodeA"]["name"], ) diff --git a/gso/workflows/tasks/import_iptrunk.py b/gso/workflows/tasks/import_iptrunk.py index a2c52f5c11a2949bad0562620d1bbe32bf7b4d0d..f22852d1af60a74225ee689ec590ad3dea666d2c 100644 --- a/gso/workflows/tasks/import_iptrunk.py +++ b/gso/workflows/tasks/import_iptrunk.py @@ -1,6 +1,7 @@ """A creation workflow for adding an existing IP trunk to the service database.""" import ipaddress +from uuid import uuid4 from orchestrator import workflow from orchestrator.forms import FormPage @@ -11,12 +12,12 @@ from orchestrator.workflow import StepList, done, init, step from orchestrator.workflows.steps import resync, set_status, store_process_subscription from gso.products import ProductType -from gso.products.product_blocks.iptrunk import IptrunkType, PhyPortCapacity +from gso.products.product_blocks.iptrunk import IptrunkInterfaceBlockInactive, IptrunkType, PhyPortCapacity from gso.products.product_types.iptrunk import IptrunkInactive, IptrunkProvisioning +from gso.products.product_types.router import Router from gso.services import subscriptions from gso.services.crm import get_customer_by_name from gso.utils.helpers import LAGMember -from gso.workflows.iptrunk.create_iptrunk import initialize_subscription def _generate_routers() -> dict[str, str]: @@ -43,6 +44,7 @@ def initial_input_form_generator() -> FormGenerator: iptrunk_type: IptrunkType iptrunk_speed: PhyPortCapacity iptrunk_minimum_links: int + iptrunk_isis_metric: int side_a_node_id: router_enum # type: ignore[valid-type] side_a_ae_iface: str @@ -75,6 +77,54 @@ def create_subscription(customer: str) -> State: } +@step("Initialize subscription") +def initialize_subscription( + subscription: IptrunkInactive, + geant_s_sid: str, + iptrunk_type: IptrunkType, + iptrunk_description: str, + iptrunk_speed: PhyPortCapacity, + iptrunk_minimum_links: int, + iptrunk_isis_metric: int, + side_a_node_id: str, + side_a_ae_iface: str, + side_a_ae_geant_a_sid: str, + side_a_ae_members: list[dict], + side_b_node_id: str, + side_b_ae_iface: str, + side_b_ae_geant_a_sid: str, + side_b_ae_members: list[dict], +) -> State: + """Take all input from the user, and store it in the database.""" + subscription.iptrunk.geant_s_sid = geant_s_sid + subscription.iptrunk.iptrunk_description = iptrunk_description + subscription.iptrunk.iptrunk_type = iptrunk_type + subscription.iptrunk.iptrunk_speed = iptrunk_speed + subscription.iptrunk.iptrunk_isis_metric = iptrunk_isis_metric + subscription.iptrunk.iptrunk_minimum_links = iptrunk_minimum_links + + subscription.iptrunk.iptrunk_sides[0].iptrunk_side_node = Router.from_subscription(side_a_node_id).router + subscription.iptrunk.iptrunk_sides[0].iptrunk_side_ae_iface = side_a_ae_iface + subscription.iptrunk.iptrunk_sides[0].iptrunk_side_ae_geant_a_sid = side_a_ae_geant_a_sid + for member in side_a_ae_members: + subscription.iptrunk.iptrunk_sides[0].iptrunk_side_ae_members.append( + IptrunkInterfaceBlockInactive.new(subscription_id=uuid4(), **member), + ) + + subscription.iptrunk.iptrunk_sides[1].iptrunk_side_node = Router.from_subscription(side_b_node_id).router + subscription.iptrunk.iptrunk_sides[1].iptrunk_side_ae_iface = side_b_ae_iface + subscription.iptrunk.iptrunk_sides[1].iptrunk_side_ae_geant_a_sid = side_b_ae_geant_a_sid + for member in side_b_ae_members: + subscription.iptrunk.iptrunk_sides[1].iptrunk_side_ae_members.append( + IptrunkInterfaceBlockInactive.new(subscription_id=uuid4(), **member), + ) + + subscription.description = f"IP trunk, geant_s_sid:{geant_s_sid}" + subscription = IptrunkProvisioning.from_other_lifecycle(subscription, SubscriptionLifecycle.PROVISIONING) + + return {"subscription": subscription} + + @step("Update IPAM Stub for Subscription") def update_ipam_stub_for_subscription( subscription: IptrunkProvisioning, diff --git a/test/imports/test_imports.py b/test/imports/test_imports.py index 7fda2def5e24115396be754b3255533672873de8..dfe21d06faf6d0f7ac8543c39b7f06836ce3c67f 100644 --- a/test/imports/test_imports.py +++ b/test/imports/test_imports.py @@ -26,6 +26,7 @@ def iptrunk_data(nokia_router_subscription_factory, faker): "iptrunk_description": faker.sentence(), "iptrunk_speed": PhyPortCapacity.HUNDRED_GIGABIT_PER_SECOND, "iptrunk_minimum_links": 5, + "iptrunk_isis_metric": 500, "side_a_node_id": router_side_a, "side_a_ae_iface": faker.network_interface(), "side_a_ae_geant_a_sid": faker.geant_sid(),