Open ashxjain opened 8 years ago
Hi,
I have the exact same question, also need this.
Otherwise, need a copy of each source template/vm for each port group.
This functionality exists after all, with the "vlan" setting. Just set it to the desired network / port group name.
Thank you @voiprodrigo ! You are right. But i wanted to configure multiple network mappings and not just for 1st NIC. Say if i have 2 NICs, i want NIC1 to be mapped to PortGroup1 and NIC2 to be mapped to PortGroup2.
I did the following changes to work in my setup:
In lib/vSphere/action/clone.rb:
def create_network_device(label, summary, index)
key = 4000 + index
config_spec_operation = RbVmomi::VIM::VirtualDeviceConfigSpecOperation('edit')
nic_backing_info = RbVmomi::VIM::VirtualEthernetCardNetworkBackingInfo(:deviceName => summary)
connectable = RbVmomi::VIM::VirtualDeviceConnectInfo(
:allowGuestControl => true,
:connected => true,
:startConnected => true)
device = RbVmomi::VIM::VirtualVmxnet3(
:backing => nic_backing_info,
:deviceInfo => RbVmomi::VIM::Description(:label => label, :summary => summary),
:key => key,
:connectable => connectable)
device_spec = RbVmomi::VIM::VirtualDeviceConfigSpec(
:operation => config_spec_operation,
:device => device)
return device_spec
end
def add_custom_network(spec, vm_template, test_net1, test_net2)
device_net1_spec = create_network_device("Network adapter 1", test_net1, 0)
device_net2_spec = create_network_device("Network adapter 2", test_net2, 1)
spec[:config][:deviceChange] = [device_net1_spec, device_net2_spec]
end
Have a look at my pull request #210
It adds comprehensive support for multiple nics and configuring them just the way you want.
I use it to configure virtual routers that have 10 nics and connect to a number of different port groups.
I want to deploy a VM on an ESXI server. VM has 3 network interfaces.
When the VM is deployed on ESXI server by Vagrant, How can i map those network interfaces to use the port-groups (networks) on that ESXI server? I'm unable to find any way to do it using Vagrant.
Because of this, Vagrant is unable to SSH into the VM, as the VM's network interfaces are mapped to some port-groups (junk).
test-vm-1: Warning: Authentication failure. Retrying...