mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
Network handler for UDP port allocation and server network interfaces.
This commit is contained in:
1 parent
c002bbfb23
commit
50fea669b5
9 files changed
+134
-63
No files matched your search
@@ -51,6 +51,21 @@ class PortManager:
|
||||
else:
|
||||
self._console_host = host
|
||||
|
||||
assert not hasattr(PortManager, "_instance")
|
||||
PortManager._instance = self
|
||||
|
||||
@classmethod
|
||||
def instance(cls):
|
||||
"""
|
||||
Singleton to return only one instance of PortManager.
|
||||
|
||||
:returns: instance of PortManager
|
||||
"""
|
||||
|
||||
if not hasattr(cls, "_instance") or cls._instance is None:
|
||||
cls._instance = cls()
|
||||
return cls._instance
|
||||
|
||||
@property
|
||||
def console_host(self):
|
||||
|
||||
|
||||
@@ -807,7 +807,10 @@ class VirtualBoxVM(BaseVM):
|
||||
yield from self._control_vm("nic{} null".format(adapter_id + 1))
|
||||
|
||||
nio = adapter.get_nio(0)
|
||||
if str(nio) == "NIO UDP":
|
||||
self.manager.port_manager.release_udp_port(nio.lport)
|
||||
adapter.remove_nio(0)
|
||||
|
||||
log.info("VirtualBox VM '{name}' [{uuid}]: {nio} removed from adapter {adapter_id}".format(name=self.name,
|
||||
uuid=self.uuid,
|
||||
nio=nio,
|
||||
|
||||
@@ -343,7 +343,10 @@ class VPCSVM(BaseVM):
|
||||
port_id=port_id))
|
||||
|
||||
nio = self._ethernet_adapter.get_nio(port_id)
|
||||
if str(nio) == "NIO UDP":
|
||||
self.manager.port_manager.release_udp_port(nio.lport)
|
||||
self._ethernet_adapter.remove_nio(port_id)
|
||||
|
||||
log.info("VPCS {name} [{uuid}]: {nio} removed from port {port_id}".format(name=self._name,
|
||||
uuid=self.uuid,
|
||||
nio=nio,
|
||||
|
||||
Reference in new issue
Block a user