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

enhance: Allow standby_nics as optional attribute #1695

Merged
merged 2 commits into from
Jul 26, 2022

Conversation

tenthirtyam
Copy link
Collaborator

Description

Allow standby_nics on r/vsphere_host_virtual_switch to be an optional attribute so the standby_nics = [] does not need to be defined when no standby NICs are required/available.

Release Note

resource/host_virtual_switch: Allow standby_nics on r/vsphere_host_virtual_switch to be an optional attribute so the standby_nics = [] does not need to be defined when no standby NICs are required/available.

References

Closes: #1690

Manual Tests

Current Method:

terraform {
  required_providers {
    vsphere = {
      source  = "local/hashicorp/vsphere"
      version = ">= 2.3.0"
    }
  }
  required_version = ">= 1.2.5"
}

provider "vsphere" {
  vsphere_server       = "m01-vc01.rainpole.io"
  user                 = "[email protected]"
  password             = "VMware1!"
  allow_unverified_ssl = true
}

data "vsphere_datacenter" "datacenter" {
  name = "dc-01"
}

data "vsphere_host" "host" {
  name          = "n-esxi01.rainpole.io"
  datacenter_id = data.vsphere_datacenter.datacenter.id
}

resource "vsphere_host_virtual_switch" "gh-1690" {
  name = "gh-1690"
  host_system_id = data.vsphere_host.host.id
  network_adapters = ["vmnic1","vmnic2","vmnic3"]
  active_nics  =  ["vmnic1"]
  standby_nics = []
}
terraform apply -auto-approve
data.vsphere_datacenter.datacenter: Reading...
data.vsphere_datacenter.datacenter: Read complete after 1s [id=datacenter-99086]
data.vsphere_host.host: Reading...
data.vsphere_host.host: Read complete after 0s [id=host-100004]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # vsphere_host_virtual_switch.gh-1690 will be created
  + resource "vsphere_host_virtual_switch" "gh-1690" {
      + active_nics              = [
          + "vmnic2",
        ]
      + allow_forged_transmits   = true
      + allow_mac_changes        = true
      + allow_promiscuous        = false
      + beacon_interval          = 1
      + check_beacon             = false
      + failback                 = true
      + host_system_id           = "host-100004"
      + id                       = (known after apply)
      + link_discovery_operation = "listen"
      + link_discovery_protocol  = "cdp"
      + mtu                      = 1500
      + name                     = "gh-1690"
      + network_adapters         = [
          + "vmnic1",
          + "vmnic2",
          + "vmnic3",
        ]
      + notify_switches          = true
      + number_of_ports          = 128
      + shaping_enabled          = false
      + standby_nics             = []
      + teaming_policy           = "loadbalance_srcid"
    }

Plan: 1 to add, 0 to change, 0 to destroy.
vsphere_host_virtual_switch.gh-1690: Creating...
vsphere_host_virtual_switch.gh-1690: Creation complete after 0s [id=tf-HostVirtualSwitch:host-100004:gh-1690]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

Results as expected.

New methods w/ standby_nic optional.

terraform {
  required_providers {
    vsphere = {
      source  = "local/hashicorp/vsphere"
      version = ">= 2.3.0"
    }
  }
  required_version = ">= 1.2.5"
}

provider "vsphere" {
  vsphere_server       = "m01-vc01.rainpole.io"
  user                 = "[email protected]"
  password             = "VMware1!"
  allow_unverified_ssl = true
}

data "vsphere_datacenter" "datacenter" {
  name = "dc-01"
}

data "vsphere_host" "host" {
  name          = "n-esxi01.rainpole.io"
  datacenter_id = data.vsphere_datacenter.datacenter.id
}

resource "vsphere_host_virtual_switch" "gh-1690" {
  name = "gh-1690"
  host_system_id = data.vsphere_host.host.id
  network_adapters = ["vmnic1","vmnic2","vmnic3"]
  active_nics  =  ["vmnic1"]
}
terraform apply -auto-approve
data.vsphere_datacenter.datacenter: Reading...
data.vsphere_datacenter.datacenter: Read complete after 1s [id=datacenter-99086]
data.vsphere_host.host: Reading...
data.vsphere_host.host: Read complete after 0s [id=host-100004]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # vsphere_host_virtual_switch.gh-1690 will be created
  + resource "vsphere_host_virtual_switch" "gh-1690" {
      + active_nics              = [
          + "vmnic1",
        ]
      + allow_forged_transmits   = true
      + allow_mac_changes        = true
      + allow_promiscuous        = false
      + beacon_interval          = 1
      + check_beacon             = false
      + failback                 = true
      + host_system_id           = "host-100004"
      + id                       = (known after apply)
      + link_discovery_operation = "listen"
      + link_discovery_protocol  = "cdp"
      + mtu                      = 1500
      + name                     = "gh-1690"
      + network_adapters         = [
          + "vmnic1",
          + "vmnic2",
          + "vmnic3",
        ]
      + notify_switches          = true
      + number_of_ports          = 128
      + shaping_enabled          = false
      + teaming_policy           = "loadbalance_srcid"
    }

Plan: 1 to add, 0 to change, 0 to destroy.
vsphere_host_virtual_switch.gh-1690: Creating...
vsphere_host_virtual_switch.gh-1690: Creation complete after 1s [id=tf-HostVirtualSwitch:host-100004:gh-1690]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

Results as expected.

Ryan Johnson
Senior Staff Solutions Architect | Product Engineering @ VMware, Inc.

Ryan Johnson added 2 commits July 20, 2022 13:49
Allow `standby_nic` on `r/vsphere_host_virtual_switch` to be an optional attribute so the `standby_nics = []` does not need to be defined when no standby NICs are required/available.

Resolves #1690

Signed-off-by: Ryan Johnson <[email protected]>
Allow `standby_nic` on `r/vsphere_host_virtual_switch` to be an optional attribute so the `standby_nics = []` does not need to be defined when no standby NICs are required/available.

Resolves #1690

Signed-off-by: Ryan Johnson <[email protected]>
@tenthirtyam tenthirtyam added enhancement Type: Enhancement size/xs Relative Sizing: Extra-Small area/networking Area: Networking labels Jul 20, 2022
@tenthirtyam tenthirtyam added this to the v2.3.0 milestone Jul 20, 2022
@tenthirtyam tenthirtyam requested a review from appilon July 20, 2022 19:26
@tenthirtyam tenthirtyam self-assigned this Jul 20, 2022
@github-actions github-actions bot added documentation Type: Documentation provider Type: Provider labels Jul 20, 2022
@tenthirtyam tenthirtyam added the needs-review Status: Pull Request Needs Review label Jul 20, 2022
@tenthirtyam tenthirtyam changed the title enhance: Allow standby_nic as optional attribute enhance: Allow standby_nics as optional attribute Jul 21, 2022
@tenthirtyam tenthirtyam removed the needs-review Status: Pull Request Needs Review label Jul 26, 2022
@tenthirtyam tenthirtyam merged commit 4617457 into main Jul 26, 2022
@tenthirtyam tenthirtyam deleted the enhance/vss_standy_nics branch July 26, 2022 02:00
tenthirtyam pushed a commit that referenced this pull request Jul 26, 2022
Updates `CHANGELOG.md` to include the enhancement provided in #1695.
@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/networking Area: Networking documentation Type: Documentation enhancement Type: Enhancement provider Type: Provider size/xs Relative Sizing: Extra-Small
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for vsphere_host_virtual_switch without standby_nics argument
2 participants