@@ -170,6 +170,20 @@ func dataSourceVSphereVirtualMachine() *schema.Resource {
170
170
Computed : true ,
171
171
Description : "Indicates whether a virtual Trusted Platform Module (TPM) device is present on the virtual machine." ,
172
172
},
173
+ "usb_controller" : {
174
+ Type : schema .TypeList ,
175
+ Computed : true ,
176
+ Description : "List of virtual USB controllers present on the virtual machine, including their versions." ,
177
+ Elem : & schema.Resource {
178
+ Schema : map [string ]* schema.Schema {
179
+ "version" : {
180
+ Type : schema .TypeString ,
181
+ Computed : true ,
182
+ Description : "The version of the USB controller." ,
183
+ },
184
+ },
185
+ },
186
+ },
173
187
}
174
188
175
189
// Merge the VirtualMachineConfig structure so that we can include the number of
@@ -298,6 +312,24 @@ func dataSourceVSphereVirtualMachineRead(d *schema.ResourceData, meta interface{
298
312
}
299
313
_ = d .Set ("vtpm_present" , isVTPMPresent )
300
314
315
+ var usbControllers []map [string ]interface {}
316
+ for _ , dev := range props .Config .Hardware .Device {
317
+ switch dev .(type ) {
318
+ case * types.VirtualUSBController :
319
+ usbControllers = append (usbControllers , map [string ]interface {}{
320
+ "version" : "2.x" ,
321
+ })
322
+ case * types.VirtualUSBXHCIController :
323
+ usbControllers = append (usbControllers , map [string ]interface {}{
324
+ "version" : "3.x" ,
325
+ })
326
+ }
327
+ }
328
+
329
+ if err := d .Set ("usb_controller" , usbControllers ); err != nil {
330
+ return fmt .Errorf ("error setting usb_controller: %s" , err )
331
+ }
332
+
301
333
log .Printf ("[DEBUG] VM search for %q completed successfully (UUID %q)" , name , props .Config .Uuid )
302
334
return nil
303
335
}
0 commit comments