VMware

This Question is Answered

1 "correct" answer available (10 pts) 2 "helpful" answers available (6 pts)
6 Replies Last post: Nov 10, 2009 8:14 AM by catman  

PowerCLI - Datastores and LUNs.... Argh!!! posted: Nov 3, 2009 1:15 PM

Click to view catman's profile Novice 6 posts since
Jun 2, 2005
Hello

I am new to vSphere PowerCLI (just over a month of dabbling), and I'm building up a script that we can use to perform various operations.

My current hurdle is how to find out what LUN a datastore is on. The vSphere Client shows this data with apparent ease.

I can obviously get info for a datastore:

$objDataStore = get-datastore -name "PLOEVA01_VMFS_001"

$objDataStore | Format-List

FreeSpaceMB : 467655
CapacityMB : 511744
Accessible : True
Type : VMFS
Id : Datastore-datastore-113
Name : PLOEVA01_VMFS_001

...and I can then get a .NET view, and delve a bit deeper:

$objDataStoreView = Get-View -id $objDataStore.id
$objDataStoreView


Info : VMware.Vim.VmfsDatastoreInfo
Summary : VMware.Vim.DatastoreSummary
Host : {VMware.Vim.ManagedObjectReference, VMware.Vim.ManagedObjectReference}
Vm : {VMware.Vim.ManagedObjectReference, VMware.Vim.ManagedObjectReference, VMware.Vim.ManagedObjectRe
ference, VMware.Vim.ManagedObjectReference}
Browser : VMware.Vim.ManagedObjectReference
Capability : VMware.Vim.DatastoreCapability
Parent : VMware.Vim.ManagedObjectReference
CustomValue : {}
OverallStatus : green
ConfigStatus : gray
ConfigIssue : {}
EffectiveRole : {-1, 5}
Permission : {}
Name : PLOEVA01_VMFS_001
DisabledMethod : {}
RecentTask : {}
DeclaredAlarmState : {alarm-9.datastore-113}
TriggeredAlarmState : {}
AlarmActionsEnabled : True
Tag : {}
Value : {}
AvailableField : {}
MoRef : VMware.Vim.ManagedObjectReference
Client : VMware.Vim.VimClient

...the Info and Summary properties give some additional info:

$objDataStoreView.info

Vmfs : VMware.Vim.HostVmfsVolume
Name : PLOEVA01_VMFS_001
Url : sanfs://vmfs_uuid:4a6daf9a-fde9d1f2-ee8b-001b784495e2/
FreeSpace : 490371809280
MaxFileSize : 274877906944
Timestamp : 03/11/2009 14:18:46
DynamicType :
DynamicProperty :

$objDataStoreView.summary

Datastore : VMware.Vim.ManagedObjectReference
Name : PLOEVA01_VMFS_001
Url : sanfs://vmfs_uuid:4a6daf9a-fde9d1f2-ee8b-001b784495e2/
Capacity : 536602476544
FreeSpace : 490371809280
Uncommitted : 8694775296
Accessible : True
MultipleHostAccess : True
Type : VMFS
DynamicType :
DynamicProperty :

...but I just cannot find a correlation between this and a LUN. In desperation, I knocked up a routine (below) which enumerates the fibre HBAs in a given host, enumerates the visible LUNs, then the paths, picks the active paths and reports any paths that lead to a fibre disk. The last step would be to list the datastores on this disk. But how?

Any thoughts... anyone?

Thank you

Simon Catlin
http://communities.vmware.com/images/emoticons/cry.gif



MY FUNCTION FOR ENUMERATING A HOST'S STORAGE:

<See EXAMPLE_CODE.TXT attachment>

EXAMPLE OUTPUT:

<See EXAMPLE_OUTPUT.txt attachment>

Attachments:

Re: PowerCLI - Datastores and LUNs.... Argh!!!

2. Nov 3, 2009 2:29 PM in response to: catman
Click to view monahancj's profile Lurker 2 posts since
Feb 9, 2007

Not sure if this is what you're asking for, but here's my guess.

$t = get-vmhost -datastore datastorename | Select-Object -Last 1 -Property Name
get-scsilun -vmhost $t.name | format-table -autosize


CanonicalName ConsoleDeviceName LunType CapacityMB MultipathP
olicy


-----------------
----------
vmhba1:0:13 /vmfs/devices/disks/vml.02000d00006006016041561a00b82d742836f0dc11524149442035 disk 1099247 MostRec...
vmhba1:0:4 /vmfs/devices/disks/vml.02000400006006016041561a00fc1f387733f0dc11524149442035 disk 1099247 MostRec...
vmhba1:0:8 /vmfs/devices/disks/vml.02000800006006016041561a007c1b9e9533f0dc11524149442035 disk 1099247 MostRec...
vmhba1:0:11 /vmfs/devices/disks/vml.02000b00006006016041561a00f2da0ef537f0dc11524149442035 disk 824435 MostRec...

Re: PowerCLI - Datastores and LUNs.... Argh!!!

5. Nov 10, 2009 6:06 AM in response to: catman
Click to view monahancj's profile Lurker 2 posts since
Feb 9, 2007

Catman, would you post the solution please? Thanks.


VMware Developer

SDKs, APIs, Videos, Learn and much more in the Developer community.

Learn More

Developer Sample Code

Increase your developer productivity with VMware API sample code.

Learn More

VMworld Sessions & Labs

Online access to the latest VMworld Sessions & Labs and online services.

Learn more

Purchase PSO Credits Online

Purchase credits to redeem training and consulting services online.

Buy Now

Community Hardware Software

View reported configurations or report your own.

Learn More

VMware vSphere

Come witness the next giant leap in virtualization.

Register Today

Communities