[Users] Python script retrieving MACs
Michael Pasternak
mpastern at redhat.com
Thu Dec 6 08:08:51 UTC 2012
On 12/06/2012 02:22 AM, Eli Mesika wrote:
>
>
> ----- Original Message -----
>> From: "Vincent Van der Kussen" <vincent at vanderkussen.org>
>> To: users at ovirt.org
>> Sent: Wednesday, December 5, 2012 10:39:02 AM
>> Subject: [Users] Python script retrieving MACs
>>
>> Hi,
>>
>> Im currently making a script using the Python SDK to retrieve a list
>> of VM names + their MAC address.
>> I currently came up with this
>>
>> 17 vm = api.vms.list()
>> 18
>> 19
>> 20 for item in vm:
>> 21 hostname = item.get_name()
>> 22 nic = api.vms.get(name=hostname).nics.list()
>> 23 for net in nic:
>> 24 nicname = net.mac.get_address()
>> 25 print "%s" % hostname
>> 26 print "%s" % nicname
>>
>> I've noticed that retrieving the nic list during the iteration does a
>> logon each time which slows thing down dramatically.
>> Is there a better way to get the NICs from a list of VMs?
>
> Michael P wrote in another thread :
>
> ##if you using > 3.1 backend, you should be using persistent authentication in api,
> ##this way you'll have to pass JSESSIONID and login will happen only on first request.
>
> Michael , please elaborate on that
persistent authentication available since 3.1 api,
if your backend is 3.1 or higher, sdk will use it by default,
otherwise authentication happens peer request.
>
>>
>> Regards,
>> Vincent
>>
>> _______________________________________________
>> Users mailing list
>> Users at ovirt.org
>> http://lists.ovirt.org/mailman/listinfo/users
>>
--
Michael Pasternak
RedHat, ENG-Virtualization R&D
More information about the Users
mailing list