Example #1
0
def _set_graphics(devices, target_vm_conf):
    # TODO: Support VMs with multiple <graphics> sections.
    graphics = devices.find('graphics')
    if graphics is None:
        return

    graphics_listen = graphics.find('listen')

    target_display_network, target_display_ip = _vmconf_display(target_vm_conf)

    if net_api.ovs_bridge(target_display_network):
        graphics_listen.attrib.pop('network', None)
        graphics_listen.set('type', 'address')
        graphics_listen.set('address', target_display_ip)
    else:
        libvirt_network = net_api.netname_o2l(target_display_network)
        graphics_listen.attrib.pop('address', None)
        graphics_listen.set('type', 'network')
        graphics_listen.set('network', libvirt_network)
Example #2
0
def _set_graphics(devices, target_vm_conf):
    # TODO: Support VMs with multiple <graphics> sections.
    graphics = devices.find('graphics')
    if graphics is None:
        return

    graphics_listen = graphics.find('listen')

    target_display_network, target_display_ip = _vmconf_display(target_vm_conf)

    if net_api.ovs_bridge(target_display_network):
        graphics_listen.attrib.pop('network', None)
        graphics_listen.set('type', 'address')
        graphics_listen.set('address', target_display_ip)
    else:
        libvirt_network = net_api.netname_o2l(target_display_network)
        graphics_listen.attrib.pop('address', None)
        graphics_listen.set('type', 'network')
        graphics_listen.set('network', libvirt_network)
Example #3
0
    def getXML(self):
        """
        Create domxml for a graphics framebuffer.

        <graphics type='spice' port='5900' tlsPort='5901' autoport='yes'
                  listen='0' keymap='en-us'
                  passwdValidTo='1970-01-01T00:00:01'>
          <listen type='address' address='0'/>
          <clipboard copypaste='no'/>
        </graphics>
        OR
        <graphics type='vnc' port='5900' autoport='yes' listen='0'
                  keymap='en-us' passwdValidTo='1970-01-01T00:00:01'>
          <listen type='address' address='0'/>
        </graphics>

        """

        graphicsAttrs = {
            'type': self.device,
            'port': self.port,
            'autoport': 'yes',
        }
        if config.getboolean('vars', 'ssl'):
            graphicsAttrs['defaultMode'] = 'secure'
        # the default, 'any', has automatic fallback to
        # insecure mode, so works with ssl off.

        if self.device == 'spice':
            graphicsAttrs['tlsPort'] = self.tlsPort

        self._setPasswd(graphicsAttrs)

        if 'keyMap' in self.specParams:
            graphicsAttrs['keymap'] = self.specParams['keyMap']

        graphics = vmxml.Element('graphics', **graphicsAttrs)

        if not utils.tobool(self.specParams.get('copyPasteEnable', True)):
            clipboard = vmxml.Element('clipboard', copypaste='no')
            graphics.appendChild(clipboard)

        if not utils.tobool(self.specParams.get('fileTransferEnable', True)):
            filetransfer = vmxml.Element('filetransfer', enable='no')
            graphics.appendChild(filetransfer)

        # This list could be dropped in 4.1. We should keep only
        # the default mode, which is both simpler and safer.
        if (self.device == 'spice' and
           'spiceSecureChannels' in self.specParams):
            for chan in self._getSpiceChannels():
                graphics.appendChildWithArgs('channel', name=chan,
                                             mode='secure')

        if self.specParams.get('displayNetwork'):
            graphics.appendChildWithArgs(
                'listen', type='network',
                network=net_api.netname_o2l(
                    self.specParams.get('displayNetwork')))
        else:
            graphics.setAttrs(listen='0')

        return graphics
