ONTAP Discussions

Powershell - Create Snapmirror Relationship with autocreating destination

TzwaynY
2,491 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
2,187 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
2,188 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
1,806 Views

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

TzwaynY
1,567 Views

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

 

Best regards

Kai

Fux
1,561 Views

Yes please

TzwaynY
1,378 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