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

feat: add vmk services support #1855

Merged
merged 2 commits into from
Apr 26, 2023
Merged

feat: add vmk services support #1855

merged 2 commits into from
Apr 26, 2023

Conversation

zxinyu08
Copy link
Contributor

@zxinyu08 zxinyu08 commented Mar 15, 2023

Description

fix: Add support to enable services on a vmk

Support vnic enabled_services field. This feature is to support configuring the service of vnic. Current possible values are 'vmotion', 'management' and 'vsan'. Will expand scope in later version.

Testing Details:
We did end to end test from 3 standalone hosts based on the vSphere 7.0 and 8.0. The vnic can be created with different services enabled by running .tf file which contains the following settings, and the created vsan cluster is healthy.

variable "network_interfaces" {
  default = [
    "vmnic1",
  ]
}

resource "vsphere_distributed_virtual_switch" "vds" {
  name          = "vds-1"
  datacenter_id = data.vsphere_datacenter.dc.id

  uplinks         = ["uplink1", "uplink2", "uplink3", "uplink4"]
  active_uplinks  = ["uplink1", "uplink2"]
  standby_uplinks = ["uplink3", "uplink4"]

  host {
    host_system_id = data.vsphere_host.hosts.0.id
    devices        = "${var.network_interfaces}"
  }
  host {
    host_system_id = data.vsphere_host.hosts.1.id
    devices        = "${var.network_interfaces}"
  }
  host {
    host_system_id = data.vsphere_host.hosts.2.id
    devices        = "${var.network_interfaces}"
  }
}
resource "vsphere_distributed_port_group" "portgroup" {
  name                            = "pg-1"
  distributed_virtual_switch_uuid = resource.vsphere_distributed_virtual_switch.vds.id
}

resource "vsphere_vnic" "v1" {
  host                    = data.vsphere_host.hosts.0.id
  distributed_switch_port = resource.vsphere_distributed_virtual_switch.vds.id
  distributed_port_group  = vsphere_distributed_port_group.portgroup.id
  services = ["vsan","management","vmotion"]
  ipv4 {
    dhcp = true
  }
}

resource "vsphere_vnic" "v2" {
  host                    = data.vsphere_host.hosts.1.id
  distributed_switch_port = resource.vsphere_distributed_virtual_switch.vds.id
  distributed_port_group  = vsphere_distributed_port_group.portgroup.id
  services = ["vsan", "management", "vmotion"]
  ipv4 {
    dhcp = true
  }
}
resource "vsphere_vnic" "v3" {
  host                    = data.vsphere_host.hosts.2.id
  distributed_switch_port = resource.vsphere_distributed_virtual_switch.vds.id
  distributed_port_group  = vsphere_distributed_port_group.portgroup.id
  services = ["vsan", "management", "vmotion"]
  ipv4 {
    dhcp = true
  }
}

resource "vsphere_compute_cluster" "cluster" {
  name          = "cluster-1"
  datacenter_id = data.vsphere_datacenter.dc.id
  drs_enabled              = false
  ha_enabled               = false
  host_system_ids = "${data.vsphere_host.hosts.*.id}"

  vsan_enabled       = true

  depends_on = [
    vsphere_vnic.v1,
    vsphere_vnic.v2,
    vsphere_vnic.v3
  ]
}

Acceptance tests

  • Have you added an acceptance test for the functionality being added?
  • Have you run the acceptance tests on this branch?

Output from acceptance testing:

=== RUN   TestAccResourceVSphereVNic_services_valid
--- PASS: TestAccResourceVSphereVNic_services_valid (69.89s)
=== RUN   TestAccResourceVSphereVNic_services_invalid
--- PASS: TestAccResourceVSphereVNic_services_invalid (15.15s)
=== RUN   TestAccResourceVSphereVNic_services_nonDefaultNetstack
--- PASS: TestAccResourceVSphereVNic_services_nonDefaultNetstack (22.93s)

Release Note

Release note for CHANGELOG:

References

Closes #1594

@zxinyu08 zxinyu08 requested a review from a team as a code owner March 15, 2023 03:24
@github-actions github-actions bot added documentation Type: Documentation provider Type: Provider size/m Relative Sizing: Medium labels Mar 15, 2023
@tenthirtyam tenthirtyam added enhancement Type: Enhancement area/networking Area: Networking labels Mar 24, 2023
@tenthirtyam tenthirtyam added this to the v2.4.0 milestone Mar 24, 2023
@appilon appilon changed the title fix: Add support to enable services on a vmk feat: Add support to enable services on a vmk Mar 29, 2023
@tenthirtyam tenthirtyam changed the title feat: Add support to enable services on a vmk feat: add vmk services support Apr 18, 2023
@appilon appilon self-assigned this Apr 18, 2023
@appilon appilon mentioned this pull request Apr 19, 2023
2 tasks
Copy link
Contributor

@appilon appilon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the contribution. There are some changes that are needed, normally I would just highlight them in a review. Mainly we need to add acceptance tests testing the feature, although I managed to get the existing tests passing, they are not in a "sustainable" state, they were written using a pattern I'd like to move away from.

I'll make the necessary changes to this PR to get it merged.

@github-actions github-actions bot added the size/l Relative Sizing: Large label Apr 26, 2023
@appilon appilon merged commit e62bd61 into hashicorp:main Apr 26, 2023
Copy link
Contributor

@appilon appilon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@github-actions
Copy link

github-actions bot commented May 5, 2023

This functionality has been released in v2.4.0 of the Terraform Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions
Copy link

github-actions bot commented Jun 5, 2023

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 Jun 5, 2023
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/l Relative Sizing: Large size/m Relative Sizing: Medium
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support to enable services on a vmk
3 participants