Example #4
0
    def getXML(self):
        """
        Create domxml for a graphics framebuffer.

        <graphics type='spice' port='5900' tlsPort='5901' autoport='yes'
                  listen='0' keymap='en-us'
                  passwdValidTo='1970-01-01T00:00:01'>
          <listen type='address' address='0'/>
          <clipboard copypaste='no'/>
        </graphics>
        OR
        <graphics type='vnc' port='5900' autoport='yes' listen='0'
                  keymap='en-us' passwdValidTo='1970-01-01T00:00:01'>
          <listen type='address' address='0'/>
        </graphics>

        """

        graphicsAttrs = {"type": self.device, "port": self.port, "autoport": "yes"}
        if config.getboolean("vars", "ssl"):
            graphicsAttrs["defaultMode"] = "secure"
        # the default, 'any', has automatic fallback to
        # insecure mode, so works with ssl off.

        if self.device == "spice":
            graphicsAttrs["tlsPort"] = self.tlsPort

        self._setPasswd(graphicsAttrs)

        if "keyMap" in self.specParams:
            graphicsAttrs["keymap"] = self.specParams["keyMap"]

        graphics = vmxml.Element("graphics", **graphicsAttrs)

        if not utils.tobool(self.specParams.get("copyPasteEnable", True)):
            clipboard = vmxml.Element("clipboard", copypaste="no")
            graphics.appendChild(clipboard)

        if not utils.tobool(self.specParams.get("fileTransferEnable", True)):
            filetransfer = vmxml.Element("filetransfer", enable="no")
            graphics.appendChild(filetransfer)

        # This list could be dropped in 4.1. We should keep only
        # the default mode, which is both simpler and safer.
        if self.device == "spice" and "spiceSecureChannels" in self.specParams:
            for chan in self._getSpiceChannels():
                graphics.appendChildWithArgs("channel", name=chan, mode="secure")

        # For the listen type IP to be used, the display network must be OVS.
        # We assume that the cluster in which the host operates is OVS enabled
        # and all other hosts in the cluster have the migration hook installed.
        # The migration hook is responsible to convert ip to net and vice versa
        display_network = self.specParams.get("displayNetwork")
        display_ip = self.specParams.get("displayIp", "0")
        if display_network and display_ip != "0" and supervdsm.getProxy().ovs_bridge(display_network):
            graphics.appendChildWithArgs("listen", type="address", address=display_ip)
        elif display_network:
            graphics.appendChildWithArgs(
                "listen", type="network", network=net_api.netname_o2l(self.specParams.get("displayNetwork"))
            )
        else:
            graphics.setAttrs(listen="0")

        return graphics
Example #5
0
    def getXML(self):
        """
        Create domxml for a graphics framebuffer.

        <graphics type='spice' port='5900' tlsPort='5901' autoport='yes'
                  listen='0' keymap='en-us'
                  passwdValidTo='1970-01-01T00:00:01'>
          <listen type='address' address='0'/>
          <clipboard copypaste='no'/>
        </graphics>
        OR
        <graphics type='vnc' port='5900' autoport='yes' listen='0'
                  keymap='en-us' passwdValidTo='1970-01-01T00:00:01'>
          <listen type='address' address='0'/>
        </graphics>

        """

        graphicsAttrs = {
            'type': self.device,
            'port': self.port,
            'autoport': 'yes',
        }
        if config.getboolean('vars', 'ssl'):
            graphicsAttrs['defaultMode'] = 'secure'
        # the default, 'any', has automatic fallback to
        # insecure mode, so works with ssl off.

        if self.device == 'spice':
            graphicsAttrs['tlsPort'] = self.tlsPort

        self._setPasswd(graphicsAttrs)

        if 'keyMap' in self.specParams:
            graphicsAttrs['keymap'] = self.specParams['keyMap']

        graphics = vmxml.Element('graphics', **graphicsAttrs)

        if not utils.tobool(self.specParams.get('copyPasteEnable', True)):
            clipboard = vmxml.Element('clipboard', copypaste='no')
            graphics.appendChild(clipboard)

        if not utils.tobool(self.specParams.get('fileTransferEnable', True)):
            filetransfer = vmxml.Element('filetransfer', enable='no')
            graphics.appendChild(filetransfer)

        # This list could be dropped in 4.1. We should keep only
        # the default mode, which is both simpler and safer.
        if (self.device == 'spice' and
           'spiceSecureChannels' in self.specParams):
            for chan in self._getSpiceChannels():
                graphics.appendChildWithArgs('channel', name=chan,
                                             mode='secure')

        # For the listen type IP to be used, the display network must be OVS.
        # We assume that the cluster in which the host operates is OVS enabled
        # and all other hosts in the cluster have the migration hook installed.
        # The migration hook is responsible to convert ip to net and vice versa
        display_network = self.specParams.get('displayNetwork')
        display_ip = self.specParams.get('displayIp', '0')
        if (display_network and display_ip != '0' and
                supervdsm.getProxy().ovs_bridge(display_network)):
            graphics.appendChildWithArgs(
                'listen', type='address', address=display_ip)
        elif display_network:
            graphics.appendChildWithArgs(
                'listen', type='network',
                network=net_api.netname_o2l(
                    self.specParams.get('displayNetwork')))
        else:
            graphics.setAttrs(listen='0')

        return graphics
Example #6
0
    def getXML(self):
        """
        Create domxml for a graphics framebuffer.

        <graphics type='spice' port='5900' tlsPort='5901' autoport='yes'
                  listen='0' keymap='en-us'
                  passwdValidTo='1970-01-01T00:00:01'>
          <listen type='address' address='0'/>
          <clipboard copypaste='no'/>
        </graphics>
        OR
        <graphics type='vnc' port='5900' autoport='yes' listen='0'
                  keymap='en-us' passwdValidTo='1970-01-01T00:00:01'>
          <listen type='address' address='0'/>
        </graphics>

        """

        graphicsAttrs = {
            'type': self.device,
            'port': self.port,
            'autoport': 'yes',
        }
        if config.getboolean('vars', 'ssl'):
            graphicsAttrs['defaultMode'] = 'secure'
        # the default, 'any', has automatic fallback to
        # insecure mode, so works with ssl off.

        if self.device == 'spice':
            graphicsAttrs['tlsPort'] = self.tlsPort

        self._setPasswd(graphicsAttrs)

        if 'keyMap' in self.specParams:
            graphicsAttrs['keymap'] = self.specParams['keyMap']

        graphics = vmxml.Element('graphics', **graphicsAttrs)

        if not utils.tobool(self.specParams.get('copyPasteEnable', True)):
            clipboard = vmxml.Element('clipboard', copypaste='no')
            graphics.appendChild(clipboard)

        if not utils.tobool(self.specParams.get('fileTransferEnable', True)):
            filetransfer = vmxml.Element('filetransfer', enable='no')
            graphics.appendChild(filetransfer)

        # This list could be dropped in 4.1. We should keep only
        # the default mode, which is both simpler and safer.
        if (self.device == 'spice'
                and 'spiceSecureChannels' in self.specParams):
            for chan in self._getSpiceChannels():
                graphics.appendChildWithArgs('channel',
                                             name=chan,
                                             mode='secure')

        # For the listen type IP to be used, the display network must be OVS.
        # We assume that the cluster in which the host operates is OVS enabled
        # and all other hosts in the cluster have the migration hook installed.
        # The migration hook is responsible to convert ip to net and vice versa
        display_network = self.specParams.get('displayNetwork')
        display_ip = self.specParams.get('displayIp', '0')
        if (display_network and display_ip != '0'
                and supervdsm.getProxy().ovs_bridge(display_network)):
            graphics.appendChildWithArgs('listen',
                                         type='address',
                                         address=display_ip)
        elif display_network:
            graphics.appendChildWithArgs(
                'listen',
                type='network',
                network=net_api.netname_o2l(
                    self.specParams.get('displayNetwork')))
        else:
            graphics.setAttrs(listen='0')

        return graphics