[Users] Python script retrieving MACs

Eli Mesika emesika at redhat.com
Thu Dec 6 00:22:14 UTC 2012



----- 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

> 
> Regards,
> Vincent
> 
> _______________________________________________
> Users mailing list
> Users at ovirt.org
> http://lists.ovirt.org/mailman/listinfo/users
> 



More information about the Users mailing list