diff --git a/gns3server/compute/builtin/nodes/cloud.py b/gns3server/compute/builtin/nodes/cloud.py index 628c624e..e332c8dc 100644 --- a/gns3server/compute/builtin/nodes/cloud.py +++ b/gns3server/compute/builtin/nodes/cloud.py @@ -101,15 +101,16 @@ class Cloud(BaseNode): :param ports: ports info """ - if len(self._nios) > 0: - raise NodeError("Can't modify a cloud already connected.") + if ports != self._ports_mapping: + if len(self._nios) > 0: + raise NodeError("Can't modify a cloud already connected.") - port_number = 0 - for port in ports: - port["port_number"] = port_number - port_number += 1 + port_number = 0 + for port in ports: + port["port_number"] = port_number + port_number += 1 - self._ports_mapping = ports + self._ports_mapping = ports @asyncio.coroutine def create(self): diff --git a/gns3server/compute/dynamips/nodes/ethernet_hub.py b/gns3server/compute/dynamips/nodes/ethernet_hub.py index df811e7e..5ec4d9cc 100644 --- a/gns3server/compute/dynamips/nodes/ethernet_hub.py +++ b/gns3server/compute/dynamips/nodes/ethernet_hub.py @@ -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,15 +74,24 @@ 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.") - 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): diff --git a/gns3server/compute/dynamips/nodes/ethernet_switch.py b/gns3server/compute/dynamips/nodes/ethernet_switch.py index 482e8bc3..4fd75011 100644 --- a/gns3server/compute/dynamips/nodes/ethernet_switch.py +++ b/gns3server/compute/dynamips/nodes/ethernet_switch.py @@ -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):