From 9835db7ddbd6616b10942c44372268db9defc6fd Mon Sep 17 00:00:00 2001
From: Neda Moeini <neda.moeini@geant.org>
Date: Tue, 28 Nov 2023 10:14:09 +0100
Subject: [PATCH] Fixed router import data and Update delete device from
 netbox.

---
 data/routers.json             | 6 ++++--
 gso/cli/imports.py            | 6 +++---
 gso/services/netbox_client.py | 4 +++-
 3 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/data/routers.json b/data/routers.json
index 9827efdb..8c648b57 100644
--- a/data/routers.json
+++ b/data/routers.json
@@ -8,7 +8,8 @@
     "router_role": "p",
     "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"
+    "router_lo_iso_address": "49.51e5.0001.0620.4011.9002.00",
+    "is_ias_connected": false
   },
   {
     "customer": "GÉANT",
@@ -19,6 +20,7 @@
     "router_role": "p",
     "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"
+    "router_lo_iso_address": "49.51e5.0001.0620.4011.9001.00",
+    "is_ias_connected": false
   }
 ]
diff --git a/gso/cli/imports.py b/gso/cli/imports.py
index 2adfac2a..07389ea3 100644
--- a/gso/cli/imports.py
+++ b/gso/cli/imports.py
@@ -76,14 +76,14 @@ def generic_import_data(
 
 
 @app.command()
-def import_sites(filepath: str) -> None:
+def import_sites(filepath: str = common_filepath_option) -> None:
     """Import sites into GSO."""
     # Use the import_data function to handle common import logic
     generic_import_data(filepath, SiteImportModel, import_site, "site_name")
 
 
 @app.command()
-def import_routers(filepath: str) -> None:
+def import_routers(filepath: str = common_filepath_option) -> None:
     """Import routers into GSO."""
     # Use the import_data function to handle common import logic
     generic_import_data(filepath, RouterImportModel, import_router, "hostname")
@@ -101,7 +101,7 @@ def get_router_subscription_id(node_name: str) -> str | None:
 
 
 @app.command()
-def import_iptrunks(filepath: str) -> None:
+def import_iptrunks(filepath: str = common_filepath_option) -> None:
     """Import IP trunks into GSO."""
     successfully_imported_data = []
     data = read_data(filepath)
diff --git a/gso/services/netbox_client.py b/gso/services/netbox_client.py
index 4bf9fd66..bae9485e 100644
--- a/gso/services/netbox_client.py
+++ b/gso/services/netbox_client.py
@@ -125,7 +125,9 @@ class NetboxClient:
     def delete_interface(self, device_name: str, iface_name: str) -> None:
         """Delete an interface from a device by name."""
         interface = self.get_interface_by_name_and_device(iface_name, device_name)
-        return interface.delete()
+        if interface:
+            return interface.delete()
+        return None
 
     def create_device_type(self, manufacturer: str, model: str, slug: str) -> DeviceTypes:
         """Create a new device type in Netbox."""
-- 
GitLab