InvalidArgument: A specified parameter was not correct: deviceChange[1].device.key" - vCenter adding two NICs
Description Attaching two NICs with vCenter results into an InvalidArgument error.
deploy: Deploy of VM 16 on vCenter cluster Cluster1 with /var/lib/one/vms/16/deployment.0 failed due to
"InvalidArgument: A specified parameter was not correct: deviceChange[1].device.key"on attempt #2.
To Reproduce Instantiate a template and adding (or template already has) two NICs attached.
Expected behavior Virtual machines is being created without errors.
Details
- Affected Component: vCenter Driver
- Hypervisor: vCenter 7.0
- Version: 6.8.3
Additional context
So i might have identified already where it fails:
- the
device_changecontains two devices with same key-101. -
calculate_add_nic_specis calculating acard_numbased on@item['config.hardware.device']which on a new vm seems to never contain the NIC devices, this results into same number forcard_spec[:key] = -100 - card_num.to_i - on the other hand i found code calculating a
@unicbut it is never used - using
@uniqcatcard_spec[:key] = -100 - @uniqc.to_iand:label => 'net' + @uniqc.to_s,gives the expected result (not sure if first place plays a role.
So this already could be the fix needed. I am not sure what about the other part when converting to a template. calculate_add_nic_spec_autogenerate_mac
Progress Status
- [ ] Code committed
- [ ] Testing - QA
- [ ] Documentation (Release notes - resolved issues, compatibility, known issues)
Is there anything new? We have the same problem since the update to vSphere 8.0. We have fixed it ourselves so far. But it would be nice if there was an official solution.
For people who also have problems. In the file /usr/lib/one/ruby/opennebula/virtual_machine.rb insert in two places under if @vi_client.vim.serviceContent.about.apiVersion.to_f >= 7.0:
# Initialize @used_keys if not already done
@used_keys ||= @item['config.hardware.device'].map(&:key)
# Find next available unique key starting from -100
key = -100
key -= 1 while @used_keys.include?(key)
# Remember this key has been used
@used_keys << key
card_spec[:key] = key
Thanks for the hint @Kazyini
I guess your path is not korrekt, the virtual_machine.rb file which needs to be patched, is not the one in /usr/lib/one/ruby/opennebula/ but in /usr/lib/one/ruby/vcenter_driver/
(Version OpenNebula 6.10.0.1)