From 59ce105a50e289d408af71aaee2063288da72053 Mon Sep 17 00:00:00 2001 From: grossmj Date: Tue, 21 Aug 2018 19:46:14 +0700 Subject: [PATCH] Fix exception with short names for Dynamips interfaces. Fixes #1386. --- gns3server/controller/ports/atm_port.py | 8 ++------ gns3server/controller/ports/ethernet_port.py | 4 ++-- gns3server/controller/ports/fastethernet_port.py | 4 ++-- gns3server/controller/ports/frame_relay_port.py | 4 ---- gns3server/controller/ports/gigabitethernet_port.py | 4 ++-- gns3server/controller/ports/port.py | 4 ++-- gns3server/controller/ports/port_factory.py | 4 ++-- gns3server/controller/ports/pos_port.py | 4 ++-- gns3server/controller/ports/serial_port.py | 4 ++-- 9 files changed, 16 insertions(+), 24 deletions(-) diff --git a/gns3server/controller/ports/atm_port.py b/gns3server/controller/ports/atm_port.py index 51da8d86..f63b9e4b 100644 --- a/gns3server/controller/ports/atm_port.py +++ b/gns3server/controller/ports/atm_port.py @@ -33,8 +33,8 @@ class ATMPort(SerialPort): """ return "ATM" - @property - def short_name_type(self): + @staticmethod + def short_name_type(): """ Returns the short name type for this port. @@ -42,10 +42,6 @@ class ATMPort(SerialPort): """ return "a" - @property - def short_name(self): - return "{}".format(self._port_number) - @property def data_link_types(self): """ diff --git a/gns3server/controller/ports/ethernet_port.py b/gns3server/controller/ports/ethernet_port.py index 6847998b..ae3f7e73 100644 --- a/gns3server/controller/ports/ethernet_port.py +++ b/gns3server/controller/ports/ethernet_port.py @@ -39,8 +39,8 @@ class EthernetPort(Port): return "Ethernet" - @property - def short_name_type(self): + @staticmethod + def short_name_type(): """ Returns the short name type for this port. diff --git a/gns3server/controller/ports/fastethernet_port.py b/gns3server/controller/ports/fastethernet_port.py index a8f98780..2a01e14a 100644 --- a/gns3server/controller/ports/fastethernet_port.py +++ b/gns3server/controller/ports/fastethernet_port.py @@ -34,8 +34,8 @@ class FastEthernetPort(Port): return "FastEthernet" - @property - def short_name_type(self): + @staticmethod + def short_name_type(): """ Returns the short name type for this port. diff --git a/gns3server/controller/ports/frame_relay_port.py b/gns3server/controller/ports/frame_relay_port.py index 356c13bd..87049917 100644 --- a/gns3server/controller/ports/frame_relay_port.py +++ b/gns3server/controller/ports/frame_relay_port.py @@ -34,10 +34,6 @@ class FrameRelayPort(SerialPort): return "FrameRelay" - @property - def short_name(self): - return "{}".format(self._port_number) - @property def data_link_types(self): """ diff --git a/gns3server/controller/ports/gigabitethernet_port.py b/gns3server/controller/ports/gigabitethernet_port.py index c96b820f..bcf7b143 100644 --- a/gns3server/controller/ports/gigabitethernet_port.py +++ b/gns3server/controller/ports/gigabitethernet_port.py @@ -34,8 +34,8 @@ class GigabitEthernetPort(Port): return "GigabitEthernet" - @property - def short_name_type(self): + @staticmethod + def short_name_type(): """ Returns the short name type for this port. diff --git a/gns3server/controller/ports/port.py b/gns3server/controller/ports/port.py index 52b58530..2b7cadef 100644 --- a/gns3server/controller/ports/port.py +++ b/gns3server/controller/ports/port.py @@ -67,9 +67,9 @@ class Port: if self._short_name: return self._short_name elif '/' in self._name: - return self._name.replace(self.long_name_type(), self.short_name_type) + return self._name.replace(self.long_name_type(), self.short_name_type()) elif self._name.startswith("{}{}".format(self.long_name_type(), self._interface_number)): - return self.short_name_type + "{}".format(self._interface_number) + return self.short_name_type() + "{}".format(self._interface_number) return self._name @short_name.setter diff --git a/gns3server/controller/ports/port_factory.py b/gns3server/controller/ports/port_factory.py index 88dfc569..35d66b41 100644 --- a/gns3server/controller/ports/port_factory.py +++ b/gns3server/controller/ports/port_factory.py @@ -191,7 +191,7 @@ class DynamipsPortFactory: for port_number in range(0, cls.ADAPTER_MATRIX[properties[name]]["nb_ports"]): name = "{}{}/{}".format(port_class.long_name_type(), adapter_number, port_number) port = port_class(name, adapter_number, adapter_number, port_number) - port.short_name = "{}{}/{}".format(port.short_name_type, adapter_number, port_number) + port.short_name = "{}{}/{}".format(port_class.short_name_type(), adapter_number, port_number) ports.append(port) adapter_number += 1 elif name.startswith("wic") and properties[name]: @@ -200,7 +200,7 @@ class DynamipsPortFactory: for port_number in range(0, cls.WIC_MATRIX[properties[name]]["nb_ports"]): name = "{}{}/{}".format(port_class.long_name_type(), 0, display_wic_port_number) port = port_class(name, 0, 0, wic_port_number) - port.short_name = "{}{}/{}".format(port.short_name_type, 0, display_wic_port_number) + port.short_name = "{}{}/{}".format(port_class.short_name_type(), 0, display_wic_port_number) ports.append(port) display_wic_port_number += 1 wic_port_number += 1 diff --git a/gns3server/controller/ports/pos_port.py b/gns3server/controller/ports/pos_port.py index 152e1f62..bd6a508e 100644 --- a/gns3server/controller/ports/pos_port.py +++ b/gns3server/controller/ports/pos_port.py @@ -33,8 +33,8 @@ class POSPort(SerialPort): """ return "POS" - @property - def short_name_type(self): + @staticmethod + def short_name_type(): """ Returns the short name type for this port. diff --git a/gns3server/controller/ports/serial_port.py b/gns3server/controller/ports/serial_port.py index 090f3a47..37fb4ebc 100644 --- a/gns3server/controller/ports/serial_port.py +++ b/gns3server/controller/ports/serial_port.py @@ -34,8 +34,8 @@ class SerialPort(Port): return "Serial" - @property - def short_name_type(self): + @staticmethod + def short_name_type(): """ Returns the short name type for this port.