Bug 1350348 - can not create VM with spice+vnc
Summary: can not create VM with spice+vnc
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: ovirt-engine-sdk-python
Classification: oVirt
Component: General
Version: 3.6.7.0
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
: ---
Assignee: Juan Hernández
QA Contact: Pavel Stehlik
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-06-27 08:30 UTC by Martin Polednik
Modified: 2016-06-28 11:57 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-06-27 09:40:03 UTC
oVirt Team: Infra
Embargoed:
rule-engine: planning_ack?
rule-engine: devel_ack?
rule-engine: testing_ack?


Attachments (Terms of Use)

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".


Note You need to log in before you can comment on or make changes to this bug.