|
|
|
@ -26,6 +26,7 @@ from gns3server.utils import parse_version
|
|
|
|
|
from .device import Device
|
|
|
|
|
from ..nios.nio_udp import NIOUDP
|
|
|
|
|
from ..dynamips_error import DynamipsError
|
|
|
|
|
from ...error import NodeError
|
|
|
|
|
|
|
|
|
|
import logging
|
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
@ -70,7 +71,7 @@ class EthernetSwitch(Device):
|
|
|
|
|
return ethernet_switch_info
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def ports(self):
|
|
|
|
|
def ports_mapping(self):
|
|
|
|
|
"""
|
|
|
|
|
Ports on this switch
|
|
|
|
|
|
|
|
|
@ -79,15 +80,24 @@ class EthernetSwitch(Device):
|
|
|
|
|
|
|
|
|
|
return self._ports
|
|
|
|
|
|
|
|
|
|
@ports.setter
|
|
|
|
|
def ports(self, ports):
|
|
|
|
|
@ports_mapping.setter
|
|
|
|
|
def ports_mapping(self, ports):
|
|
|
|
|
"""
|
|
|
|
|
Set the ports on this switch
|
|
|
|
|
|
|
|
|
|
:param ports: ports info
|
|
|
|
|
"""
|
|
|
|
|
if ports != self._ports:
|
|
|
|
|
if len(self._nios) > 0:
|
|
|
|
|
raise NodeError("Can't modify a switch already connected.")
|
|
|
|
|
|
|
|
|
|
self._ports = ports
|
|
|
|
|
port_number = 0
|
|
|
|
|
for port in ports:
|
|
|
|
|
port["name"] = "Ethernet{}".format(port_number)
|
|
|
|
|
port["port_number"] = port_number
|
|
|
|
|
port_number += 1
|
|
|
|
|
|
|
|
|
|
self._ports = ports
|
|
|
|
|
|
|
|
|
|
@asyncio.coroutine
|
|
|
|
|
def create(self):
|
|
|
|
|