Vagrant: enhancement: hyper-v provider vswitch customization parameter

Created on 20 Oct 2016  Â·  15Comments  Â·  Source: hashicorp/vagrant

Vagrant version

1.8.6

Host operating system

Windows 10

Guest operating system

ubuntu 12.04

Vagrantfile

node.vm.provider "hyperv" do |hv|
       # Customize the amount of memory on the VM:
       hv.memory = machine[:ram]
       hv.vmname = machine[:hostname] #name in hyper-v manager ui
      end

Expected behavior

there should be an avalible parameter hv.vswitch, that allows user to provide a string containing the hyper-v switch name to vagrant, allowing the user to skip having to make a selection ever time.
If the switch name doesn't exist, fall back to prompting the user.

vagrant/plugins/providers/hyperv/action/import.rb line 63 - 100
appears to have the code nessary to look up a vswitch by name. it seems that with some rework that code could be used to support the vagrantfile configuration option.

Actual behavior

no ability to provide a vswitch name in the vagrant file, must answer the prompt every time.

Steps to reproduce

  1. attempt to provide a vswitch name in the vagrantfile
  2. vagrant up
  3. vagrant fails to bring machine up

    References

enhancement providehyperv

Most helpful comment

There's a work around for this, specifying the network in the vagrantfile:

config.vm.network "public_network", bridge: "VirtualSwitchName"

All 15 comments

+1 will be nice feature.

There's a work around for this, specifying the network in the vagrantfile:

config.vm.network "public_network", bridge: "VirtualSwitchName"

I submitted a pull request which allows you to specify the virtual switch in the config such as;

default.vm.provider 'hyperv' do |provider|
  provider.vswitch = 'DockerNAT'
end

I'm not sure if the change I made will actually break what @michaeltlombardi suggested as a workaround. I guess I'll test that when I get home.

Pull Request #8510

Breaking the workaround is probably okay because the configuration method you supplied is _much more obvious_ to users than the workaround. I don't remember if the work around was anywhere in the official documentation, either.

However, does it lend itself to multi-homed scenerios?

The workaround way would be much easier to update to permit use of multiple vswitches on multiple adapters and follows the Vagrant network config for most other providers. Why create a snow flake that doesn't provide additional functionality?

for example, for a router VM:

config.vm.network "public_network", bridge: "External Switch"
config.vm.network "private_network", bridge: "Internal Switch"

You may want to wait on merging this. I've made significant changes to fully support hyperv and this approach has been changed to be much more flexible.

Regards,

John

On May 1, 2017, at 2:10 PM, WickedViking notifications@github.com wrote:

However, does it lend itself to multi-homed scenerios?

The workaround way would be much easier to update to permit use of multiple vswitches on multiple adapters and follows the Vagrant network config for most other providers. Why create a snow flake that doesn't provide additional functionality?

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.

@johnrizzo1 is the work to more fully support hyper-v finished? Thanks!

@erick-thompson I have been busy at work but I have the code I worked on. Let me see where I was with things and either make it available or finish it.

@johnrizzo1 Thanks John!

"vswitch" option is missing in the documentation: https://www.vagrantup.com/docs/hyperv/configuration.html
So, could we reopen the case until the option is documented ?

@clement-igonet is that the working one rather than

config.vm.network "public_network", bridge: "External Switch"
config.vm.network "private_network", bridge: "Internal Switch"

Has this PR been merged?

@gurry: Option switch doesn't seem to exist for hyperv provider 😞 .
```rb
config.vm.provider 'hyperv' do |h|
h.vswitch = 'DockerNAT'
end
````

$ vagrant up --provider=hyperv
````
[...]
Hyper-V:

  • The following settings shouldn't exist: vswitch
    ````

10455 may be related.

Is someone looking into this?

Right now using:

  config.vm.provider 'hyperv' do |hv, override|
    hv.vlan_id = ENV['HYPERV_VLAN_ID']
    # see https://github.com/hashicorp/vagrant/blob/10faa599e7c10541f8b7acf2f8a23727d4d44b6e/plugins/providers/hyperv/action/configure.rb#L21-L35
    override.vm.network :private_network, bridge: ENV['HYPERV_SWITCH_NAME'] if ENV['HYPERV_SWITCH_NAME']
  end

Is quite odd because we already have an vlan_id property but there is no switch_name (like in packer).

What do you think to add a property named switch_name like in packer? and drop the override.vm.network :private_network part?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tomhking picture tomhking  Â·  3Comments

janw-me picture janw-me  Â·  3Comments

luispabon picture luispabon  Â·  3Comments

bbaassssiiee picture bbaassssiiee  Â·  3Comments

hesco picture hesco  Â·  3Comments