Commit cdc3fef5 authored by Anael Beutot's avatar Anael Beutot
Browse files

Prevent virtio console from being opened if libvirtd version is 0.8

Libvirtd version 0.8.8 is capable of handling connections to virtio consoles but
the Python API is broken.
parent 51ebb0e7
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -36,7 +36,12 @@ class DRBDError(CCNodeError):
    pass


class ConsoleAlreadyOpened(CCNodeError):
class ConsoleError(CCNodeError):
    """Error relative to VM virtio console handling."""
    pass


class ConsoleAlreadyOpened(ConsoleError):
    """VM virtio console is already opened."""
    pass

+4 −1
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@ from cloudcontrol.node.hypervisor import lib as _libvirt
from cloudcontrol.node.hypervisor.lib import DOMAIN_STATES as STATE
from cloudcontrol.node.hypervisor.domains import vm_tags
from cloudcontrol.node.utils import SocketBuffer
from cloudcontrol.node.exc import ConsoleAlreadyOpened
from cloudcontrol.node.exc import ConsoleAlreadyOpened, ConsoleError


logger = logging.getLogger(__name__)
@@ -178,6 +178,9 @@ class VirtualMachine(object):
        if self.stream is not None:
            raise ConsoleAlreadyOpened('Console for this VM is already'
                                       ' opened')
        if self.hypervisor.handler.tag_db['libvirtver'].value.startswith('8'):
            raise ConsoleError(
                'Cannot open console, not compatible with this version of libvirt')
        logger.info('Opening console stream on VM %s', self.name)
        try:
            self.stream = self.hypervisor.vir_con.newStream(