LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Virtualization and Cloud
User Name
Password
Linux - Virtualization and Cloud This forum is for the discussion of all topics relating to Linux Virtualization and Linux Cloud platforms. Xen, KVM, OpenVZ, VirtualBox, VMware, Linux-VServer and all other Linux Virtualization platforms are welcome. OpenStack, CloudStack, ownCloud, Cloud Foundry, Eucalyptus, Nimbus, OpenNebula and all other Linux Cloud platforms are welcome. Note that questions relating solely to non-Linux OS's should be asked in the General forum.

Notices



Reply
 
Search this Thread
Old 11-01-2013, 09:51 AM   #1
merana
Member
 
Registered: May 2002
Location: Philly/So. Jersey
Distribution: ESXi CentOS Red-Hat Ubuntuu Solaris Debian
Posts: 80

Rep: Reputation: 15
Question * SOLVED * - LUN Masking on ESXi


Hi All.

This post is relevant to LUN masking on an ESXi Host per this KB (1009449).

I've managed to hack out this ugly snippet that will almost auto generate the claimrule code if you know the naa.x id of the Volume to be masked.

Code:
esxcfg-mpath -L | awk '/naa.600601609d381800eee88f0ee9edde11/{print $1}' | sort | awk -F: '{hba=$1,tgt=substr($3,2,1),lun=substr($4,2,2);print "esxcli corestorage claimrule add --rule 129 -t location -A " hba " -T " tgt " -L " lun " -P MASK_PATH"}'
Yeah. It's really ugly. BUT it is really helpful when you have to do the task on over 50 blades...

That snippet will generate the following:

Code:
esxcli corestorage claimrule add --rule 129 -t location -A vmhba1 -T 0 -L 90 -P MASK_PATH
esxcli corestorage claimrule add --rule 129 -t location -A vmhba1 -T 1 -L 90 -P MASK_PATH
esxcli corestorage claimrule add --rule 129 -t location -A vmhba2 -T 0 -L 90 -P MASK_PATH
esxcli corestorage claimrule add --rule 129 -t location -A vmhba2 -T 1 -L 90 -P MASK_PATH
Now, the only thing I have to figure out is how to get the --rule number to automatically increment. Is there a way to do this inline or must I breakdown and actually create a script to do this?

Thanks in advance for any suggestions or comments.

Last edited by merana; 11-11-2013 at 02:20 PM.
 
Old 11-06-2013, 03:59 PM   #2
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,013

Rep: Reputation: 83
Are you after something that creates:
Code:
esxcli corestorage claimrule add --rule 129 -t location -A vmhba1 -T 0 -L 90 -P MASK_PATH
esxcli corestorage claimrule add --rule 130 -t location -A vmhba1 -T 1 -L 90 -P MASK_PATH
esxcli corestorage claimrule add --rule 131 -t location -A vmhba2 -T 0 -L 90 -P MASK_PATH
esxcli corestorage claimrule add --rule 132 -t location -A vmhba2 -T 1 -L 90 -P MASK_PATH
If so, you could try adding a "BEGIN" section to the awk statement to initialise a counter and then increment it for each line.

untested:
Code:
awk -F: 'BEGIN { count=128 }{count++; hba=$1,tgt=substr($3,2,1),lun=substr($4,2,2);print "esxcli corestorage claimrule add --rule " count " -t location -A " hba " -T " tgt " -L " lun " -P MASK_PATH"}'

Last edited by Disillusionist; 11-06-2013 at 06:06 PM.
 
Old 11-11-2013, 02:19 PM   #3
merana
Member
 
Registered: May 2002
Location: Philly/So. Jersey
Distribution: ESXi CentOS Red-Hat Ubuntuu Solaris Debian
Posts: 80

Original Poster
Rep: Reputation: 15
The fix

Hi Dis!

Thanks for that example.

I got it to work using the following:

Code:
LUN_ID=`esxcfg-scsidevs -m | grep LM_VMFS10 | awk '{print $1}' | cut -d':' -f1`
esxcfg-mpath -L | grep $LUN_ID | awk -F: 'BEGIN { count=128 }{count++; hba=$1,tgt=substr($3,2,1),lun=substr($4,2,2);print "esxcli corestorage claimrule add --rule " count " -t location -A " hba " -T " tgt " -L " lun " -P MASK_PATH"}'
This correctly creates the required rules:

Code:
esxcli corestorage claimrule add --rule 129 -t location -A vmhba2 -T 0 -L 90 -P MASK_PATH
esxcli corestorage claimrule add --rule 130 -t location -A vmhba2 -T 1 -L 90 -P MASK_PATH
esxcli corestorage claimrule add --rule 131 -t location -A vmhba1 -T 0 -L 90 -P MASK_PATH
esxcli corestorage claimrule add --rule 132 -t location -A vmhba1 -T 1 -L 90 -P MASK_PATH
Thanks for the suggestion and example!
 
  


Reply

Tags
cli, esxi, lun, vmware


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Replacing 200 GB LUN with 100 GB LUN in LVM rajaniyer123 Linux - Enterprise 4 03-27-2012 01:32 PM
LXer: Upgrade/Migrate VMware ESX/ESXi 4.x To ESXi 5.0 LXer Syndicated Linux News 0 09-11-2011 04:10 PM
RAID card for vmware esxi, and some other esxi questions JustinHoMi Linux - Enterprise 1 06-04-2010 04:57 PM
LUN Device Mapping: 2 devices map to same lun DantePasquale Linux - Distributions 0 09-24-2007 03:59 PM
ip masking hegedus Linux - Networking 5 06-15-2006 07:48 PM


All times are GMT -5. The time now is 03:30 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration