Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VM Network Mappings #209

Open
ashxjain opened this issue Oct 20, 2016 · 4 comments
Open

VM Network Mappings #209

ashxjain opened this issue Oct 20, 2016 · 4 comments

Comments

@ashxjain
Copy link

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...

@voiprodrigo
Copy link

Hi,

I have the exact same question, also need this.

Otherwise, need a copy of each source template/vm for each port group.

@voiprodrigo
Copy link

This functionality exists after all, with the "vlan" setting. Just set it to the desired network / port group name.

@ashxjain
Copy link
Author

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

@taliesins
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants