Exports Cleanup

587 views
Skip to first unread message

Andrew Stack

unread,
May 10, 2013, 2:51:19 PM5/10/13
to isilon-u...@googlegroups.com
Hello,

I'm wondering if anyone has figured out a way to delete a single host from several random exports at once?  Say you have 100 exports and you decommission a host that is exported to 50 of the 100.

Currently, I'd find the export ID: 

isi nfs export list -v | grep 'Export\|sonasdm03'

Export 10: 
           host sonasdm03
Export 12: 
           host sonasdm03
Export 13: 
           host sonasdm03

Then I'd delete it as below....

Example:

nas-rwc-is4-40# isi nfs exports modify -i 11 --delete-client=sonasdm03
Warning (export still modified): bad hostname sonasdm03
nas-rwc-is4-40# isi nfs exports modify -i 12 --delete-client=sonasdm03
Warning (export still modified): bad hostname sonasdm03
nas-rwc-is4-40# isi nfs exports modify -i 13 --delete-client=sonasdm03
Warning (export still modified): bad hostname sonasdm03

like watching paint dry but somehow worse...

Anyways, just curious is anyone has scripted a process to alleviate the tedium...if so please share.  

Thanks in advance.

--
Andrew Stack
Sr. Storage Administrator

scott

unread,
May 14, 2013, 7:41:41 PM5/14/13
to isilon-u...@googlegroups.com
I'm wondering if anyone has figured out a way to delete a single host from several random exports at once?  Say you have 100 exports and you decommission a host that is exported to 50 of the 100.

 
You could do something like:
#!/bin/bash
if [[ $1 == "" ]]; then
   echo
   echo "usage $0 [hostname to remove]"
   echo
   exit 99
fi
# look at 'nfs exports list' output.  Grab the lines that start
# with numbers.  These are the rule identifiers.
for rule in $(isi nfs exports list |egrep '^ *[1-9]'|awk '{print $1}')
do
 isi nfs exports list -i $rule -v  |grep $1 >/dev/null >1
 if [[ $? == 0 ]]; then
    echo "isi nfs exports modify -i $rule --delete-client=$1"
 fi
done
 
...
Run it like so:
 
mbisilon-1# ./remove-host-from-share.sh helium.multicare.org
isi nfs exports modify -i 7 --delete-client=helium.multicare.org
isi nfs exports modify -i 8 --delete-client=helium.multicare.org
 
I left the delete commands echoed out.  This would work for my environment but obviously would want to understand & test in your environment. 
 

Trinh Tran

unread,
May 14, 2013, 9:12:15 PM5/14/13
to isilon-u...@googlegroups.com
Hi Andrew, we can script it. Let me find some free time. Trinh

Sent from my iPhone
--
You received this message because you are subscribed to the Google Groups "Isilon Technical User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to isilon-user-gr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Trinh Tran

unread,
May 22, 2013, 6:35:55 PM5/22/13
to isilon-u...@googlegroups.com
Hi Scott,

I have modify your script into this.  I commented out the execution line.


for rule in $(isi nfs exports list |egrep '^ *[1-9]'|awk '{print $1}')
do
 for host in $(isi nfs exports list -i $rule -r -v  | tr '\[' '\n' | grep ^host | cut -d\] -f1 | awk -F ' ' '{print $2}')
   do
      echo -e "\tBad hostname $host found."
      #Run an nslookup on that hostname to make sure it doesn't return an ip address
      #return 0 if selected lines are found, in this case no ip found result is not 0
      nslookup $host | grep Add | grep -v "#"
      if [[ $? != 0 ]]; then
           echo -e "\tNSLOOKUP on $host failed, $host have no IP"
           echo "Removing client $host from export number $rule"
           #isi nfs exports modify -i $rule --delete-client=$host
      fi
   done
done


Trinh
Reply all
Reply to author
Forward
0 new messages