Subscribe

How do I pass the next-Tag using the API Proxy or set the max-records to 100 for .NET SDK

Hi All

Using manage OnTAP API .NET SDK (DFM 5.2)

                NaServer s = new NaServer(Properties.Settings.Default.DFMServer, 1, 0);

                        s.ServerType = NaServer.SERVER_TYPE.DFM;

                        s.TransportType = NaServer.TRANSPORT_TYPE.HTTPS;

                        s.Port = 8488;

                        //s.Port = 443;

                        s.Style = NaServer.AUTH_STYLE.LOGIN_PASSWORD;

                        s.SetAdminUser(Properties.Settings.Default.DFMUsername, Properties.Settings.Default.DFMPassword);

NaElement apiproxy = new NaElement("api-proxy");

                        apiproxy.AddNewChild("target", Clustername);

                        NaElement xi = new NaElement("request");

                        xi.AddNewChild("name", "Volume-get-iter");

                        xi.AddNewChild("args", "");

                        apiproxy.AddChildElement(xi);

                        NaElement xo = s.InvokeElem(apiproxy);

·         Connecting to a DFM Server

·         Using the APIProxy to send a volume-get-iter to a NetAPP Cluster

·         I get results but only 20

How do I pass the next-Tag using the API Proxy or set the max-records to 100?

Re: How do I pass the next-Tag using the API Proxy or set the max-records to 100 for .NET SDK

Hi Alex,

"volume-get-iter" will return 20 records by default unless you specify 'max-records' attribute/parameter to this API.

You can pass the "max-records" as 100 through the "args" parameter of "api-proxy", e.g.

         NaElement api = new NaElement("api-proxy");

         NaElement request = new NaElement("request");

         api.AddChildElement(request);

         NaElement arg_s = new NaElement("args");

         request.AddChildElement(arg_s);

         arg_s.AddNewChild("max-records", "100");

You can alsp extract the "next-tag" and pass it as a value for parameter "tag" in subsequent iterations.

For the first iteration, you need not pass the "tag" parameter. When all the records are retrieved, "next-tag" is have "null" value.

Here is a sample code which will give you an idea of how to iterate using next-tag:

class VolumeList

    {

    static void Main(string[] args)

     {

         try

         {

               NaServer s = new NaServer(Properties.Settings.Default.DFMServer, 1, 0);

               s.ServerType = NaServer.SERVER_TYPE.DFM;

               s.TransportType = NaServer.TRANSPORT_TYPE.HTTPS;

               s.Port = 8488;      // assuming you are using DFM 4.x or 5.x versions. For 6.x, use s.Port = 443;

               s.Style = NaServer.AUTH_STYLE.LOGIN_PASSWORD;

               s.SetAdminUser(Properties.Settings.Default.DFMUsername, Properties.Settings.Default.DFMPassword);

                      

               String tag = "";

               while (tag != null)

               {

                     NaElement api = new NaElement("api-proxy");

                     NaElement request = new NaElement("request");

                     api.AddChildElement(request);

                     NaElement arg_s = new NaElement("args");

                     request.AddChildElement(arg_s);

                     arg_s.AddNewChild("tag", tag);

                     request.AddNewChild("name", "volume-get-iter");

                     api.AddNewChild("target", "<ip address of the storage system>");

                     NaElement xo = s.InvokeElem(api);

                     NaElement response = xo.GetChildByName("response");

                     String status = response.GetChildContent("status");

                     if(status.Equals("passed"))

                     {

                         NaElement results = response.GetChildByName("results");

                         int num_records = results.GetChildIntValue("num-records", 0);

                         if (num_records > 0)

                         {

                             NaElement attributes_list = results.GetChildByName("attributes-list");

                             NaElement volume_attributes = attributes_list.GetChildByName("volume-attributes");

                             NaElement volume_id_attributes = volume_attributes.GetChildByName("volume-id-attributes");

                             String vserver_name = volume_id_attributes.GetChildContent("owning-vserver-name");

                             String aggr_name = volume_id_attributes.GetChildContent("containing-aggregate-name");

                             String vol_name = volume_id_attributes.GetChildContent("name");

                             Console.WriteLine("Volume: " + vserver_name + ":" + aggr_name + "/" + vol_name);

                         }

                         tag = results.GetChildContent("next-tag");

                     }

                 }

        }

        catch (NaAuthException e)

        {

            Console.Error.WriteLine("Authorization Failed: " + e.Message);

        }

        catch (NaApiFailedException e)

        {

            Console.Error.WriteLine("API FAILED: " + e.Message);

        }

         catch (Exception e)

        {

            Console.Error.WriteLine(e.Message);

        }

     }

  }

Regards,

Sen.