From b82eb6384ce7cf2938d9f7c30c193b6fd6fb7688 Mon Sep 17 00:00:00 2001 From: Neda Moeini <neda.moeini@geant.org> Date: Wed, 20 Dec 2023 12:33:56 +0100 Subject: [PATCH] Fixed data files and fixed validate country code issue with UK as country code. --- data/routers.json | 12 ++++++------ data/sites.json | 10 +++++----- data/trunks.json | 14 +++++++------- gso/cli/imports.py | 8 ++++---- gso/utils/helpers.py | 15 ++++++++------- 5 files changed, 30 insertions(+), 29 deletions(-) diff --git a/data/routers.json b/data/routers.json index 0fa3c504..a68e7fe8 100644 --- a/data/routers.json +++ b/data/routers.json @@ -4,7 +4,7 @@ "hostname": "rt1", "ts_port": 22111, "router_vendor": "juniper", - "router_role": "p", + "router_role": "pe", "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", @@ -15,7 +15,7 @@ "hostname": "rt1", "ts_port": 22111, "router_vendor": "juniper", - "router_role": "p", + "router_role": "pe", "router_lo_ipv4_address": "62.40.119.1", "router_lo_ipv6_address": "2001:798:1ab::1", "router_lo_iso_address": "49.51e5.0001.0620.4011.9001.00", @@ -26,7 +26,7 @@ "hostname": "rt1", "ts_port": 22111, "router_vendor": "juniper", - "router_role": "p", + "router_role": "pe", "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", @@ -37,18 +37,18 @@ "hostname": "rt1", "ts_port": 22111, "router_vendor": "juniper", - "router_role": "p", + "router_role": "pe", "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_role": "pe", "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", diff --git a/data/sites.json b/data/sites.json index 3dc257ec..1ce74276 100644 --- a/data/sites.json +++ b/data/sites.json @@ -9,7 +9,7 @@ "site_bgp_community_id": 13, "site_internal_id": 2, "site_tier": "1", - "site_ts_address": "62.40.111.195", + "site_ts_address": "62.40.111.195" }, { "site_name": "ATH", @@ -21,7 +21,7 @@ "site_bgp_community_id": 14, "site_internal_id": 4, "site_tier": "1", - "site_ts_address": "62.40.111.196", + "site_ts_address": "62.40.111.196" }, { "site_name": "BIL", @@ -33,7 +33,7 @@ "site_bgp_community_id": 47, "site_internal_id": 3, "site_tier": "1", - "site_ts_address": "62.40.111.197", + "site_ts_address": "62.40.111.197" }, { "site_name": "DUB", @@ -50,12 +50,12 @@ { "site_name": "LON", "site_city": "London", - "site_country": "England", + "site_country": "United Kingdom", "site_country_code": "UK", "site_latitude": 51.49821912962843, "site_longitude": -0.015228819041376851, "site_bgp_community_id": 28, - "site_internal_id": "1", + "site_internal_id": 1, "site_tier": "1", "site_ts_address": "62.40.111.199" } diff --git a/data/trunks.json b/data/trunks.json index eb2cb2c9..f1c2b872 100644 --- a/data/trunks.json +++ b/data/trunks.json @@ -40,7 +40,7 @@ "id": "LGS-00003", "config": { "common": { - "link_speed": "100g", + "link_speed": "100G", "minimum_links": 1, "isis_metric": 500, "type": "Leased" @@ -77,7 +77,7 @@ "id": "LGS-00004", "config": { "common": { - "link_speed": "400g", + "link_speed": "400G", "minimum_links": 1, "isis_metric": 100, "type": "Dark_fiber" @@ -114,7 +114,7 @@ "id": "LGS-00006", "config": { "common": { - "link_speed": "100g", + "link_speed": "100G", "minimum_links": 1, "isis_metric": 500, "type": "Dark_fiber" @@ -151,7 +151,7 @@ "id": "LGS-00007", "config": { "common": { - "link_speed": "100g", + "link_speed": "100G", "minimum_links": 1, "isis_metric": 500, "type": "Dark_fiber" @@ -188,7 +188,7 @@ "id": "LGS-00008", "config": { "common": { - "link_speed": "100g", + "link_speed": "100G", "minimum_links": 1, "isis_metric": 500, "type": "Dark_fiber" @@ -225,7 +225,7 @@ "id": "LGS-00012", "config": { "common": { - "link_speed": "100g", + "link_speed": "100G", "minimum_links": 1, "isis_metric": 500, "type": "Dark_fiber" @@ -262,7 +262,7 @@ "id": "LGS-00013", "config": { "common": { - "link_speed": "100g", + "link_speed": "100G", "minimum_links": 1, "isis_metric": 500, "type": "Dark_fiber" diff --git a/gso/cli/imports.py b/gso/cli/imports.py index 514143a2..9bdf8e79 100644 --- a/gso/cli/imports.py +++ b/gso/cli/imports.py @@ -173,7 +173,7 @@ def import_iptrunks(filepath: str = common_filepath_option) -> None: except ValidationError as e: typer.echo(f"Validation error: {e}") - if successfully_imported_data: - typer.echo("Successfully imported IP Trunks:") - for item in successfully_imported_data: - typer.echo(f"- {item}") + if successfully_imported_data: + typer.echo("Successfully imported IP Trunks:") + for item in successfully_imported_data: + typer.echo(f"- {item}") diff --git a/gso/utils/helpers.py b/gso/utils/helpers.py index c5316a05..1fde7d65 100644 --- a/gso/utils/helpers.py +++ b/gso/utils/helpers.py @@ -199,13 +199,14 @@ def validate_ipv4_or_ipv6(value: str) -> str: def validate_country_code(country_code: str) -> str: """Validate that a country code is valid.""" - try: - pycountry.countries.lookup(country_code) - except LookupError as e: - msg = "Invalid or non-existent country code, it must be in ISO 3166-1 alpha-2 format." - raise ValueError(msg) from e - else: - return country_code + # Check for the UK code before attempting to look it up since it's known as "GB" in the pycountry database. + if country_code != "UK": + try: + pycountry.countries.lookup(country_code) + except LookupError as e: + msg = "Invalid or non-existent country code, it must be in ISO 3166-1 alpha-2 format." + raise ValueError(msg) from e + return country_code def validate_site_name(site_name: str) -> str: -- GitLab