NetApp Community Update
This site will enter Read Only mode on July 23 as we prepare to move to a new platform. You will still be able to view content, but posting and replying will be temporarily disabled.
We're excited to launch our new Community experience on July 30 and more information will follow soon.
Stay connected during the transition - Join our Discord community today.

Active IQ Unified Manager Discussions

Command to change the cDOt volume State from online to offline

Adai
5,336 Views

Hi,

       I am looking for a cdot volume modify command or volume set command that would change the state of the volume from online to offline.

I looked at out of box commands,  both modify volume and rename volume and both doesnt do it.

 

The state change is part of a Destory volume workflow, where we would like to rename the volume as volname_upfordecomissioning and then change the volume state to offline.

Then as a batch process destory all volume with _upfordecomissioning.

 

Anyone already written a cdot command to change to volume state from online to offline ?

 

Regards

adai

1 ACCEPTED SOLUTION

francoisbnc
5,325 Views

Hello Adai,

You can use part of certified commmand "remove volume", only concerning checking, dismounting and offlining and create a new one that could be have this look:

 

param (
[parameter(Mandatory=$true, HelpMessage="Cluster IP address")]
[string]$Cluster,

[parameter(Mandatory=$true, HelpMessage="Volume name")]
[string]$VolumeName,

[parameter(Mandatory=$true, HelpMessage="Storage Virtual Machine name")]
[string]$VserverName


)

# connect to cluster
Connect-WfaCluster $Cluster
$lastConnectedCluster = $Cluster

$clusterInfo = Get-NcCluster

# Testing volume existence. As this command doesn't throw exception if
# ErrorAction is 'Stop' and the volume isn't found. So, an explicit check.
$vol = Get-NcVol -Name $VolumeName -Vserver $VserverName
if(!$vol)
{
throw "Volume '$VolumeName' not found on Storage Virtual Machine '$VserverName'"
}

# Dismount the volume from the Storage Virtual Machine namespace if it is not the Storage Virtual Machine root volume
if (!$vol.VolumeStateAttributes.IsVserverRoot)
{
Get-WFALogger -Info -message $("Dismounting volume: " + $VolumeName + " on Storage Virtual Machine " + $VserverName)
Dismount-NcVol -Name $VolumeName -VserverContext $VserverName -Force -ErrorAction Stop
}

$volState = (Get-NcVol -Name $VolumeName -VserverContext $VserverName).State

if($volState -ne "offline")
{
Get-WFALogger -Info -message $("Offlining volume: " + $VolumeName + " on Storage Virtual Machine " + $VserverName)
Set-NcVol -Name $VolumeName -VserverContext $VserverName -Offline -ErrorAction Stop
}

 

François

View solution in original post

3 REPLIES 3

trentino123
5,332 Views

Hi Adai,

 

Don't know about the offline before for removing a volume there is a workflow called :  Remove a Clustered Data ONTAP VOlume

 

Which uses the following Commands : Split Volume Clone -> Wait for Volume Clone split -> Remove Volume

 

Hope it helps.

francoisbnc
5,326 Views

Hello Adai,

You can use part of certified commmand "remove volume", only concerning checking, dismounting and offlining and create a new one that could be have this look:

 

param (
[parameter(Mandatory=$true, HelpMessage="Cluster IP address")]
[string]$Cluster,

[parameter(Mandatory=$true, HelpMessage="Volume name")]
[string]$VolumeName,

[parameter(Mandatory=$true, HelpMessage="Storage Virtual Machine name")]
[string]$VserverName


)

# connect to cluster
Connect-WfaCluster $Cluster
$lastConnectedCluster = $Cluster

$clusterInfo = Get-NcCluster

# Testing volume existence. As this command doesn't throw exception if
# ErrorAction is 'Stop' and the volume isn't found. So, an explicit check.
$vol = Get-NcVol -Name $VolumeName -Vserver $VserverName
if(!$vol)
{
throw "Volume '$VolumeName' not found on Storage Virtual Machine '$VserverName'"
}

# Dismount the volume from the Storage Virtual Machine namespace if it is not the Storage Virtual Machine root volume
if (!$vol.VolumeStateAttributes.IsVserverRoot)
{
Get-WFALogger -Info -message $("Dismounting volume: " + $VolumeName + " on Storage Virtual Machine " + $VserverName)
Dismount-NcVol -Name $VolumeName -VserverContext $VserverName -Force -ErrorAction Stop
}

$volState = (Get-NcVol -Name $VolumeName -VserverContext $VserverName).State

if($volState -ne "offline")
{
Get-WFALogger -Info -message $("Offlining volume: " + $VolumeName + " on Storage Virtual Machine " + $VserverName)
Set-NcVol -Name $VolumeName -VserverContext $VserverName -Offline -ErrorAction Stop
}

 

François

Adai
5,285 Views

Hi Francois,

                 Thanks for your base code. I used it as a base and built the cDOT Volume Offline Comand.

 

Here it is for the convenience of all.

 

Regards

adai

Public