VMware {code} Community
2smin
Contributor
Contributor

get VM - disk,sata,cdrom identifier

I'm using vcenter REST API (getVM) and each subresource of VM (such as disk, cdrom, sata_adapter....) has their own identifier.But i'm not sure what standard has been used to make those identifier.

such as .. 

"disks": {
        "2000": {
            "scsi": {
                "bus": 0,
                "unit": 0
            },
            "backing": {
                "vmdk_file": "[datastore3] test.vmdk",
                "type": "VMDK_FILE"
            },
            "label": "Hard disk 1",
            "type": "SCSI",
            "capacity": 322122547200
        },
        "2001": {
            "scsi": {
                "bus": 0,
                "unit": 1
            },
            "backing": {
                "vmdk_file": "[datastore3] ex1.vmdk",
                "type": "VMDK_FILE"
            },
            "label": "Hard disk 2",
            "type": "SCSI",
            "capacity": 17179869184
        },
        "2002": {
            "scsi": {
                "bus": 0,
                "unit": 2
            },
            "backing": {
                "vmdk_file": "[datastore3] ex.vmdk",
                "type": "VMDK_FILE"
            },
            "label": "Hard disk 3",
            "type": "SCSI",
            "capacity": 21474836480
        }
    }
"sata_adapters": {
    "15000": {
        "bus": 0,
        "pci_slot_number": 33,
        "label": "SATA controller 0",
        "type": "AHCI"
    }
}

which order has been used for those identifier (key: 2000~2.15000)?

Labels (1)
Reply
0 Kudos
1 Reply
doskiran
Enthusiast
Enthusiast

Each sub-resource in a virtual machine (such as disk, cdrom, sata_adapter....) is also called a VirtualDevice.
i.e, 
 
VirtualDevice = VirtualDisk, VirtualCdrom, VirtualController,  VirtualEthernetCard, VirtualFloppy, VirtualKeyboard, VirtualMachineVideoCard, VirtualPCIPassthrough, VirtualSerialPort, VirtualSoundCard, VirtualTPM, VirtualUSB , .... and more
 
Every VirtualDevice has a unique "key" that distinguishes this device from other devices in the same virtual machine.
 
i.e,

 

Key( integer ) = A unique key that distinguishes this device from other devices in the same virtual machine. Keys are immutable but may be recycled; that is, a key does not change as long as the device is associated with a particular virtual machine. However, once a device is removed, its key may be used when another device is added.
This property is not read-only, but the client cannot control its value. Persistent device keys are always assigned and managed by the server, which guarantees that all devices will have non-negative key values.
 
When adding new devices, it may be necessary for a client to assign keys temporarily in order to associate controllers with devices in configuring a virtual machine. However, the server does not allow a client to reassign a device key, and the server may assign a different value from the one passed during configuration. Clients should ensure that existing device keys are not reused as temporary key values for the new device to be added (for example, by using unique negative integers as temporary keys).
 
When editing or deleting a device, clients must use the server-provided key to refer to an existing device.

 

 
Virtualdevice Keys:
device[100]  =   VirtualPCIController
device[200]  =   VirtualIDEController
device[300]  =   VirtualPS2Controller
device[400]  =   VirtualSIOController
device[500]  =   VirtualMachineVideoCard
device[600]  =   VirtualKeyboard
.
.
device[3000] =   VirtualCdrom
device[2000] =   VirtualDisk
.
.
.
 
Eg:  Multiple disks in a VM with device keys
 
Hard Disk 1  = device[2000] =   VirtualDisk
Hard Disk 2 = device[2001]  =   VirtualDisk
Hard Disk 3 = device[2002] =   VirtualDisk
 
For more info refer :
Reply
0 Kudos