Microsoft Virtualization Discussions

FSID via PS-Toolkit?

mark_schuren
5,291 Views

Hi all,

is there a way to get FSID values for aggregates and volumes via API / PS-Toolkit?

During some 7-mode controller migrations I need to get / set fsid's for a hughe number of objects. Since the data is not found in ASUP contents, is it possible via Powershell?

Thanks for any hints,

Mark

6 REPLIES 6

beam
5,291 Views

Hi Mark,

The FSID value is returned in Get-NaAggr:

PS C:\> Get-NaAggr | select Name, FSID

Name                                                                                                               Fsid

----                                                                                                               ----

aggr0                                                                                                        2071468128

aggr1                                                                                                        1845942832

-Steven

markweber
5,291 Views

you can use Invoke-NaSsh to pull it for each volume. i happened to be working on a function with a similar structure so i just changed the lines to pull the volume FSIDs and it worked against the 8.1.3 controller i tested it against.

YMMV - this structure makes several assumptions like RPC access from the account your are running the function under and that you have keyless SSH setup - plus a complete lack of error handling but it is a starting point.

save as Get-NaVolFSID.ps1, edit $keyfile and dot source it (. .\Get-NaVolFSID.ps1) then you can run $FSID = Get-NaVolFSID <controller> or pipe a list of controllers to it like: $FSID = gc .\filerlist.txt | Get-NaVolFSID

Function Get-NaVolFSID{

    [CmdletBinding()]

    Param(

        [Parameter(Mandatory=$True,

                    ValueFromPipeline=$true,

                    ValueFromPipelineByPropertyName=$true)]

        [Alias('Filer','Node')]

        [String[]]$Controller,

        [Parameter(Mandatory=$False)]

        [String]$keyfile = "<filename>.ppk"

    )

    Begin{

        $Results = @()

    }

    Process{

        foreach($C in $Controller){

            connect-nacontroller $C > $null

            $vols = get-navol

            foreach ($vol in $vols){

                $result = (Invoke-NaSsh -name root@$C -command "priv set advanced;vol read_fsid $vol" -PrivateKeyFile $keyfile -WarningAction SilentlyContinue) -split '\s+'

                $FSID = $result[($result.count - 2)].replace('.','')

                $Prop=[ordered]@{

                        'Controller' = $C

                        'Volume' = $vol.name

                        'FSID' = $FSID

                }

                $Obj=New-Object -TypeName PSObject -Property $Prop

                $Results += $Obj

            }

        }

    }

    End{

        #globally add aliasproperty

        $results | add-member -MemberType AliasProperty -name VolumeName -value Volume

        $results | add-member -MemberType AliasProperty -name Filer -value Controller

        $results | add-member -MemberType AliasProperty -name Node -value Controller

        Write-Output $Results

    }

}

JGPSHNTAP
5,291 Views

mark -

Just some things i noticed.  Please take this as constructive critisicm. In powershell, we shouldn't use > $Null.  The proper way to do this is | Out-null

Also, you can do this $connection = connect-nacntroller $c

Also, i see you are connecting RPC.  You are better to connect via https or run invoke-nassh natively.

markweber
5,291 Views

Hi Josh - I'm happy to have any feedback!

Why do you say out-null is the proper way? There are many ways to do almost anything in powershell, so what makes out-null better?

I prefer RPC over https because in my testing (and maybe it is just my environment) it is many times faster than https. It also allows me to schedule my scripts using our scripting account and not have to deal with the credential cache.

As for the script above, it is using RPC to get the volume list but invoke-nassh is run using -privatekeyfile since invoke-nassh doesn't support RPC.

thanks again for the feedback

mark

mark_schuren
5,291 Views

Thanks, this helps a lot to read out the data. And I think invoke-nassh should also do make it possible to "rewrite" FSID's.

But can an aggregate's FSID be changed while volumes are living on that aggr? Does it need to be offline to change it?

The idea is to get an exact 1:1 copy of and "old" filer aggregate / volume structure to a "new" filer using snapmirror - keeping all FSID's so that OnCommand UM is happy afterwards (does not notice the change) and all datasets/relationships stay intact after a filer migration...

markweber
5,291 Views

unfortunately, this isn't something i have any experience doing.

given that you are doing a migration, i would probably attack the problem from the other end and script the changes in OnCommand instead of changing the aggregrates/volumes - but i don't use OnCommand for managing Snapmirror/Snapvault relationships, so that is a naive statement on my part.

Public