Network handler for UDP port allocation and server network interfaces.

This commit is contained in:
Jeremy committed 2015-01-24 15:32:58 -07:00
1 parent c002bbfb23
commit 50fea669b5
9 files changed
+134 -63

No files matched your search

+15
View File
@@ -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,
+3
View File
@@ -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,