Hi Karli,
On 05/23/2013 12:35 PM, Karli Sjöberg wrote:
Hi!
We´re in the process of building an orderportal where our customers will be able to log
in, select a virtual machine template, type in a desired hostname and it will be
automatically created, and they recieve a mail explaining what they´ve gotten themselves
into:). For this I figured the PythonSDK would be the best choice but I´m having
trouble using it. What we´ve done so far is:
1) Create a new VM from a template; OK. I found an example and it worked OOTB
2) Rename the new VM´s disk from ${TemplateName}_Disk1 to ${VMName}_Disk1; Not OK. I
found an example of how to change the name of a VMNic and that works, but using the
same method to change VMDisk´s name does not (FYI, the VM only has one VNic and VDisk):
>>> from ovirtsdk.xml import params
>>> from ovirtsdk.api import API
>>> api = API(url='https://${ENGINE}:443/api',
<
https://storm.slu.se:443/api',> ca_file='${CACERT}',
username='admin@internal <mailto:'admin@internal>',
password='letmein!')
>>> vm = api.vms.get(name='VMName')
>>> vmnic = vm.nics.get(name='*')
>>> vmnic.name
'nic1'
>>> api.vms.get(name='VMName').nics.get(name='*')
'nic1'
>>> vmnic.name='nic2'
>>> vmnic.update()
>>> api.vms.get(name='VMName').nics.get(name='*')
'nic2'
>>> vmnic.name
'nic2'
>>> vmdisk = vm.disks.get(name='*')
>>> vmdisk.name
'TemplateName_Disk1'
>>> api.vms.get(name='VMName').disks.get(name='*')
this kind of call is not efficient, by fetching the disk
you also fetch the vm,
i'd suggest fetch vm, store it in local variable and then
reuse it for any sub-collection manipulations.
'TemplateName_Disk1'
>>> vmdisk.name='VMName_Disk1'
>>> vmdisk.update()
>>> vmdisk.name
'VMName_Disk1'
>>> api.vms.get(name='VMName').disks.get(name='*')
'TemplateName_Disk1'
See? Am I holding it wrong?
disk.name is deprecated, please use 'alias' instead.
3) Create a snapshot called "Origin", so if a customer calls in and says
they´ve borked it completely, we´ll just revert to it´s "Origin" and they´re up
and running again;
OK, found another OOTB example, thank you.
4) Add the customer to VM´s Permissions with an appropriate role; Not OK. I have found no
examples on how to do this and just don´t know where to start looking. BTW,
creating a new VM with Python results in Permissions completely empty, no inheritance
either. Don´t know if that is intended...
elena, ilia,
guys, do you have any permission related code to share?
client# rpm -qa | grep ovirt
ovirt-engine-cli-3.2.0.11-1.fc17.noarch
ovirt-engine-sdk-3.2.0.10-1.fc17.noarch
engine# rpm -qa | grep ovirt
ovirt-engine-config-3.1.0-4.fc17.noarch
ovirt-engine-dbscripts-3.1.0-4.fc17.noarch
ovirt-log-collector-3.1.0-0.git10d719.fc17.noarch
ovirt-engine-restapi-3.1.0-4.fc17.noarch
ovirt-image-uploader-3.1.0-0.git9c42c8.fc17.noarch
ovirt-engine-genericapi-3.1.0-4.fc17.noarch
ovirt-iso-uploader-3.1.0-0.git1841d9.fc17.noarch
ovirt-engine-webadmin-portal-3.1.0-4.fc17.noarch
ovirt-engine-setup-3.1.0-4.fc17.noarch
ovirt-engine-sdk-3.2.0.2-1.fc17.noarch
ovirt-engine-backend-3.1.0-4.fc17.noarch
ovirt-engine-tools-common-3.1.0-4.fc17.noarch
ovirt-engine-3.1.0-4.fc17.noarch
ovirt-engine-userportal-3.1.0-4.fc17.noarch
ovirt-engine-notification-service-3.1.0-4.fc17.noarch
--
Best Regards
-------------------------------------------------------------------------------
Karli Sjöberg
Swedish University of Agricultural Sciences
Box 7079 (Visiting Address Kronåsvägen 8)
S-750 07 Uppsala, Sweden
Phone: +46-(0)18-67 15 66
karli.sjoberg(a)slu.se <mailto:karli.sjoberg@adm.slu.se>
_______________________________________________
Users mailing list
Users(a)ovirt.org
http://lists.ovirt.org/mailman/listinfo/users
--
Michael Pasternak
RedHat, ENG-Virtualization R&D