@@ -501,34 +501,18 @@ def get_subnets(self, server: Server) -> list[dict[str, Any]]:
501501 client = server .get_client (self .dhcp_version )
502502 assert client is not None , "TODO"
503503
504- config = client .command ("config-get " )
504+ config = client .command (f"subnet { self . dhcp_version } -list " )
505505 assert config [0 ]["arguments" ] is not None
506- subnets = config [0 ]["arguments" ][f"Dhcp{ self .dhcp_version } " ][
507- f"subnet{ self .dhcp_version } "
508- ]
506+ subnets = config [0 ]["arguments" ]["subnets" ]
509507 subnet_list = [
510508 {
511509 "id" : s ["id" ],
512510 "subnet" : s ["subnet" ],
513- "dhcp_version" : self .dhcp_version ,
514- "server_pk" : server .pk ,
511+ "shared_network" : s ["shared-network-name" ],
515512 }
516513 for s in subnets
517- if "id" in s and "subnet" in s
518514 ]
519515
520- for sn in config [0 ]["arguments" ][f"Dhcp{ self .dhcp_version } " ]["shared-networks" ]:
521- subnet_list .extend (
522- {
523- "id" : s ["id" ],
524- "subnet" : s ["subnet" ],
525- "shared_network" : sn ["name" ],
526- "dhcp_version" : self .dhcp_version ,
527- "server_pk" : server .pk ,
528- }
529- for s in sn [f"subnet{ self .dhcp_version } " ]
530- )
531-
532516 return subnet_list
533517
534518 def get (self , request : HttpRequest , ** kwargs : Any ) -> HttpResponse :
@@ -542,6 +526,10 @@ def get(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
542526
543527 table_data = self .prep_table_data (request , child_objects , instance )
544528 table = self .get_table (table_data , request , False )
529+ table .server_url = reverse (
530+ f"plugins:netbox_kea:server_leases{ self .dhcp_version } " ,
531+ args = [instance .pk ],
532+ )
545533
546534 if "export" in request .GET :
547535 return export_table (
0 commit comments