Hello,
I am trying to create a virtual machine from a template using oVirt
API. Somehow like this:
---
def createVM(connection, cluster, vmname, vmtemplate):
try:
param = params.VM( name=vmname, \
cluster=connection.clusters.get(name=cluster), \
template=connection.templates.get(name=vmtemplate), \
use_latest_template_version = True )
except:
print "Could not construct a request to oVirtapi,please check parameters which were
being sent to"
return None
try:
connection.vms.add(param)
except:
print "I was not able to commit my request into oVirt api."
return None
return "OK"
---
Everything is fine when I have only ONE version of a template. But I am
used to create several number of versions for one template because it
is quite flexible. In this case, when I run my script, I receive an
"AmbiguousQueryError" error even if an option
"use_latest_template_version = True" is used.
I revised
file /usr/lib/python2.7/site-packages/ovirtsdk/utils/filterhelper.py
and found near line 30 that this error is raised unquestionably:
--
if len(result) > 1:
raise AmbiguousQueryError(query)
return result[0] if result else None
--
It seems quite strange. Either I do not understand the meaning of
option "use_latest_template_version" or using of this option does not
make sense, I mean query constructed in params.VM() function will not
be passed by filterhelper.py in current implementation.
I made a small patch that allows me to use the latest
version of the template during VM creation:
--
if len(result) > 1 :
result = result[len(result) - 1]
return result
#raise AmbiguousQueryError(query)
return result[0] if result else Nonepython-2.7.5-34.el7.x86_64
--
But I am still not sure that original behaviour of filehelper.py is
unexpectable. I would be very pleasant if you explain me this issue.
My OS is CentOS 7. I use Python python-2.7.5-34.el7.x86_64. Version of
ovirt-engine-sdk is ovirt-engine-sdk-python-3.6.8.0-1.el7.centos.noarch
--
Thanks in advance, Roman A. Chukov.
https://asgardahost.org