Skip to content
Snippets Groups Projects
Commit 9835db7d authored by Neda Moeini's avatar Neda Moeini
Browse files

Fixed router import data and Update delete device from netbox.

parent 4579de64
No related branches found
No related tags found
1 merge request!121Feature/nat 354 import lab data to core db
Pipeline #84696 passed
......@@ -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
}
]
......@@ -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)
......
......@@ -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."""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment