Exemple #1
0
def generate_spice_graphic_xml(params, expected_result):
    """
    Generate SPICE graphics XML using input parameters.
    """
    autoport = params.get("spice_autoport", "yes")
    default_mode = params.get("defaultMode", "not_set")
    channels_str = params.get("channels", "")
    port = params.get("spice_port", "not_set")
    tls_port = params.get("spice_tlsPort", "not_set")
    image_compression = params.get("image_compression", "not_set")
    jpeg_compression = params.get("jpeg_compression", "not_set")
    zlib_compression = params.get("zlib_compression", "not_set")
    playback_compression = params.get("playback_compression", "not_set")
    listen_type = params.get("spice_listen_type", "not_set")

    graphic = Graphics(type_name='spice')

    if autoport != 'not_set':
        graphic.autoport = autoport

    if port != 'not_set':
        graphic.port = port

    if tls_port != 'not_set':
        graphic.tlsPort = tls_port

    if default_mode != 'not_set':
        graphic.defaultMode = default_mode

    if image_compression != 'not_set':
        graphic.image_compression = image_compression

    if jpeg_compression != 'not_set':
        graphic.jpeg_compression = jpeg_compression

    if zlib_compression != 'not_set':
        graphic.zlib_compression = zlib_compression

    if playback_compression != 'not_set':
        graphic.playback_compression = playback_compression

    channels = []
    if channels_str:
        for channel_str in channels_str.strip().split(','):
            name, mode = channel_str.split(':')
            channels.append({'name': name, 'mode': mode})
    graphic.channel = channels

    if listen_type == 'network':
        net_type = params.get("spice_network_type", "vnet")
        listen = {'type': 'network', 'network': 'virt-test-%s' % net_type}
        graphic.listens = [listen]
    elif listen_type == 'address':
        address = params.get("spice_listen_address", "127.0.0.1")
        if address in ['valid_ipv4', 'valid_ipv6']:
            address = str(expected_result['spice_ips'][0])
        listen = {'type': 'address', 'address': address}
        graphic.listens = [listen]

    return graphic
def generate_spice_graphic_xml(params, expected_result):
    """
    Generate SPICE graphics XML using input parameters.
    """
    autoport = params.get("spice_autoport", "yes")
    default_mode = params.get("defaultMode", "not_set")
    channels_str = params.get("channels", "")
    port = params.get("spice_port", "not_set")
    tls_port = params.get("spice_tlsPort", "not_set")
    image_compression = params.get("image_compression", "not_set")
    jpeg_compression = params.get("jpeg_compression", "not_set")
    zlib_compression = params.get("zlib_compression", "not_set")
    playback_compression = params.get("playback_compression", "not_set")
    listen_type = params.get("spice_listen_type", "not_set")

    graphic = Graphics(type_name='spice')

    if autoport != 'not_set':
        graphic.autoport = autoport

    if port != 'not_set':
        graphic.port = port

    if tls_port != 'not_set':
        graphic.tlsPort = tls_port

    if default_mode != 'not_set':
        graphic.defaultMode = default_mode

    if image_compression != 'not_set':
        graphic.image_compression = image_compression

    if jpeg_compression != 'not_set':
        graphic.jpeg_compression = jpeg_compression

    if zlib_compression != 'not_set':
        graphic.zlib_compression = zlib_compression

    if playback_compression != 'not_set':
        graphic.playback_compression = playback_compression

    channels = []
    if channels_str:
        for channel_str in channels_str.strip().split(','):
            name, mode = channel_str.split(':')
            channels.append({'name': name, 'mode': mode})
    graphic.channel = channels

    if listen_type == 'network':
        net_type = params.get("spice_network_type", "vnet")
        listen = {'type': 'network', 'network': 'virt-test-%s' % net_type}
        graphic.listens = [listen]
    elif listen_type == 'address':
        address = params.get("spice_listen_address", "127.0.0.1")
        if address in ['valid_ipv4', 'valid_ipv6']:
            address = str(expected_result['spice_ips'][0])
        listen = {'type': 'address', 'address': address}
        graphic.listens = [listen]

    return graphic
 def prepare_spice_graphics_device():
     """
     Prepare a spice graphics device XML according to parameters
     """
     graphic = Graphics(type_name='spice')
     graphic.autoport = "yes"
     graphic.port = "-1"
     graphic.tlsPort = "-1"
     return graphic
 def prepare_spice_graphics_device():
     """
     Prepare a spice graphics device XML according to parameters
     """
     graphic = Graphics(type_name='spice')
     graphic.autoport = "yes"
     graphic.port = "-1"
     graphic.tlsPort = "-1"
     return graphic
Exemple #5
0
    def configure_spice(vm_name):
        """
        Configure spice

        :params vm_name: guest name
        """
        vm_spice_xml = VMXML.new_from_inactive_dumpxml(vm_name)
        vm_spice_xml.remove_all_device_by_type('graphics')

        graphic = Graphics(type_name='spice')
        graphic.autoport = "yes"
        graphic.port = "-1"
        graphic.tlsPort = "-1"
        vm_spice_xml.add_device(graphic)
        vm_spice_xml.sync()