Closed antonmarsden closed 4 years ago
Like the array but not crazy about "dhcp". If one wants dhcp, they should simply omit the ip setting.
Only a single NIC will be configured if you omit the IP address - so the 'dhcp' option caters for a dual NIC DHCP situation, i.e., :ip => ['dhcp', 'dhcp']
I believe knife-vsphere behaves in the same way.
oh i see. right. that makes sense. Might be nice for it to honor a nil or empty entry. I guess thay all have varying levels of weirdness.
The code now honours a nil/empty entry, i.e., no :ip setting implies :ip => [nil] and nil means dhcp. Also means you can have 2 NICs on dhcp, e.g., :ip => [nil, nil]
So I recently got access to vmware infrastructure and have tested this change. The main issue I see is that it requires that the template vm being cloned have the appropriate number of NICs already attached. If your base vm has just one NIC and you assign two networks here and two IP entries, you will get a NicSettingMismatch
error.
The main culprit here is the way that the driver currently adds NICs I think is fundamentally flawed. It initially only configures the existing NICs and then it adds NICs after the clone operation. I honestly can't remember why this is. Its most likely because I did not have a good grasp of vmware, the vsphere API or ruby at the time. I was a C# dev who had only worked with VirtualBox and Hyper-V when I started working on this 2 years ago.
That said I think you could add all the NICs up front simply by changing this line to:
clone_spec.config.deviceChange = [changes, deviceAdditions].flatten
then removing the setup_extra_nics
logic in driver.rb.
The only remaining issue is the windows specific logic in setup_extra_nics
. Currently it disables the extra adapters. I don't know if setting the nic to not be connected would accomplish the same thing here. So one thought here is that if the IP array is smaller than ther number of nics, you would just have the remaining nics be disconnected. I think that would maintain backward compatibility.
Hope that all makes sense.
Hi! If you're still interested in getting this merged, please close and reopen this PR against the new maintainers at https://github.com/chef-partners/chef-provisioning-vsphere.
We are in the process of reinvigorating this project and look forward to many collaborations in the future!
Thanks for your time and help!
Oh! We also are on the VMware{Code} slack team in #chef if you'd ever like to come by and say hi!
The [:ip] field can now be a single IP address (string) or an array of IP addresses.
As per knife vsphere functionality, I have also added the ability to use 'dhcp' as the address (as yet untested)