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 usb controller #2280

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
# <!-- markdownlint-disable first-line-h1 no-inline-html -->

## .Next (Not Released)
## 2.11.0 (Not Released)

IMPROVEMENTS:

- `resource/distributed_virtual_switch`: Added support for vSphere distributed switch version `8.0.3` in vSphere 8.0 U3. [(2306](https://github.com/hashicorp/terraform-provider-vsphere/pull/2306))
- `resource/distributed_virtual_switch`: Added support for vSphere distributed switch version `8.0.3` in vSphere 8.0 U3.
[(2306](https://github.com/hashicorp/terraform-provider-vsphere/pull/2306))

FEATURES:

- `resource/vsphere_virtual_machine`: Adds ability to add `usb_controller` to virtual machine on creation or clone.
[#2280](https://github.com/hashicorp/terraform-provider-vsphere/pull/2280)
- `data/vsphere_virtual_machine`: Adds ability read `usb_controller` on virtual machine; will return `true` or `false` based on the configuration.
[#2280](https://github.com/hashicorp/terraform-provider-vsphere/pull/2280)

CHORE:

- `provider`: Updated `golang/go` to v1.22.8.
([#2289](https://github.com/terraform-providers/terraform-provider-vsphere/pull/2289))


## 2.10.0 (October 16, 2024)

FEATURES:
Expand Down
32 changes: 32 additions & 0 deletions vsphere/data_source_vsphere_virtual_machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,20 @@ func dataSourceVSphereVirtualMachine() *schema.Resource {
Computed: true,
Description: "Indicates whether a virtual Trusted Platform Module (TPM) device is present on the virtual machine.",
},
"usb_controller": {
Type: schema.TypeList,
Computed: true,
Description: "List of virtual USB controllers present on the virtual machine, including their versions.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"version": {
Type: schema.TypeString,
Computed: true,
Description: "The version of the USB controller.",
},
},
},
},
}

// Merge the VirtualMachineConfig structure so that we can include the number of
Expand Down Expand Up @@ -298,6 +312,24 @@ func dataSourceVSphereVirtualMachineRead(d *schema.ResourceData, meta interface{
}
_ = d.Set("vtpm_present", isVTPMPresent)

var usbControllers []map[string]interface{}
for _, dev := range props.Config.Hardware.Device {
switch dev.(type) {
case *types.VirtualUSBController:
usbControllers = append(usbControllers, map[string]interface{}{
"version": "2.x",
})
case *types.VirtualUSBXHCIController:
usbControllers = append(usbControllers, map[string]interface{}{
"version": "3.x",
})
}
}

if err := d.Set("usb_controller", usbControllers); err != nil {
return fmt.Errorf("error setting usb_controller: %s", err)
}

log.Printf("[DEBUG] VM search for %q completed successfully (UUID %q)", name, props.Config.Uuid)
return nil
}
Loading
Loading