1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-24 17:28:08 +00:00

Bug fixes on Hub

This commit is contained in:
Julien Duponchelle 2016-09-29 16:01:18 +02:00
parent 74dd212def
commit f6b34e2434
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8
3 changed files with 36 additions and 15 deletions

View File

@ -101,6 +101,7 @@ class Cloud(BaseNode):
:param ports: ports info
"""
if ports != self._ports_mapping:
if len(self._nios) > 0:
raise NodeError("Can't modify a cloud already connected.")

View File

@ -24,6 +24,7 @@ import asyncio
from .bridge import Bridge
from ..nios.nio_udp import NIOUDP
from ..dynamips_error import DynamipsError
from ...error import NodeError
import logging
log = logging.getLogger(__name__)
@ -64,7 +65,7 @@ class EthernetHub(Bridge):
"status": "started"}
@property
def ports(self):
def ports_mapping(self):
"""
Ports on this hub
@ -73,13 +74,22 @@ class EthernetHub(Bridge):
return self._ports
@ports.setter
def ports(self, ports):
@ports_mapping.setter
def ports_mapping(self, ports):
"""
Set the ports on this hub
:param ports: ports info
"""
if ports != self._ports:
if len(self._mappings) > 0:
raise NodeError("Can't modify a hub already connected.")
port_number = 0
for port in ports:
port["name"] = "Ethernet{}".format(port_number)
port["port_number"] = port_number
port_number += 1
self._ports = ports

View File

@ -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,13 +80,22 @@ 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.")
port_number = 0
for port in ports:
port["name"] = "Ethernet{}".format(port_number)
port["port_number"] = port_number
port_number += 1
self._ports = ports