VMware {code} Community
venkat70
Contributor
Contributor

Finding a ScsiLun.Lun using key

hi,

i'm getting a ScsiLun key as below.

MultipathInfo mpinfo = HostSystem.getConfig().getStorageDevice().getMultipathInfo();

LogicalUnit[] luns =mpinfo.getLun();

now for each LogicalUnit

i'm getting LogicalUnit.getLun(). it gives the ScsiLun key like "key-vim.host.ScsiDisk-vmhba2:0:9".

if i need to get ScsiLun attributes like the logical unit number of the lun, i need to get the ScsiTopology.Lun.

how do i get there with the key i got earlier. i can't do findEntities as ScsiTopology.Lun is not a ManagedEntity.

should i cache all the Luns from ScsiTopology first and then do a lookup when i get a ScsiLun key?

the basic question is if i have a key for non ManagedEntity, how do i get the object with a lookup or it's not possible?

thanks

venkat

Reply
0 Kudos
3 Replies
admin
Immortal
Immortal

// use the key in LogicalUnit and look up the lun here

ScsiLun[] luns = HostSystem.getConfig().getStorageDevice().getScisiLun();

core API and toolkits team

venkat70
Contributor
Contributor

no. ScsiLun doesn't have all the information. ScsiTopology.Lun only has the logical unit number of the SCSI logical unit.

i figure out a way to do this efficiently.

thanks

venkat

Reply
0 Kudos
venkat70
Contributor
Contributor

hi,

i have a related question. i'm trying to find the device wwn associated with a scsi lun.

it is there in ScsiTopology.Lun.getKey(). but it is part of a bigger string. i'm trying to figure out the format of the string to parse out the wwn.

Here's a sample.

02001b0000600601601f20220048b0e0a6720fde11524149442035

i tried to guess this string

0200 1b 0000 600601601f20220048b0e0a6720fde11 524149442035

1b is the lun because getLun() gives me 27. so, in hex it's 1b. The bold part is wwn(world wide name of the scsi lun). i'm not sure what's the last part.

my question is if i skip first 10 bytes and last 12 bytes, the rest in the middle is wwn?

i think more documentation on the format of these keys will help as these keys have some useful information buried(in this case device wwn).

thanks

venkat

Reply
0 Kudos