More PowerShell functions...
Function Apply-VolMount mounts a volume to / and returns
true if successful or false if not. Function Update-LsMirrorRootVol triggers
updates of the load sharing mirrors from the rootvol.
FUNCTION
Apply-VolMount {
Param([String]$VOLNAME,[String]$SVMNAME)
[Void](Mount-NcVol -Name $VOLNAME
-JunctionPath "/$VOLNAME" -VserverContext $SVMNAME)
$a = Get-NcVol -Template
Initialize-NcObjectProperty $a
VolumeIdAttributes
$a.VolumeIdAttributes.JunctionPath =
""
IF((Get-NcVol -Name $VOLNAME -Attributes
$a).VolumeIdAttributes.JunctionPath -eq "/$VOLNAME"){ RETURN $TRUE }
ELSE{ RETURN $FALSE}
}
FUNCTION
Check-VolMount {
Param([String]$VOLNAME,[String]$SVMNAME,[String]$LOGFILE)
[Boolean]$Check = Apply-VolMount $VOLNAME
$SVMNAME
IF($Check){ Wr ("Mounted $VOLNAME to
/$VOLNAME") GREEN; Wr }
ELSE{ Wr ("FAILED to mount $VOLNAME to
/$VOLNAME") RED -Log $LOGFILE; Wr }
}
FUNCTION
Wr {
Param([String]$ToDisplay,[String]$Color =
"WHITE",[String]$LogFile)
If($ToDisplay){ Write-Host $ToDisplay
-ForegroundColor $Color -NoNewLine } else { Write-Host }
If($LogFile){ $ToDisplay >> $LogFile }
}
$Volname
= Read-Host "Volume "
$Svmname
= Read-Host "SVM "
[Void](Check-VolMount
$VOLNAME $SVMNAME "Errors.txt")
FUNCTION
Update-LsMirrorRootVol {
Param([String]$CLUSTERNAME,[String]$SVMNAME)
$a = Get-NcVserver -Template
$a.RootVolume = ""
[String]$RootVol = (Get-NcVserver -Attributes
$a -VserverContext $SVMNAME).RootVolume
[Void](Invoke-NcSnapMirrorLsUpdate
-SourceCluster $CLUSTERNAME -SourceVserver $SVMNAME -SourceVol $RootVol)
$RootVol
}
FUNCTION
Trigger-LsMirrorRootvolUpdate {
Param([String]$CLUSTERNAME,[String]$SVMNAME)
Wr; Wr "Triggered LS Mirror Update from
rootvol: " CYAN; Wr (Update-LsMirrorRootVol $CLUSTERNAME $SVMNAME); Wr
}
$CLUSTERNAME
= Read-Host "Cluster "
$SVMNAME = Read-Host "SVM "
[Void](Trigger-LsMirrorRootvolUpdate
$CLUSTERNAME $SVMNAME)
Comments
Post a Comment