1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-28 11:18:11 +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,15 +101,16 @@ class Cloud(BaseNode):
:param ports: ports info :param ports: ports info
""" """
if len(self._nios) > 0: if ports != self._ports_mapping:
raise NodeError("Can't modify a cloud already connected.") if len(self._nios) > 0:
raise NodeError("Can't modify a cloud already connected.")
port_number = 0 port_number = 0
for port in ports: for port in ports:
port["port_number"] = port_number port["port_number"] = port_number
port_number += 1 port_number += 1
self._ports_mapping = ports self._ports_mapping = ports
@asyncio.coroutine @asyncio.coroutine
def create(self): def create(self):

View File

@ -24,6 +24,7 @@ import asyncio
from .bridge import Bridge from .bridge import Bridge
from ..nios.nio_udp import NIOUDP from ..nios.nio_udp import NIOUDP
from ..dynamips_error import DynamipsError from ..dynamips_error import DynamipsError
from ...error import NodeError
import logging import logging
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -64,7 +65,7 @@ class EthernetHub(Bridge):
"status": "started"} "status": "started"}
@property @property
def ports(self): def ports_mapping(self):
""" """
Ports on this hub Ports on this hub
@ -73,15 +74,24 @@ class EthernetHub(Bridge):
return self._ports return self._ports
@ports.setter @ports_mapping.setter
def ports(self, ports): def ports_mapping(self, ports):
""" """
Set the ports on this hub Set the ports on this hub
:param ports: ports info :param ports: ports info
""" """
if ports != self._ports:
if len(self._mappings) > 0:
raise NodeError("Can't modify a hub 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 @asyncio.coroutine
def create(self): def create(self):

View File

@ -26,6 +26,7 @@ from gns3server.utils import parse_version
from .device import Device from .device import Device
from ..nios.nio_udp import NIOUDP from ..nios.nio_udp import NIOUDP
from ..dynamips_error import DynamipsError from ..dynamips_error import DynamipsError
from ...error import NodeError
import logging import logging
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -70,7 +71,7 @@ class EthernetSwitch(Device):
return ethernet_switch_info return ethernet_switch_info
@property @property
def ports(self): def ports_mapping(self):
""" """
Ports on this switch Ports on this switch
@ -79,15 +80,24 @@ class EthernetSwitch(Device):
return self._ports return self._ports
@ports.setter @ports_mapping.setter
def ports(self, ports): def ports_mapping(self, ports):
""" """
Set the ports on this switch Set the ports on this switch
:param ports: ports info :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 @asyncio.coroutine
def create(self): def create(self):