Active IQ Unified Manager Discussions

vFiler DR Resync via WFA

CHRISTIAN_UMREIN
4,132 Views

Hi all,

I want to set up a "vFiler DR resync" command in WFA 2.0

Is there anyone who uses this already and could give me the command for this?

I want to write it in Power Shell.

Thanks,

Chris

1 ACCEPTED SOLUTION

yaronh
4,132 Views

Hi Christian,

I was working with a team of advanced users from T-system on their workflows and happened to notice they've done some work on this. With permission of Paul Bloem and Carl Thijssen I am sharing their solution:

param (

    [parameter(Mandatory=$true, HelpMessage="Source array name or IP address")]

    [string]$SourceArray,

 

    [parameter(Mandatory=$true, HelpMessage="Destination array name or IP address")]

    [string]$DestinationArray, 

    [parameter(Mandatory=$true, HelpMessage="Source vFiler name")]

    [string]$SourceVFilerName,

    [parameter(Mandatory=$false, HelpMessage="Volume Name")]

    [string]$SourceVolumeName

)

# connect to controller

Connect-WFAController -Array $DestinationArray

#syntax:

#Invoke-NaVfilerDrResync [-RemoteVfiler] <String> [-RemoteFiler] <String> [-Credential <PSCredential>] [-Synchronous] [-Secure] [-Controller <NaController>] [-WhatIf] [-Confirm] [<CommonParameters>]

 

$cred = Get-NaCredentials -Host $SourceArray

if(!$cred)

{

    throw "Failed to get credentials for source array : " + $SourceArray

}

 

Get-WFALogger -Info -message $("Resync Vfiler DR")

$SourceBaseArray=$SourceArray.split(".")[0]

 

Get-WFALogger -Info -message $("Resync Vfiler DR " + $SourceVFilerName + " " + $SourceBaseArray + " " + $DestinationArray + " Cred:  " + $cred.UserName + " VolumeName " + $SourceVolumeName)

try

{

    Invoke-NaVfilerDrResync -RemoteVfiler $SourceVFilerName -RemoteFiler $SourceBaseArray -Secure -Credential $cred -Confirm:$false -ea Stop

}

catch

{

    $MyError=$_

    $FoundVolume=Get-NaVfilerDr -RemoteVfiler $SourceVFilerName -RemoteFiler $SourceBaseArray | where-object { $_.StoragePath -eq "$SourceVolumeName" }

    if ($FoundVolume)

    {

        Get-WFALogger -Info -message $("Found storage path " + $FoundVolume.StoragePath + " with status " + $FoundVolume.Status)

         if ($FoundVolume.Status -eq "initializing" -or $FoundVolume.Status -eq "snapmirrored")

        {

           Get-WFALogger -Info -message $("That is fantastic, apparently the resync worked")

        } else

        {

           Get-WFALogger -Info -message $("Not good, status is not good...")

           throw $MyError

        }

    } else

    {

       Get-WFALogger -Info -message $("Caught the exception, but throwing anyway")

       Get-NaVfilerDr -RemoteVfiler $SourceVFilerName -RemoteFiler $SourceBaseArray | Foreach-Object { Get-WFALogger -Info -message $("Volume " + $_.StoragePath + " Status " + $_.Status) }

       throw $MyError;

    }

}

Hope that helps as a base for building your command.

Cheers,

Yaron Haimsohn

WFA Team

View solution in original post

3 REPLIES 3

yaronh
4,133 Views

Hi Christian,

I was working with a team of advanced users from T-system on their workflows and happened to notice they've done some work on this. With permission of Paul Bloem and Carl Thijssen I am sharing their solution:

param (

    [parameter(Mandatory=$true, HelpMessage="Source array name or IP address")]

    [string]$SourceArray,

 

    [parameter(Mandatory=$true, HelpMessage="Destination array name or IP address")]

    [string]$DestinationArray, 

    [parameter(Mandatory=$true, HelpMessage="Source vFiler name")]

    [string]$SourceVFilerName,

    [parameter(Mandatory=$false, HelpMessage="Volume Name")]

    [string]$SourceVolumeName

)

# connect to controller

Connect-WFAController -Array $DestinationArray

#syntax:

#Invoke-NaVfilerDrResync [-RemoteVfiler] <String> [-RemoteFiler] <String> [-Credential <PSCredential>] [-Synchronous] [-Secure] [-Controller <NaController>] [-WhatIf] [-Confirm] [<CommonParameters>]

 

$cred = Get-NaCredentials -Host $SourceArray

if(!$cred)

{

    throw "Failed to get credentials for source array : " + $SourceArray

}

 

Get-WFALogger -Info -message $("Resync Vfiler DR")

$SourceBaseArray=$SourceArray.split(".")[0]

 

Get-WFALogger -Info -message $("Resync Vfiler DR " + $SourceVFilerName + " " + $SourceBaseArray + " " + $DestinationArray + " Cred:  " + $cred.UserName + " VolumeName " + $SourceVolumeName)

try

{

    Invoke-NaVfilerDrResync -RemoteVfiler $SourceVFilerName -RemoteFiler $SourceBaseArray -Secure -Credential $cred -Confirm:$false -ea Stop

}

catch

{

    $MyError=$_

    $FoundVolume=Get-NaVfilerDr -RemoteVfiler $SourceVFilerName -RemoteFiler $SourceBaseArray | where-object { $_.StoragePath -eq "$SourceVolumeName" }

    if ($FoundVolume)

    {

        Get-WFALogger -Info -message $("Found storage path " + $FoundVolume.StoragePath + " with status " + $FoundVolume.Status)

         if ($FoundVolume.Status -eq "initializing" -or $FoundVolume.Status -eq "snapmirrored")

        {

           Get-WFALogger -Info -message $("That is fantastic, apparently the resync worked")

        } else

        {

           Get-WFALogger -Info -message $("Not good, status is not good...")

           throw $MyError

        }

    } else

    {

       Get-WFALogger -Info -message $("Caught the exception, but throwing anyway")

       Get-NaVfilerDr -RemoteVfiler $SourceVFilerName -RemoteFiler $SourceBaseArray | Foreach-Object { Get-WFALogger -Info -message $("Volume " + $_.StoragePath + " Status " + $_.Status) }

       throw $MyError;

    }

}

Hope that helps as a base for building your command.

Cheers,

Yaron Haimsohn

WFA Team

CHRISTIAN_UMREIN
4,132 Views

Hi Yaron,

thanks for your source code.

I have implemented it and will start to test when our storage admins arrive.

Cheers,

Chris

CHRISTIAN_UMREIN
4,132 Views

Hi Yaron,

the code works fine. Thank you

Public