First wanted to say thanks for all the stuff I've found so far by the community (especially William Lam, in my case).
Currently I am in a dire need to figure out, how to change the MAC of a machine.
After reading the vSphere SDK for Perl documentation, and successfully writing (or at least understanding hehe) scripts to retrieve information as well as do simple actions such as reboot/poweron etc, I've moved on to changing properties of virtual machines.
My current task (small part of a bigger project actually), is to be able to get as parameter, a MAC address and VM name, then find the VM, and modify the MAC address (it will only have one...)
I have tried following the Documentation, in the section about "Modifying Property Values"
As you can see in my attached Perl code, line 74 is: $newMAC = $_->macAddress($parsedMAC);
Which is like the Documentation example, and actually gives no errors when ran - except MAC doesn't change!
I've tried everything I could think of, but in other variations or scopes, there are errors about not found methods/objects etc, so pretty sure I am on the right track at least.
Finally I managed to find William's vmNICManagement.pl - which is exactly for changing MAC! (mind you, it was NOT easy to find heh).
I looked at the code first, trying to understand how is that different from what I tried, and I still cant understand why does he have so many more parameters such as $vnic_device,$vnic_name and then doing a lot of checks about properties that don't exist as far as I am aware - I work according to: http://pubs.vmware.com/vi30/sdk/ReferenceGuide/vim.vm.device.VirtualEthernetCard.html
There should only be 3 properties....
Anyhow, I gave it a try, but Lam's script gives this error to me:
Can't locate object method "network" via package "VirtualEthernetCardDistributedVirtualPortBackingInfo" at /usr/lib/vmware-vcli/apps/vm/vmNICManagement.pl line 123.
Which is not surprising, cause this property doesn't exist according to API documentation.
If I am wrong or don't understand, please correct me... Been trying to get it fixed the whole working day
I also tried to understand the values of the variables in his updatemac function, added a print line which prints:
vnic_device is: VirtualPCNet32=HASH(0xa9ee57c), vnic_name is: Network adapter 1
I know the machine was created with an E1000 adaptor, so this is what I specify when I try running his script.
I hope someone can give me some help with this.. I am getting the feel my code is pretty close to being right and (as usual in programming..) missing something small
ChangeMAC2.pl 1.9 K