@@ -165,6 +165,20 @@ func dataSourceVSphereVirtualMachine() *schema.Resource {
165
165
Computed : true ,
166
166
Description : "Instance UUID of this virtual machine." ,
167
167
},
168
+ "usb_controller" : {
169
+ Type : schema .TypeList ,
170
+ Computed : true ,
171
+ Description : "List of virtual USB controllers present on the virtual machine, including their versions." ,
172
+ Elem : & schema.Resource {
173
+ Schema : map [string ]* schema.Schema {
174
+ "version" : {
175
+ Type : schema .TypeString ,
176
+ Computed : true ,
177
+ Description : "The version of the USB controller." ,
178
+ },
179
+ },
180
+ },
181
+ },
168
182
}
169
183
170
184
// Merge the VirtualMachineConfig structure so that we can include the number of
@@ -283,6 +297,26 @@ func dataSourceVSphereVirtualMachineRead(d *schema.ResourceData, meta interface{
283
297
return fmt .Errorf ("error setting guest IP addresses: %s" , err )
284
298
}
285
299
}
300
+
301
+ var usbControllers []map [string ]interface {}
302
+
303
+ for _ , dev := range props .Config .Hardware .Device {
304
+ switch dev .(type ) {
305
+ case * types.VirtualUSBController :
306
+ usbControllers = append (usbControllers , map [string ]interface {}{
307
+ "version" : "2.x" ,
308
+ })
309
+ case * types.VirtualUSBXHCIController :
310
+ usbControllers = append (usbControllers , map [string ]interface {}{
311
+ "version" : "3.x" ,
312
+ })
313
+ }
314
+ }
315
+
316
+ if err := d .Set ("usb_controller" , usbControllers ); err != nil {
317
+ return fmt .Errorf ("error setting usb_controller: %s" , err )
318
+ }
319
+
286
320
log .Printf ("[DEBUG] VM search for %q completed successfully (UUID %q)" , name , props .Config .Uuid )
287
321
return nil
288
322
}
0 commit comments