[ovirt-users] [PySDK v3] Choose storage domain

Nicolas Ecarnot nicolas at ecarnot.net
Tue Jan 24 12:18:17 UTC 2017


Juan,

Thank you very much for your help, this is working.

Some comments below.

Le 24/01/2017 à 11:04, Juan Hernández a écrit :
> In order to do that you need to specify that you want to clone the disks
> of the template, and for each disk you need to specify the storage
> domain where you want to create it.

This is what I feared, and it was not really obvious at first sight (to 
prepare a disks list...).
I think I saw it was less weird in V4.

> [...]

> Also, please be careful when specifying the cluster and the template.
> You are currently doing this:
>
>   cluster=vm_cluster,
>   template=vm_template,
>
> Not sure how you are assigning the values to those 'vm_cluster' and
> 'vm_template' variables, but you are probably doing this:
>
>   vm_cluster = api.vms.get(name='mycluster')
>   vm_template = api.vms.get(name='mytemplate')

Here is what I was doing (please don't laugh) :

c_list = api.clusters.list()
# At present (2017), each datacenter contains only one cluster
vm_cluster = c_list[0]

vm_template = api.templates.get(name=template_name)

> That combination isn't ideal, because you will be sending with the 'add'
> request the complete representation of the cluster and the template,
> when the server only needs the id or the name. Consider doing this instead:
>
>   cluster=params.Cluster(
>     id=vm_cluster.get_id()
>   ),
>   template=params.Cluster(
>     id=vm_template.get_id()
>   ),

Is it right to say that this last method is only valid in the api 
context, and would not work outside of the api object scope?
I mean : if I want to use your method, I can no longer separate the 
preparation of a vm_params object before calling the vms.add, right?




OK, just one second before sending this e-mail, I made a quick test with 
the template object and it is working anyway.
Does it mean nothing is instantiated before the api.vms.add call?

-- 
Nicolas ECARNOT


More information about the Users mailing list