mirror of
https://github.com/GNS3/gns3-server
synced 2024-12-26 00:38:10 +00:00
Fix If I change the content of cloud the cloud no longer work
Fix #1540
This commit is contained in:
parent
4ea3690951
commit
5555662b2c
@ -58,7 +58,7 @@ class Cloud(BaseNode):
|
|||||||
"name": interface["name"]
|
"name": interface["name"]
|
||||||
})
|
})
|
||||||
else:
|
else:
|
||||||
self._ports_mapping = ports
|
self.ports_mapping = ports
|
||||||
|
|
||||||
def _interfaces(self):
|
def _interfaces(self):
|
||||||
return gns3server.utils.interfaces.interfaces()
|
return gns3server.utils.interfaces.interfaces()
|
||||||
@ -100,6 +100,11 @@ class Cloud(BaseNode):
|
|||||||
if len(self._nios) > 0:
|
if len(self._nios) > 0:
|
||||||
raise NodeError("Can't modify a cloud already connected.")
|
raise NodeError("Can't modify a cloud already connected.")
|
||||||
|
|
||||||
|
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
|
@asyncio.coroutine
|
||||||
|
@ -83,3 +83,42 @@ def test_json_without_ports(on_gns3vm, project):
|
|||||||
{'name': 'virbr0', 'special': True, 'type': 'ethernet'}
|
{'name': 'virbr0', 'special': True, 'type': 'ethernet'}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def test_update_port_mappings(on_gns3vm, project):
|
||||||
|
"""
|
||||||
|
We don't allow an empty interface in the middle of port list
|
||||||
|
"""
|
||||||
|
ports1 = [
|
||||||
|
{
|
||||||
|
"interface": "eth0",
|
||||||
|
"name": "eth0",
|
||||||
|
"port_number": 0,
|
||||||
|
"type": "ethernet"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"interface": "eth1",
|
||||||
|
"name": "eth1",
|
||||||
|
"port_number": 1,
|
||||||
|
"type": "ethernet"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
cloud = Cloud("cloud1", str(uuid.uuid4()), project, MagicMock(), ports=ports1)
|
||||||
|
assert cloud.ports_mapping == ports1
|
||||||
|
|
||||||
|
ports2 = [
|
||||||
|
{
|
||||||
|
"interface": "eth0",
|
||||||
|
"name": "eth0",
|
||||||
|
"port_number": 0,
|
||||||
|
"type": "ethernet"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"interface": "eth1",
|
||||||
|
"name": "eth1",
|
||||||
|
"port_number": 2,
|
||||||
|
"type": "ethernet"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
cloud = Cloud("cloud2", str(uuid.uuid4()), project, MagicMock(), ports=ports2)
|
||||||
|
assert cloud.ports_mapping == ports1
|
||||||
|
Loading…
Reference in New Issue
Block a user