VMware Cloud Community
markdjones82
Expert
Expert

Detach_Lun "object" not found

All,

  Using Luc's detach function here: http://www.lucd.info/2011/11/25/lun-juggling-in-vsphere-5/

When I try ot detach one of my unmounted lun's by name it says it cannot find the object.  Any help?

http://www.twitter.com/markdjones82 | http://nutzandbolts.wordpress.com
0 Kudos
10 Replies
LucD
Leadership
Leadership

Does the CanonicalName you pass to the function appear in

Get-ScsiLun -VMHost YourEsxHostName | Select CanonicalName


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
markdjones82
Expert
Expert

Canonical LUN is actually showing the NAA id's instead of the name when i run that command

http://www.twitter.com/markdjones82 | http://nutzandbolts.wordpress.com
0 Kudos
LucD
Leadership
Leadership

And did you pass one of those NAA id's to the function ?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
markdjones82
Expert
Expert

Luc,

  Is the canonical name the NAA id and not the actual datastore name?  I was passing the actual name of the datastore as opposed ot NAA id is this not correct?

http://www.twitter.com/markdjones82 | http://nutzandbolts.wordpress.com
0 Kudos
LucD
Leadership
Leadership

Yes, in the function I filter out the LUN involved by ways of the LUN-id (that happens in the Where-clause).


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
markdjones82
Expert
Expert

Ah so canonical name is the datastore name or the naa id?  In theory i should be abel to do it by the datastore name right?

IE can i use this:

detach-disk -vmhost esx -CanonicalName datastore_name

or do I have to do this?

detach-disk -vmhost

$esx -CanonicalName naa.23049817123094871234901823

http://www.twitter.com/markdjones82 | http://nutzandbolts.wordpress.com
0 Kudos
LucD
Leadership
Leadership

The 2nd line


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
markdjones82
Expert
Expert

Ah i modiefied your function the other day to do NAA because i didn't realize that canonical is same as NAA id and it worked without this line: $lunUuid = (Get-ScsiLun -VmHost $VMHost where {$_.CanonicalName -eq $CanonicalName}).ExtensionData.Uuid

What is the purpose of the above line if it works without it?

Here is what i used the other day in a script i wrote

function

Detach-Disk{

param(

[

VMware.VimAutomation.ViCore.Impl.V1.Inventory.VMHostImpl]$VMHost,

[

string]$naa

)

$storSys = Get-View $VMHost.Extensiondata.ConfigManager.StorageSystem

$storSys.DetachScsiLun($naa)

}

http://www.twitter.com/markdjones82 | http://nutzandbolts.wordpress.com
0 Kudos
LucD
Leadership
Leadership

The DetachScsiLun method I use in the function requires a UUID as a parameter.

It's possible that for some types of storage this NAA is the same as the UUID, but on the storage where I tested my function, it wasn't.

Hence the Where-clause construction to get the correct UUID, starting from the CanonicalName


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
markdjones82
Expert
Expert

Ah understood, as always thanks for the help! Now to begin my mass detach of 100 luns from 50 systems lol

http://www.twitter.com/markdjones82 | http://nutzandbolts.wordpress.com
0 Kudos