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.

ONTAP Discussions

Powershell - Create Snapmirror Relationship with autocreating destination

TzwaynY
5,178 Views

Hello together,

I just started to code with the Ontap Powershell Module. I want to know, is there a way, to automatically create the destination volume for the snapmirror relation?
I tried it with the following:

 

for($i=0; $i -le ($VolsToCreate).Count; $i++){
$vServerForSnapmirror = ($VolsToCreate).vServer[$i]
New-NcSnapmirror -SourceVserver ($VolsToCreate).Vserver[$i] -DestinationVserver $DestinationvServerName -SourceVolume ($VolsToCreate).Name[$i] -DestinationVolume ($SnapMirrorDestinatioNVols).Name[$i] -RelationshipType XDP -CreateDestination $true
}

 

But it seems that $true is not working and the error I receive is not helping either. The error says that I should write down a valid command of type DataONTAP.C.Types.Snapmirror.CreateDestination

I also tried to create the volumes manually but I cant create volume of type DP which is a problem.

 

Maybe some of you can help me. 

Best regards

Kai

 

1 ACCEPTED SOLUTION

TzwaynY
4,874 Views

Hello everyone,

I solved the problem on my own. I let the script create the volumes with DP on the destination with an RESTAPI Post. Thats the only way I found how it works.

If anyone needs to know how I did the API post, let me know and I will post the solution 🙂

Best regards to everyone

- Kai

View solution in original post

5 REPLIES 5

TzwaynY
4,875 Views

Hello everyone,

I solved the problem on my own. I let the script create the volumes with DP on the destination with an RESTAPI Post. Thats the only way I found how it works.

If anyone needs to know how I did the API post, let me know and I will post the solution 🙂

Best regards to everyone

- Kai

Fux
4,493 Views

Hy, I'm facing the same issue, could you please share your trick ? Br

TzwaynY
4,254 Views

Hi Fux, sorry for the late repsone. Do you still need it?

 

Best regards

Kai

Fux
4,248 Views

Yes please

TzwaynY
4,065 Views

Hey Fux,

finally I had the time to look my code up in this case.

 

Here is how I did it:

 

I fetched the Names which needed to be 1:1 in my case before and pasted them into a variable which I filled into the PAYLOAD of my API Post:

 

                            $PAYLOAD = @{
                                "name"       = "VOLUMENAME"
                                "aggregates" = @(
                                    @{
                                        "name" = "AGGREGATENAME"
                                    }
                                )
                                "size"       = "SIZE" + "UNIT"
                                "svm"        = "DESTINATIONVSERVERNAME"
                                "type"       = "DP" #This is what you need!
                                "language"   = "VOLUMELANGUAGE"
                                "tiering"    = 
                                @{
                                    "policy" = "TIERINGPOLICY"
                                }
                            } | ConvertTo-Json  
                            $RESPONSE = Invoke-RestMethod -Uri $VOLUMEURL -Method Post -Headers $HEADERS -Body $PAYLOAD -ErrorAction Stop -SkipCertificateCheck
                            $RESPONSE | ConvertTo-Json

 

 As you can see, the "type" of the Volume it "dp" which is exactly what you will need, in order to create the dp volumes on your destination. 

 

Hope that helps. Feel free to ask me, if you need further assistance.

 

Best regards

Kai

Public