VMware Cloud Community
opdude
Contributor
Contributor

Disconnecting USB device via SSH

Hey,

I'm currently attempting to connect and disconnect USB devices via a script, however I'm finding it difficult to produce the USB id information for both commands. So far I have worked out that I can use the usb id from lsusb to connect the device but I am unable to use that from the disconnect command, which seems to only take the path information that esxi is creating. Is there any way to work out what the path for the usb will be before it's connected to a VM?

I've tried using lsusb -v and guessing at which of those values are the pointing at the path but I can only get the first and last number from that, the second number doesn't seem to correlate to anything in that output.

I've modified the ID's a little but this the basic information I have

Example:

Get the device ID from lsusb

lsusb

Bus 02 Device 04: ID 1111:2222 Google Inc.

Connect the USB (this works just fine)

vim-cmd vmsvc/device.connusbdev 1 "0x1111:0x2222"

Here I can get the path but I would like to get this before I connect it to a VM as the value is stored elsewhere

vim-cmd vmsvc/device.getdevices 1 | grep  path

deviceName = "path:2/4 version:2",

This one fails

vim-cmd vmsvc/device.dissconnusbdev 1 "0x1111:0x2222"

This one passes

vim-cmd vmsvc/device.dissconnusbdev 1 "path:2/4 version:2"

Thanks,

Daniel Hobley

Tags (3)
Reply
0 Kudos
0 Replies