mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
Returns the ports' adapter types and mac addresses when available.
This commit is contained in:
1 parent
adc2f69d5d
commit
7622c10cc9
4 files changed
+38
-2
No files matched your search
@@ -27,6 +27,8 @@ class Port:
|
||||
self._port_number = port_number
|
||||
self._name = name
|
||||
self._short_name = short_name
|
||||
self._adapter_type = None
|
||||
self._mac_address = None
|
||||
self._link = None
|
||||
|
||||
@property
|
||||
@@ -48,6 +50,22 @@ class Port:
|
||||
def port_number(self):
|
||||
return self._port_number
|
||||
|
||||
@property
|
||||
def adapter_type(self):
|
||||
return self._adapter_type
|
||||
|
||||
@adapter_type.setter
|
||||
def adapter_type(self, val):
|
||||
self._adapter_type = val
|
||||
|
||||
@property
|
||||
def mac_address(self):
|
||||
return self._mac_address
|
||||
|
||||
@mac_address.setter
|
||||
def mac_address(self, val):
|
||||
self._mac_address = val
|
||||
|
||||
@property
|
||||
def data_link_types(self):
|
||||
"""
|
||||
@@ -81,5 +99,7 @@ class Port:
|
||||
"data_link_types": self.data_link_types,
|
||||
"port_number": self._port_number,
|
||||
"adapter_number": self._adapter_number,
|
||||
"adapter_type": self._adapter_type,
|
||||
"mac_address": self._mac_address,
|
||||
"link_type": self.link_type
|
||||
}
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
import aiohttp
|
||||
|
||||
from gns3server.utils import macaddress_to_int, int_to_macaddress
|
||||
from .atm_port import ATMPort
|
||||
from .frame_relay_port import FrameRelayPort
|
||||
from .gigabitethernet_port import GigabitEthernetPort
|
||||
@@ -92,6 +93,11 @@ class StandardPortFactory:
|
||||
else:
|
||||
segment_number += 1
|
||||
|
||||
port.adapter_type = custom_adapter_settings.get("adapter_type", properties.get("adapter_type", None))
|
||||
mac_address = custom_adapter_settings.get("mac_address")
|
||||
if not mac_address and "mac_address" in properties:
|
||||
mac_address = int_to_macaddress(macaddress_to_int(properties["mac_address"]) + adapter_number)
|
||||
port.mac_address = mac_address
|
||||
ports.append(port)
|
||||
|
||||
if len(ports):
|
||||
|
||||
Reference in new issue
Block a user