ONTAP Rest API Discussions

Volume DR Protection

jsharpe
3,098 Views

I am using the Python Library to list the volumes on a cluster/SVM. One of the SVMs in the cluster is protected by SVM DR. I would like to query all of the volumes on the SVM and determine which ones are protected by SVM DR. I believe the best way to do this is to look for the "vserver-dr-protection" field (which can be queried on the CLI via "vol show -vserver # -fields vserver-dr-protection"). However, I cannot seem to find the volume API field to query to get that information.

 

What volume API field do I need to query to get that flag, or do I have to run an additional iteration using a snapshot API field?

 

My code currently looks something like this:

from netapp_ontap import NetAppRestError
from netapp_ontap import config
from netapp_ontap import HostConnection
from netapp_ontap.resources import Cluster, Volume


conn = HostConnection(...)
config.CONNECTION = conn
for vol in Volume.get_collection(fields="svm,name,state,is_svm_root"):
    print(vol)

 

1 ACCEPTED SOLUTION

RobertBlackhart
3,037 Views

You may want the `snapmirror.is_protected` field which would make your query look like this:

 

for vol in Volume.get_collection(fields="svm,name,state,is_svm_root", **{"snapmirror.is_protected": True}):
    print(vol)

 

Sometimes there are fields in the CLI which are not exposed in the REST API. If there's something you rely on that's not in REST, you may open a case with support to ask that it be added. As a stop-gap in the meantime, you can make use of the CLI passthrough endpoint which allows you to make CLI calls and get the results through the rest interface. In this case it would look like this:

 

from netapp_ontap import HostConnection
from netapp_ontap.resources import CLI

with HostConnection(...):
    response = CLI().execute("volume show", vserver_dr_protection="protected")
    for volume in response.http_response.json()["records"]:
        print(volume)

View solution in original post

2 REPLIES 2

RobertBlackhart
3,038 Views

You may want the `snapmirror.is_protected` field which would make your query look like this:

 

for vol in Volume.get_collection(fields="svm,name,state,is_svm_root", **{"snapmirror.is_protected": True}):
    print(vol)

 

Sometimes there are fields in the CLI which are not exposed in the REST API. If there's something you rely on that's not in REST, you may open a case with support to ask that it be added. As a stop-gap in the meantime, you can make use of the CLI passthrough endpoint which allows you to make CLI calls and get the results through the rest interface. In this case it would look like this:

 

from netapp_ontap import HostConnection
from netapp_ontap.resources import CLI

with HostConnection(...):
    response = CLI().execute("volume show", vserver_dr_protection="protected")
    for volume in response.http_response.json()["records"]:
        print(volume)

jsharpe
2,967 Views

Thanks for the quick reply @RobertBlackhart!

 

We are upgrading our system with SVM-DR from 9.5 to 9.7 in the coming weeks, so I will be able to verify the code then. It seems to work fine on a dev system without SVM-DR setup (with snapmirror.is_protected == False).

 

Also, thanks for the tip on pushing commands to the CLI. While it isn't very Pythonic, it can be used as a work around should I have issues getting the requested fields from the API.

Public