Adding Aggregate Information to Disks in sysconfig -A

I had a need to know how all the disks in the sysconfig -A output mapped to aggregates. I’d normally use ‘My AutoSupports: Visualizations’ for this, but this was not available to me so I had to come up with something else.

Scenario

You are tasked to perform a NetApp 7-Mode headswap from a FAS3170 to FAS3250, where the FAS3170 has 810 disks, but the FAS3250 has a platform limit of 720 disks. You know there’s a lot of spares and unassigned disks on the FAS3170, so if you can identify those disks, then you can remove enough disks (as whole shelves) to get to 720 disks. You do not have access to My AutoSupport Visualizations. What do you do?

The Solution

The ‘sysconfig -A’ output lists all the disks with their serial numbers, but doesn’t have any aggregate information. ‘aggr status -R’ can be used to map disk serial numbers to their aggregate, and then we add this information into the ‘sysconfig -A’ - the following PowerShell tool can be used to perform this task.

Example syntax (Note: The program uses ‘sysconfig -A’ and ‘aggr status -R’ outputs in txt files):

PS>

.\AddAggrInfoToSysconfigA.ps1 -N1_aggr_status_R FAS1_aggr_status_r.txt -N2_aggr_status_R FAS2_aggr_status_r.txt -N1_sysconfig_A FAS1_sysconfig_a.txt -N2_sysconfig_A FAS2_sysconfig_a.txt


Image: Running AddAggrInfoToSysconfigA.ps1

The Script

Copy to a text editor and save as say ‘AddAggrInfoToSysconfigA.ps1’.


#######################################
## ADDING AGGR INFO. TO sysconfig -A ##
#######################################

Param(
  [String]$N1_sysconfig_A,
  [String]$N2_sysconfig_A,
  [String]$N1_aggr_status_R,
  [String]$N2_aggr_status_R
)

###################################
## MAP DISK SERIALS TO AGGREGATE ##
###################################

[String]$GLOBAL:CA = "" ## CA = Current Aggregate
[System.Object]$DSTA = @{} ## DSTA = Disk Serial To Aggregate
[System.Array]$GLOBAL:SERIALS = @()

Function ProcessAggrR{
  If($LINE.startswith("Aggregate")){
    $GLOBAL:CA = $LINE.Split(" ")[1]
    RETURN                
  }
  If($LINE.trim(" ").StartsWith("dparity") -or,
    $LINE.trim(" ").StartsWith("parity") -or,
    $LINE.trim(" ").StartsWith("data") )
  {
    [System.Array]$SPLITTER = $LINE.Split(" ")
    [Int]$Column = 0
    [Int]$Splits = 0
    [String]$SERIAL = ""
    Foreach($SPLIT in $SPLITTER){
      If($SPLIT.Trim(" ") -eq ""){}
      Else{$Column++}
      If($Column -eq 4){
        [String]$SERIAL = $SPLITTER[$Splits]
        $GLOBAL:SERIALS += $SERIAL
        [String]$DSTA.$SERIAL = $GLOBAL:CA
        RETURN
      }
      $Splits++
    }
  }
}

$N1_AGGR_STATUS_R,$N2_AGGR_STATUS_R | Foreach{
  [System.Array]$AGGR_STATUS_R = Get-Content $_
  Foreach($LINE in $AGGR_STATUS_R){
    ProcessAggrR
  }
}

############################################
## ADD AGGR INFO TO DISKS IN SYSCONFIG -A ##
############################################

Function ProcessSysconfigA{
  Foreach($SERIAL in $GLOBAL:SERIALS){
       If($LINE.contains($SERIAL)){
      [String]$NEWLINE += ($LINE + " " + $DSTA.$SERIAL)
      $GLOBAL:OUTPUT += $NEWLINE
      RETURN
       }
  }
  $GLOBAL:OUTPUT += $LINE
}

$N1_SYSCONFIG_A,$N2_SYSCONFIG_A | Foreach{
  [System.Array]$GLOBAL:OUTPUT = @()
  [System.Array]$SYSCONFIG_A = Get-Content $_
  Foreach($LINE in $SYSCONFIG_A){
    ProcessSysconfigA
  }
  $GLOBAL:OUTPUT | Out-File ("$_" + "_with_aggrs.log")
}


Comments