[Users] Python script retrieving MACs

Vincent Van der Kussen vincent at vanderkussen.org
Wed Dec 5 08:39:02 UTC 2012


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?

Regards,
Vincent




More information about the Users mailing list