Quick Little Powershell Script

Here’s a quick little powershell script I wrote to illustrate the relationship between Aggregates, Shelves, and raid-groups for a student who was a little confused as to their relationship:

$raidGroup = 0;
$shelf=1;
$rgSize=8;
$shelfBays = 24
$numShelves = 2
$totalDisks = ($numShelves * $shelfBays)

write-output("Aggregate Start");
for ( $i = 0 ; $i -lt $totalDisks ; $i++) { 

    $shelfMody = $i % $shelfBays ; 
    $mody = $i % $rgSize ;
    if ( 0 -eq $shelfMody ) {
        Write-Output("------------SHELF------------");
        }
    if ( 0 -eq $mody ) {
        Write-Output("RaidGroup: $raidGroup");
        $raidGroup++;
        $Parity = 2 ; 
    }
    if ( $Parity -eq 2 ) {
        Write-Output("    Parity Disk #1: $i");
        $Parity--;
        } elseif ( $Parity -eq 1 ) {
        Write-Output("    Parity Disk #2: $i");
        $Parity--;
        } else {
        Write-Output("    data Disk: $i");
        }
    }

You can see some of the output below:

Aggregate Start
------------SHELF------------
RaidGroup: 0
    Parity Disk #1: 0
    Parity Disk #2: 1
    data Disk: 2
    data Disk: 3
    data Disk: 4
    data Disk: 5
    data Disk: 6
    data Disk: 7
RaidGroup: 1
    Parity Disk #1: 8
    Parity Disk #2: 9
    data Disk: 10
    data Disk: 11
    data Disk: 12
    data Disk: 13
    data Disk: 14
    data Disk: 15
RaidGroup: 2
    Parity Disk #1: 16
    Parity Disk #2: 17
    data Disk: 18
    data Disk: 19
    data Disk: 20
    data Disk: 21
    data Disk: 22
    data Disk: 23
------------SHELF------------
RaidGroup: 3
    Parity Disk #1: 24
    Parity Disk #2: 25
    data Disk: 26
    data Disk: 27
    data Disk: 28
    data Disk: 29
    data Disk: 30
    data Disk: 31
RaidGroup: 4
    Parity Disk #1: 32
    Parity Disk #2: 33
    data Disk: 34
    data Disk: 35
    data Disk: 36
    data Disk: 37
    data Disk: 38
    data Disk: 39
RaidGroup: 5
    Parity Disk #1: 40
    Parity Disk #2: 41
    data Disk: 42
    data Disk: 43
    data Disk: 44
    data Disk: 45
    data Disk: 46
    data Disk: 47
This entry was posted in netapp, programming, tech and tagged , , . Bookmark the permalink.