Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1350348

Summary: can not create VM with spice+vnc
Product: [oVirt] ovirt-engine-sdk-python Reporter: Martin Polednik <mpoledni>
Component: GeneralAssignee: Juan Hernández <juan.hernandez>
Status: CLOSED NOTABUG QA Contact: Pavel Stehlik <pstehlik>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 3.6.7.0CC: bugs, juan.hernandez
Target Milestone: ---Flags: rule-engine: planning_ack?
rule-engine: devel_ack?
rule-engine: testing_ack?
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-06-27 09:40:03 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Infra RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Martin Polednik 2016-06-27 08:30:43 UTC
Description of problem:
Python SDK does not allow to initialize VM object (params.VM) with spice+vnc display. Sending list or two displays is not relaly possible.

Version-Release number of selected component (if applicable):
Seems to be v3 SDK.

How reproducible:
Always.

Steps to Reproduce:
1.
Try something similar to:

api = API(url='<url>', username='admin@internal', password='<password>', insecure=True, validate_cert_chain=False)
VM_NAME = 'vm11'


NIC_NAME = 'eth0'
nic=params.NIC(
    name=NIC_NAME,
    interface='virtio',
    network=params.Network(
        name='ovirtmgmt',
    ),
)

vm_memory =  1024 * 2 ** 20
vm_params = params.VM(
    name=VM_NAME,
    memory=vm_memory,
    cluster=params.Cluster(
        name='test-cluster',
    ),
    display=params.Display(
        type_='spice',
        smartcard_enabled=True,
        file_transfer_enabled=True,
        copy_paste_enabled=True,
    ),
    template=params.Template(
        name='Blank',
    ),
    os=params.OperatingSystem(
        boot=[params.Boot(dev='network')],
    ),
    delete_protected=True,
    soundcard_enabled=True,
)

2.
modify 
    display=params.Display(
        type_='spice+vnc',
        smartcard_enabled=True,
        file_transfer_enabled=True,
        copy_paste_enabled=True,
    ),

(or try list or anything)

3.
api.vms.add(vm_params)
api.vms.get(VM_NAME).nics.add(nic)
api.vms.get(VM_NAME).start()

Actual results:
detail: The string 'spice+vnc' isn't a valid value for the 'DisplayType' enumerated type. Valid values are: 'vnc', 'spice'.

Expected results:
The VM starts with spice + vnc configuration.

Additional info:

Comment 1 Juan Hernández 2016-06-27 09:40:03 UTC
Since version 3.6 of the engine the correct way to manipulate the graphics consoles attached to a virtual machine is using the "graphicsconsoles" sub-collection. The existing "display.type" element inside the virtual machine is preserved only for backwards compatibility, and it only supports one value.

If you need to check which graphics consoles are currently enabled you can use the following code:

---8<---
protocols = []
for console in vm.graphicsconsoles.list():
  protocols.append(console.get_protocol())
print(protocols)
--->8---

This should print something like ['spice', 'vnc'], depending on the protocols that are actually enabled.

To enable a protocol you need to add it to the collection, and to disable it you need to remove it from the collection.

For example, to make sure that both SPICE and VNC are enabled, you can do the following:

---8<---
# Enable the SPICE protocol if it isn't already enabled:
if not 'spice' in protocols:
    vm.graphicsconsoles.add(
        params.GraphicsConsole(
            protocol='spice',
        )
    )

# Enable the VNC protocol if it isn't already enabled:
if not 'vnc' in protocols:
    vm.graphicsconsoles.add(
        params.GraphicsConsole(
            protocol='vnc',
        )
    )
--->8---

Comment 2 Martin Polednik 2016-06-27 09:50:18 UTC
How is it possible to specify the console parameters in that case? Display includes parameters like 

- smartcard_enabled,
- keyboard_layout,
- file_transfer_enabled

and more. I can't seem to find a way to pass these to GraphicsConsole.

Comment 3 Juan Hernández 2016-06-28 11:57:06 UTC
These parameters are still part of the "display" element. What has been moved to the "graphicsconsoles" collection is "display.type".