Skip to content

Instantly share code, notes, and snippets.

@Syuparn
Created July 10, 2021 13:23
Show Gist options
  • Save Syuparn/f85d8ebb9a7d1a9d7a1c816f45ba29c7 to your computer and use it in GitHub Desktop.
Save Syuparn/f85d8ebb9a7d1a9d7a1c816f45ba29c7 to your computer and use it in GitHub Desktop.
Reveal the VCSIM UUIDs!

Reveal the VCSIM UUIDs!

About

This note briefly shows how vcsim generates object's UUID.

⚠️ This note is based on vcsim (govmomi) 0.26.0. The latest version might work differently.

Algorithm

input string to generate UUID

  • In order to call uuid.NewSHA1 easily, simple CLI Syuparn/sha1uuid5 is used.
  • vcsim runs without any options
$ vcsim
# another console
$ export GOVC_URL=https://user:pass@127.0.0.1:8989/sdk
$ export GOVC_INSECURE=true

VM UUIDs

$ govc vm.info -json DC0/vm/DC0_C0_RP0_VM0 | jq '.VirtualMachines[].Config | {VmPathName: .Files.VmPathName, Uuid: .Uuid, InstanceUuid: .InstanceUuid}'
{
  "VmPathName": "[LocalDS_0] DC0_C0_RP0_VM0/DC0_C0_RP0_VM0.vmx",
  "Uuid": "cd0681bf-2f18-5c00-9b9b-8197c0095348",
  "InstanceUuid": "bfff331f-7f07-572d-951e-edd3701dc061"
}

# vm UUID
$ echo "[LocalDS_0] DC0_C0_RP0_VM0/DC0_C0_RP0_VM0.vmx" | sha1uuid5
cd0681bf-2f18-5c00-9b9b-8197c0095348
# InstanceUUID
$ echo "[LocalDS_0] DC0_C0_RP0_VM0/DC0_C0_RP0_VM0.vmx" | tr '[:lower:]' '[:upper:]' | sha1uuid5
bfff331f-7f07-572d-951e-edd3701dc061

Host

$ govc host.info -json /DC0/host/DC0_H0 | jq '.HostSystems[].Hardware.SystemInfo.Uuid'
"dcf7fb3c-4a1c-5a05-b730-5e09f3704e2f"
$ echo DC0_H0 | sha1uuid5 
dcf7fb3c-4a1c-5a05-b730-5e09f3704e2f

Disk

$ govc device.info -json -vm DC0/vm/DC0_C0_RP0_VM0 disk-* | jq '.Devices[].Backing | {FileName: .FileName, Uuid: .Uuid}'
{
  "FileName": "[LocalDS_0] DC0_C0_RP0_VM0/disk1.vmdk",
  "Uuid": "be8d2471-f32e-5c7e-a89b-22cb8e533890"
}
$ govc datacenter.info -json | jq '.Datacenters[].Self'
{
  "Type": "Datacenter",
  "Value": "datacenter-2"
}
$ echo "Datacenter:datacenter-2[LocalDS_0] DC0_C0_RP0_VM0/disk1.vmdk" | sha1uuid5 
be8d2471-f32e-5c7e-a89b-22cb8e533890
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment