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

Set-VMSwitch fails when modify. #58

Closed
RBadeloe opened this issue Mar 28, 2021 · 6 comments
Closed

Set-VMSwitch fails when modify. #58

RBadeloe opened this issue Mar 28, 2021 · 6 comments

Comments

@RBadeloe
Copy link

Hi there,

I am testing this main.tf on my lab environment with Hyper-V installed.
When I apply the plan at certain moment it stops. This is the error:
Error: run command operation returned code=1
stderr:

stdOut:
Set-VMSwitch : Failed while modifying virtual Ethernet switch connection settings.
At C:\Users\Administrator\AppData\Local\Temp\shell-terraform-1qOARATLNPcbVtvz0wmRsxrSQxY.ps1:52 char:1

  • Set-VMSwitch @SetVmSwitchArgs
  •   + CategoryInfo          : NotSpecified: (:) [Set-VMSwitch], VirtualizationException
      + FullyQualifiedErrorId : OperationFailed,Microsoft.HyperV.PowerShell.Commands.SetVMSwitch
    
    on main.tf line 23, in resource "hyperv_network_switch" "dmz_network_switch":
    23: resource "hyperv_network_switch" "dmz_network_switch" {
    
    

I am using terraform:
Terraform v0.14.9

  • provider registry.terraform.io/taliesins/hyperv v1.0.3

Terraform is new for my so I'n not sure what I am doing wrong.
Regards,

Robert

@Appa-lw
Copy link

Appa-lw commented Jun 30, 2021

Hey there,

it seems like the powershell command is broken. As soon as you apply the vmmq or vrrs parameters powershell throws that error.

Any chance, that we can disable these parameters in this provider?

My Setup:

  • Terraform 1.0.1
  • taliesins/hyperv v1.0.3
  • Windows Server 2019 (build 17763.1999)

Best regards
Lukas

@taliesins
Copy link
Owner

@Appa-lw and @RBadeloe does your nic support this feature? Are you able to setup this up manually in the hyperv gui?

@Br4v3St4rr
Copy link

Yeah it seems that it will fail if your Nic doesn't support it.

Changing the:
Set-VMSwitch @SetVmSwitchArgs

to

Set-VMSwitch @SetVmSwitchArgs -ErrorAction SilentlyContinue | Out-Null

Seems to stop the error and still succeed on the other splatted resources. Not sure if that's good practice or not but it works.

@stuartgillibrand
Copy link

I am getting the same error running the examples (i.e. a basic internal switch):

provider "hyperv" {
  # Configuration options
  user = "XXX"
  password = "YYY"
  host = "localhost"
  port = 5985
  https = false
}

resource "hyperv_network_switch" "dmz_network_switch" {
  name = "dmz"
}

results in:

Terraform will perform the following actions:

  # hyperv_network_switch.dmz_network_switch will be created
  + resource "hyperv_network_switch" "dmz_network_switch" {
      + allow_management_os                     = true
      + default_flow_minimum_bandwidth_absolute = 0
      + default_flow_minimum_bandwidth_weight   = 0
      + default_queue_vmmq_enabled              = false
      + default_queue_vmmq_queue_pairs          = 1
      + default_queue_vrss_enabled              = false
      + enable_embedded_teaming                 = false
      + enable_iov                              = false
      + enable_packet_direct                    = false
      + id                                      = (known after apply)
      + minimum_bandwidth_mode                  = "None"
      + name                                    = "dmz"
      + switch_type                             = "Internal"
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

hyperv_network_switch.dmz_network_switch: Creating...
╷
│ Error: run command operation returned code=1
│ stderr:
│
│ stdOut:
│ Set-VMSwitch : Failed while modifying virtual Ethernet switch connection settings.
│ At C:\Users\Administrator\AppData\Local\Temp\shell-terraform-2HHh0ODwgTqUlS2AjnUU0OwI7RE.ps1:52 char:1
│ + Set-VMSwitch @SetVmSwitchArgs
│ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
│     + CategoryInfo          : NotSpecified: (:) [Set-VMSwitch], VirtualizationException
│     + FullyQualifiedErrorId : OperationFailed,Microsoft.HyperV.PowerShell.Commands.SetVMSwitch
│
│   with hyperv_network_switch.dmz_network_switch,
│   on test.tf line 19, in resource "hyperv_network_switch" "dmz_network_switch":
│   19: resource "hyperv_network_switch" "dmz_network_switch" {

@mattgagliardi
Copy link

Same boat here.

@taliesins
Copy link
Owner

Should be closed by #239

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

No branches or pull requests

6 participants