mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-08-28 21:10:14 +03:00
New GET /v3/netmiko/device_types endpoint returns the device types supported by the netmiko library installed on the server, including the gns3-copilot custom drivers, so the web UI can populate the netmiko_device_type dropdown on templates and nodes. The list is read at runtime from netmiko's ssh_dispatcher.CLASS_MAPPER registry (the same table ConnectHandler dispatches on), filtered to drop the '_ssh' aliases and the 'autodetect' pseudo type, and cached for the process lifetime. Returns 501 when netmiko is not installed (ai-features extra).
39 lines
1.5 KiB
Python
39 lines
1.5 KiB
Python
#
|
|
# Copyright (C) 2020 GNS3 Technologies Inc.
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
from pydantic import BaseModel, Field
|
|
from typing import List
|
|
|
|
|
|
class NetmikoDeviceType(BaseModel):
|
|
"""
|
|
A Netmiko device type supported by the installed Netmiko library.
|
|
"""
|
|
|
|
name: str = Field(..., description="Device type name to store in the netmiko_device_type field")
|
|
telnet: bool = Field(False, description="Whether the device type connects over Telnet")
|
|
custom: bool = Field(False, description="Whether the device type is a GNS3-copilot custom driver (gns3_ prefix)")
|
|
|
|
|
|
class NetmikoDeviceTypeList(BaseModel):
|
|
"""
|
|
List of Netmiko device types supported by the installed Netmiko library.
|
|
"""
|
|
|
|
netmiko_version: str = Field(..., description="Version of the installed Netmiko library")
|
|
device_types: List[NetmikoDeviceType] = Field(..., description="Supported device types, sorted by name")
|