mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-28 11:18:11 +00:00
Some cleaning.
This commit is contained in:
parent
9e83329f14
commit
2ee49fed57
@ -28,6 +28,7 @@ class BaseVM:
|
|||||||
_allocated_console_ports = []
|
_allocated_console_ports = []
|
||||||
|
|
||||||
def __init__(self, name, identifier, port_manager):
|
def __init__(self, name, identifier, port_manager):
|
||||||
|
|
||||||
self._loop = asyncio.get_event_loop()
|
self._loop = asyncio.get_event_loop()
|
||||||
self._allocate_console()
|
self._allocate_console()
|
||||||
self._queue = asyncio.Queue()
|
self._queue = asyncio.Queue()
|
||||||
@ -42,6 +43,7 @@ class BaseVM:
|
|||||||
id=self._id))
|
id=self._id))
|
||||||
|
|
||||||
def _allocate_console(self):
|
def _allocate_console(self):
|
||||||
|
|
||||||
if not self._console:
|
if not self._console:
|
||||||
# allocate a console port
|
# allocate a console port
|
||||||
try:
|
try:
|
||||||
@ -53,7 +55,7 @@ class BaseVM:
|
|||||||
raise VMError(e)
|
raise VMError(e)
|
||||||
|
|
||||||
if self._console in self._allocated_console_ports:
|
if self._console in self._allocated_console_ports:
|
||||||
raise VMError("Console port {} is already used by another device".format(self._console))
|
raise VMError("Console port {} is already used by another VM".format(self._console))
|
||||||
self._allocated_console_ports.append(self._console)
|
self._allocated_console_ports.append(self._console)
|
||||||
|
|
||||||
|
|
||||||
@ -76,13 +78,12 @@ class BaseVM:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
if console in self._allocated_console_ports:
|
if console in self._allocated_console_ports:
|
||||||
raise VMError("Console port {} is already used by another VM device".format(console))
|
raise VMError("Console port {} is already used by another VM".format(console))
|
||||||
|
|
||||||
self._allocated_console_ports.remove(self._console)
|
self._allocated_console_ports.remove(self._console)
|
||||||
self._console = console
|
self._console = console
|
||||||
self._allocated_console_ports.append(self._console)
|
self._allocated_console_ports.append(self._console)
|
||||||
log.info("{type} {name} [id={id}]: console port set to {port}".format(
|
log.info("{type} {name} [id={id}]: console port set to {port}".format(type=self.__class__.__name__,
|
||||||
type=self.__class__.__name__,
|
|
||||||
name=self._name,
|
name=self._name,
|
||||||
id=self._id,
|
id=self._id,
|
||||||
port=console))
|
port=console))
|
||||||
|
Loading…
Reference in New Issue
Block a user