Also
Need to support multiple nics and
set .virtualDev to vmxnet or e1000 as appropriate
Here's a script that lists all of the network cards for a virtual machine including the macAddress.
(The script has been posted at http://communities.vmware.com/docs/DOC-1134 )
Thats is really cool but how do I list out all the VM which has static MAC and what would be their MAC address. I thought of using Enum - VirtualEthernetCardMacType but not sure where it would fit in your script.
How about something like this? I apologize for the rough snippet.
If someone knows of a smoother way to filter out the devices by a view filter, I'd love to hear it. I ended up using 'isa' to determine the superclass of the vmware device to determine which devices were VirtualEthernetDevices. This should work for determining other device types as well.
This is exactly what I'm looking for too, but I get this error:
Can't use an undefined value as an ARRAY reference at get-macs.pl line 36.
I checked some of my samples, I have an updated version that I probably used when I ran into the problem you posted. I believe this error occurs when you have a VM defined but no devices assigned to it (no disk, no ethernet..just an empty shell.) This updated script check if the device array is defined. I wish the perl toolkit would return empty arrays instead of undefined values, just saves a lot of error checking in your script logic to avoid bomb outs.
I figured that was the case.. I started stepping through and troubleshooting, but just stepped out for a coffee so didn't get to changing it yet :smileycool:
I still get the error though.. maybe we just don't have any static macs
EDIT: My error--- it works!
This is GREAT! I spent hours trying to figure this out searching through the mob and the vi reference. It shows me exactly what i've been missing.
Thanks soooo much for your post.