mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-28 11:18:11 +00:00
Return QEMU monitor responses as Match Objects (more flexibility for future uses)
This commit is contained in:
parent
c775b05d33
commit
ccb4ccd612
@ -28,6 +28,7 @@ import shlex
|
|||||||
import ntpath
|
import ntpath
|
||||||
import telnetlib
|
import telnetlib
|
||||||
import time
|
import time
|
||||||
|
import re
|
||||||
|
|
||||||
from gns3server.config import Config
|
from gns3server.config import Config
|
||||||
from gns3dms.cloud.rackspace_ctrl import get_provider
|
from gns3dms.cloud.rackspace_ctrl import get_provider
|
||||||
@ -904,7 +905,7 @@ class QemuVM(object):
|
|||||||
:param command: QEMU monitor command (e.g. info status, stop etc.)
|
:param command: QEMU monitor command (e.g. info status, stop etc.)
|
||||||
:param timeout: how long to wait for QEMU monitor
|
:param timeout: how long to wait for QEMU monitor
|
||||||
|
|
||||||
:returns: result of the command (string)
|
:returns: result of the command (Match object or None)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
result = None
|
result = None
|
||||||
@ -920,9 +921,9 @@ class QemuVM(object):
|
|||||||
return result
|
return result
|
||||||
if expected:
|
if expected:
|
||||||
try:
|
try:
|
||||||
ind, obj, dat = tn.expect(list=expected, timeout=timeout)
|
ind, match, dat = tn.expect(list=expected, timeout=timeout)
|
||||||
if ind >= 0:
|
if match:
|
||||||
result = expected[ind].decode('ascii')
|
result = match
|
||||||
except EOFError as e:
|
except EOFError as e:
|
||||||
log.warn("Could not read from QEMU monitor: {}".format(e))
|
log.warn("Could not read from QEMU monitor: {}".format(e))
|
||||||
tn.close()
|
tn.close()
|
||||||
@ -935,7 +936,11 @@ class QemuVM(object):
|
|||||||
:returns: status (string)
|
:returns: status (string)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
result = self._control_vm("info status", [b"running", b"paused"])
|
result = None
|
||||||
|
|
||||||
|
match = self._control_vm("info status", [b"running", b"paused"])
|
||||||
|
if match:
|
||||||
|
result = match.group(0).decode('ascii')
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def suspend(self):
|
def suspend(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user