<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="GENERATOR" content="GtkHTML/4.4.4">
</head>
<body>
Hi!<br>
<br>
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:<br>
<br>
1) Create a new VM from a template; OK. I found an example and it worked OOTB<br>
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):<br>
>>> from ovirtsdk.xml import params<br>
>>> from ovirtsdk.api import API<br>
>>> api = API(url='<a href="https://storm.slu.se:443/api',">https://${ENGINE}:443/api',</a> ca_file='${CACERT}', username=<a href="mailto:'admin@internal">'admin@internal</a>', password='letmein!')<br>
>>> vm = api.vms.get(name='VMName')<br>
<br>
>>> vmnic = vm.nics.get(name='*')<br>
>>> vmnic.name<br>
'nic1'<br>
>>> api.vms.get(name='VMName').nics.get(name='*')<br>
'nic1'<br>
>>> vmnic.name='nic2'<br>
>>> vmnic.update()<br>
>>> api.vms.get(name='VMName').nics.get(name='*')<br>
'nic2'<br>
>>> vmnic.name<br>
'nic2'<br>
<br>
>>> vmdisk = vm.disks.get(name='*')<br>
>>> vmdisk.name<br>
'TemplateName_Disk1'<br>
>>> api.vms.get(name='VMName').disks.get(name='*')<br>
'TemplateName_Disk1'<br>
>>> vmdisk.name='VMName_Disk1'<br>
>>> vmdisk.update()<br>
>>> vmdisk.name<br>
'VMName_Disk1'<br>
>>> api.vms.get(name='VMName').disks.get(name='*')<br>
'TemplateName_Disk1'<br>
<br>
See? Am I holding it wrong?<br>
<br>
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.<br>
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...<br>
<br>
client# rpm -qa | grep ovirt<br>
ovirt-engine-cli-3.2.0.11-1.fc17.noarch<br>
ovirt-engine-sdk-3.2.0.10-1.fc17.noarch<br>
<br>
engine# rpm -qa | grep ovirt<br>
ovirt-engine-config-3.1.0-4.fc17.noarch<br>
ovirt-engine-dbscripts-3.1.0-4.fc17.noarch<br>
ovirt-log-collector-3.1.0-0.git10d719.fc17.noarch<br>
ovirt-engine-restapi-3.1.0-4.fc17.noarch<br>
ovirt-image-uploader-3.1.0-0.git9c42c8.fc17.noarch<br>
ovirt-engine-genericapi-3.1.0-4.fc17.noarch<br>
ovirt-iso-uploader-3.1.0-0.git1841d9.fc17.noarch<br>
ovirt-engine-webadmin-portal-3.1.0-4.fc17.noarch<br>
ovirt-engine-setup-3.1.0-4.fc17.noarch<br>
ovirt-engine-sdk-3.2.0.2-1.fc17.noarch<br>
ovirt-engine-backend-3.1.0-4.fc17.noarch<br>
ovirt-engine-tools-common-3.1.0-4.fc17.noarch<br>
ovirt-engine-3.1.0-4.fc17.noarch<br>
ovirt-engine-userportal-3.1.0-4.fc17.noarch<br>
ovirt-engine-notification-service-3.1.0-4.fc17.noarch<br>
<br>
<table cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td>-- <br>
<br>
Best Regards<br>
-------------------------------------------------------------------------------<br>
Karli Sjöberg<br>
Swedish University of Agricultural Sciences<br>
Box 7079 (Visiting Address Kronåsvägen 8)<br>
S-750 07 Uppsala, Sweden<br>
Phone: +46-(0)18-67 15 66<br>
<a href="mailto:karli.sjoberg@adm.slu.se">karli.sjoberg@slu.se</a> </td>
</tr>
</tbody>
</table>
</body>
</html>