Created
May 1, 2011 15:15
-
-
Save res0nat0r/950563 to your computer and use it in GitHub Desktop.
Add SAN disks to VxVM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
use Getopt::Std; | |
getopt('dig', \%opts); | |
die("\nUsage: $0 -d <file with disks to add> -i <file with inq output> -g <diskgroup name>\n\n") | |
unless (defined $opts{d} && $opts{i} && $opts{g}); | |
open(D, "<$opts{d}") || die "Can't open $opts{d}: $!\n"; | |
open(I, "<$opts{i}") || die "Can't open $opts{i}: $!\n"; | |
while(<D>) { | |
chomp; | |
push @d, $_; | |
} | |
close(D); | |
while(<I>) { | |
($disk, $sn) = (split)[0, 5]; | |
if(/dsk/) { | |
$disk =~ s,/dev/rdsk/,,; | |
$sn =~ s/^....(...*?)...$/$1/; | |
$i{$disk} = $sn; | |
} | |
} | |
close(I); | |
foreach $disk (@d) { | |
$orig = $nos2 = $disk; | |
$nos2 =~ s/s2$//; | |
$disk =~ s/c.*?t/emc_t/; | |
$disk =~ s/s2$//; | |
print "/usr/sbin/vxdg -g $opts{g} adddisk $disk\_$i{$orig}=$nos2\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment