<!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>
tis 2013-06-04 klockan 16:32 +0300 skrev Michael Pasternak:
<blockquote type="CITE">
<pre>
Karli,
On 06/04/2013 04:05 PM, Karli Sjöberg wrote:
> Hello everyone!
>
> I´m almost done with Python for now. But the last thing I sitll can´t seem to get any hang on is how to change the name of a VM´s disk:
please use disk.alias property, name is deprecated and for backward compatibility only.
</pre>
</blockquote>
<br>
It doesn´t matter what property I use, the name doesn´t change any way! Please read below, you´ll see I even tried defining .alias and .name at the same time, then update, but still no change. Could you please post the correct, and working way of doing this,
please.<br>
<br>
<blockquote type="CITE">
<pre>
>
>>>> from ovirtsdk.api import API
>>>> from ovirtsdk.xml import params
>>>> api = API(url='<a href="https://">https://</a>${OVIRT}:443 <<a href="https://storm.slu.se:443">https://storm.slu.se:443</a>>', ca_file='/etc/pki/ovirt-engine/ca.pem', username='admin@internal <<a href="mailto:'admin@internal">mailto:'admin@internal</a>>',
> password='letmein!')
>>>> VM_NAME = 'FedoraTest'
>>>> DISK_NAME = '%s_Disk1' % (VM_NAME)
>>>> vm = api.vms.get(VM_NAME)
>>>> vmdisk = vm.disks.list()[0]
>>>> vmdisk.alias = 'foobar'
>>>> vmdisk.name = 'foobar'
>>>> vmdisk.update()
> <ovirtsdk.infrastructure.brokers.VMDisk object at 0x25d7ad0>
>
> But the name/alias/whatev never changes...
>
> Could you please give me an exact, and working example of how to change the name of a VM´s disk. This is the last simple thing I would like to accomplish before sharing a
> little something back with y´all(teaser, teaser).
>
> /Karli
>
> sön 2013-05-26 klockan 02:48 -0400 skrev Ilia Meerovich:
>> Hi,
>>
>> Lets follow <a href="http://www.ovirt.org/Python-sdk">http://www.ovirt.org/Python-sdk</a>
>>
>> In [1]: from ovirtsdk.xml import params
>>
>> In [2]: from ovirtsdk.api import API
>>
>> In [3]:
>>
>> In [4]: api = API(***, ***, ***)
>>
>> In [5]: user_name = "***"
>>
>> In [6]: domain = "***.***.***.redhat.com"
>>
>> In [7]: user_domain = params.Domain(name=domain)
>>
>> In [8]: user_name = "{0}@{1}".format(user_name, domain)
>> # creating user
>> In [9]: new_user = params.User(domain=user_domain, user_name=user_name)
>> # adding user to users resource
>> In [10]: user = api.users.add(new_user)
>> # adding role to user
>> In [11]: user.roles.add(api.roles.get('UserRole'))
>> Out[11]: <ovirtsdk.infrastructure.brokers.UserRole object at 0x30c7590>
>>
>> Thanks
>> Ilia
>>
>> ----- Original Message -----
>> From: "Karli Sjöberg" <<a href="mailto:Karli.Sjoberg@slu.se">Karli.Sjoberg@slu.se</a> <<a href="mailto:Karli.Sjoberg@slu.se">mailto:Karli.Sjoberg@slu.se</a>>>
>> To: "Ilia Meerovich" <<a href="mailto:imeerovi@redhat.com">imeerovi@redhat.com</a> <<a href="mailto:imeerovi@redhat.com">mailto:imeerovi@redhat.com</a>>>
>> Cc: "Michael Pasternak" <<a href="mailto:mpastern@redhat.com">mpastern@redhat.com</a> <<a href="mailto:mpastern@redhat.com">mailto:mpastern@redhat.com</a>>>, "users" <<a href="mailto:users@ovirt.org">users@ovirt.org</a> <<a href="mailto:users@ovirt.org">mailto:users@ovirt.org</a>>>, "Elena Dolinin" <<a href="mailto:edolinin@redhat.com">edolinin@redhat.com</a> <<a href="mailto:edolinin@redhat.com">mailto:edolinin@redhat.com</a>>>
>> Sent: Friday, May 24, 2013 8:04:43 AM
>> Subject: Re: [Users] Problems using the PythonSDK
>>
>> tor 2013-05-23 klockan 08:53 -0400 skrev Ilia Meerovich:
>>
>> It should be like:
>>
>> from ovirtsdk.xml import params
>> from ovirtsdk.api import API
>>
>> api = API('*', '*', '*')
>> vm = api.vms.list()[0]
>> user = api.users.list()[1]
>> role = api.roles.list()[1]
>> permit = params.Permission()
>> permit.set_role(role)
>> permit.set_vm(vm)
>> user.permissions.add(permit)
>> Thank you very much, I´m going to test this out today! Could you also show me how to first add a user that isn´t in the system yet, please?
>>
>>
>>
>> ----- Original Message -----
>> From: "Ilia Meerovich" < <a href="mailto:imeerovi@redhat.com">imeerovi@redhat.com</a> <<a href="mailto:imeerovi@redhat.com">mailto:imeerovi@redhat.com</a>> >
>> To: "Michael Pasternak" < <a href="mailto:mpastern@redhat.com">mpastern@redhat.com</a> <<a href="mailto:mpastern@redhat.com">mailto:mpastern@redhat.com</a>> >
>> Cc: "users" < <a href="mailto:users@ovirt.org">users@ovirt.org</a> <<a href="mailto:users@ovirt.org">mailto:users@ovirt.org</a>> >, "Karli Sjöberg" < <a href="mailto:Karli.Sjoberg@slu.se">Karli.Sjoberg@slu.se</a> <<a href="mailto:Karli.Sjoberg@slu.se">mailto:Karli.Sjoberg@slu.se</a>> >, "Elena Dolinin" < <a href="mailto:edolinin@redhat.com">edolinin@redhat.com</a> <<a href="mailto:edolinin@redhat.com">mailto:edolinin@redhat.com</a>> >
>> Sent: Thursday, May 23, 2013 3:30:27 PM
>> Subject: Re: [Users] Problems using the PythonSDK
>>
>> Hi,
>>
>> We have several tests like:
>> "Add VM permission to user", that are using ART's art/rhevm_api/tests_lib/low_level/mla.py addPermitsToUser function.
>> This is generic function but it shouldn't be hard to prepare SDK code with the same functionality.
>>
>> Thanks
>> Ilia
>>
>> ----- Original Message -----
>> From: "Michael Pasternak" < <a href="mailto:mpastern@redhat.com">mpastern@redhat.com</a> <<a href="mailto:mpastern@redhat.com">mailto:mpastern@redhat.com</a>> >
>> To: "Karli Sjöberg" < <a href="mailto:Karli.Sjoberg@slu.se">Karli.Sjoberg@slu.se</a> <<a href="mailto:Karli.Sjoberg@slu.se">mailto:Karli.Sjoberg@slu.se</a>> >, "Elena Dolinin" < <a href="mailto:edolinin@redhat.com">edolinin@redhat.com</a> <<a href="mailto:edolinin@redhat.com">mailto:edolinin@redhat.com</a>> >, "Ilia Meerovich" < <a href="mailto:imeerovi@redhat.com">imeerovi@redhat.com</a> <<a href="mailto:imeerovi@redhat.com">mailto:imeerovi@redhat.com</a>> >
>> Cc: "users" < <a href="mailto:users@ovirt.org">users@ovirt.org</a> <<a href="mailto:users@ovirt.org">mailto:users@ovirt.org</a>> >
>> Sent: Thursday, May 23, 2013 3:10:21 PM
>> Subject: Re: [Users] Problems using the PythonSDK
>>
>>
>> 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', < <a href="https://storm.slu.se:443/api'">https://storm.slu.se:443/api'</a> ,> ca_file='${CACERT}', username='admin@internal < <a href="mailto:'admin@internal">mailto:'admin@internal</a> >', 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
>> > <a href="mailto:karli.sjoberg@slu.se">karli.sjoberg@slu.se</a> <<a href="mailto:karli.sjoberg@slu.se">mailto:karli.sjoberg@slu.se</a>> < <a href="mailto:karli.sjoberg@adm.slu.se">mailto:karli.sjoberg@adm.slu.se</a> >
>> >
>> >
>> >
>> > _______________________________________________
>> > Users mailing list
>> > <a href="mailto:Users@ovirt.org">Users@ovirt.org</a> <<a href="mailto:Users@ovirt.org">mailto:Users@ovirt.org</a>> > <a href="http://lists.ovirt.org/mailman/listinfo/users">http://lists.ovirt.org/mailman/listinfo/users</a> >
>>
>>         --
>>
>> Med Vänliga Hälsningar
>> -------------------------------------------------------------------------------
>> 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
>> <a href="mailto:karli.sjoberg@slu.se">karli.sjoberg@slu.se</a> <<a href="mailto:karli.sjoberg@slu.se">mailto:karli.sjoberg@slu.se</a>>
>
> --
>
> Med Vänliga Hälsningar
> -------------------------------------------------------------------------------
> 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
> <a href="mailto:karli.sjoberg@slu.se">karli.sjoberg@slu.se</a> <<a href="mailto:karli.sjoberg@adm.slu.se">mailto:karli.sjoberg@adm.slu.se</a>>
>
</pre>
</blockquote>
<br>
<table cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td>-- <br>
<br>
Med Vänliga Hälsningar<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>