Software Development Kit (SDK) and API Discussions

NMSDK OnCommand : Filer serial and system id

TThaens24
3,400 Views

Hi all,

I would like to use the NMSDK for OnCommand to get a list of all the NetApp filers I'm monitoring within my OnCommand servers.

I would like to have the following information for each filer:

  • name
  • model
  • OnTap version
  • Serial Number
  • System ID

With the following piece of code, I'm able to find the name, model and version.

But I can't figure out how to get the serial number and system ID. Also OnCommand has that information...

Any suggestions? Btw, I'm not able to connect to the filers itself from this server, only from the OnCommand servers.

(Also, it seems my filter to only display filers doesn't work. It still shows agents and vfilers)

import netapp.manage.*;

import java.util.List;

import java.util.Iterator;

public class MyTest

{

     public static void main(String[] args)

     {

          try

          {

              NaServer s = new NaServer("mydfmserver", 1, 0);

              s.setStyle(NaServer.STYLE_LOGIN_PASSWORD);

              s.setTransportType(NaServer.TRANSPORT_TYPE_HTTP);

              s.setServerType(NaServer.SERVER_TYPE_DFM);

              s.setPort(8088);

              s.setAdminUser("myDFMUser", "myDFMPassword");

              NaElement requestElem = new NaElement("host-list-info-iter-start");

              requestElem.addNewChild("host-types", "filer");

    

              NaElement responseElem = s.invokeElem(requestElem);

              String records = responseElem.getChildContent("records");

              String tag = responseElem.getChildContent("tag");

              System.out.println("Found " + records + "filer(s)");

              requestElem = new NaElement("host-list-info-iter-next");

              requestElem.addNewChild("maximum", records);

              requestElem.addNewChild("tag", tag);

              NaElement record = s.invokeElem(requestElem);

              NaElement stat = record.getChildByName("hosts");

              List infoList = null;

              if(stat != null)

                   infoList = stat.getChildren();

              else

                   return;

              Iterator infoIter = infoList.iterator();

    

              while(infoIter.hasNext())

              {

                   NaElement info = (NaElement) infoIter.next();

                   String name = info.getChildContent("host-name");

                   String type = info.getChildContent("host-type");

                   String model = info.getChildContent("host-model");

                   String version = info.getChildContent("host-version");

                   // So how do I get the serial and the system id???

   

                   System.out.println("     Found host : " + name + " - " + type + " - " + model + " - " + version);

              }

              return;

          }

          catch (Exception e)

          {

              System.err.println(e.toString());

              System.exit(1);

          }

     }

}

When I compile this, and run it:

[root@mysystem ~]# javac -d bin -cp lib/manageontap-5.1.jar src/MyTest.java

[root@mysystem ~]# java -cp "bin:lib/manageontap-5.1.jar" MyTest

Found 57filer(s)

     Found host : acgpsvfdehuz - vfiler - unknown - 8.1 7-Mode

     Found host : acgpsvfdenos - vfiler - unknown - 8.1 7-Mode

     Found host : acgpsvfprhuz - vfiler - unknown - 8.1 7-Mode

     Found host : acgpsvfprnos - vfiler - unknown - 8.1 7-Mode

     Found host : acgpsvftehuz - vfiler - unknown - 8.1 7-Mode

     Found host : acgpsvftenos - vfiler - unknown - 8.1 7-Mode

     Found host : bedbepw058 - vfiler - unknown - 8.1 7-Mode

     Found host : bedbepw060 - vfiler - unknown - 8.1 7-Mode

     Found host : behuz999001sto - vfiler - unknown - 8.1 7-Mode

     Found host : bejoriside01a - filer - FAS3210 - 8.1.1 7-Mode

     Found host : bejoriside01b - filer - FAS3210 - 8.1.1 7-Mode

     Found host : beqbrgbrg1na001 - filer - FAS3270 - 8.0.2RC1 7-Mode

     Found host : beqbrgbrg1na002 - filer - FAS3270 - 8.0.2RC1 7-Mode

     Found host : beqbrgbrg1na004 - filer - FAS3270 - 8.1RC3 7-Mode

     Found host : beqbrgbrg1na005 - filer - FAS3270 - 8.1RC3 7-Mode

     Found host : beqbrgbrg1na006 - filer - FAS3210 - 8.0.2RC1 7-Mode

     Found host : beqbrgbrg1na501 - vfiler - unknown - 8.1RC3 7-Mode

     Found host : bru0001f - vfiler - unknown - 8.1 7-Mode

     Found host : bru0002f - vfiler - unknown - 8.1 7-Mode

     Found host : bru0003f - vfiler - unknown - 8.1 7-Mode

     Found host : bru0004f - vfiler - unknown - 8.1 7-Mode

     Found host : bru0005f - vfiler - unknown - 8.1 7-Mode

     Found host : bru0006f - vfiler - unknown - 8.1 7-Mode

     Found host : bru0007f - vfiler - unknown - 8.1 7-Mode

     Found host : bru0008f - vfiler - unknown - 8.1 7-Mode

     Found host : bru0009f - vfiler - unknown - 8.1 7-Mode

     Found host : bru0010f - vfiler - unknown - 8.1 7-Mode

     Found host : bru0011f - vfiler - unknown - 8.1 7-Mode

     Found host : bru0012f - vfiler - unknown - 8.1 7-Mode

     Found host : bru0013f - vfiler - unknown - 8.1 7-Mode

     Found host : bru0059f - vfiler - unknown - 8.1 7-Mode

     Found host : bru0081f - vfiler - unknown - 8.0.2P3 7-Mode

     Found host : bru0453f - vfiler - unknown - 8.1 7-Mode

     Found host : EUOSMSFS010 - vfiler - unknown - 8.1.2 7-Mode

     Found host : EUOSMSFS010 - vfiler - unknown - 8.1.2 7-Mode

     Found host : EUOSMSNETAPPDLCB01 - filer - FAS2240-4 - 8.1.2 7-Mode

     Found host : EUOSMSNETAPPDLCB02 - filer - FAS2240-4 - 8.1.2 7-Mode

     Found host : EUOSMSNETAPPSALB01 - filer - FAS2240-4 - 8.1.2 7-Mode

     Found host : EUOSMSNETAPPSALB02 - filer - FAS2240-4 - 8.1.2 7-Mode

     Found host : fas1c1 - filer - FAS2240-4 - 8.1.2P2 7-Mode

     Found host : fas1c2 - filer - FAS2240-4 - 8.1.2P2 7-Mode

     Found host : fas2c1 - filer - FAS2240-4 - 8.1.2P2 7-Mode

     Found host : fas2c2 - filer - FAS2240-4 - 8.1.2P2 7-Mode

     Found host : FEDNAS01 - filer - FAS3040 - 7.3.2

     Found host : FEDNAS02 - filer - FAS3040 - 7.3.2

     Found host : huibron01a - filer - FAS3210 - 8.1 7-Mode

     Found host : huibron01b - filer - FAS3210 - 8.1 7-Mode

     Found host : huigosi01a - filer - FAS3240 - 8.1 7-Mode

     Found host : huigosi01b - filer - FAS3240 - 8.1 7-Mode

     Found host : HUZDNS02 - filer - FAS3170 - 8.0.2P3 7-Mode

     Found host : MC1NODE1 - filer - FAS3040 - 7.3.2P5

     Found host : MC1NODE2 - filer - FAS3040 - 7.3.2P5

     Found host : mecbron01a - filer - FAS3210 - 8.1 7-Mode

     Found host : mecbron01b - filer - FAS3210 - 8.1 7-Mode

     Found host : mecgosi01a - filer - FAS3240 - 8.1 7-Mode

     Found host : mecgosi01b - filer - FAS3240 - 8.1 7-Mode

     Found host : siebepo005 - vfiler - unknown - 8.1 7-Mode

Kind regards

1 ACCEPTED SOLUTION

lewisn
3,400 Views

If you are going through the DFM server using the API, you need to use the api-proxy call and provide system-get-info as the name and the name of the filer you need the serial for as the target. I believe there is an example for a dam api-proxy call in the NMSDK documentation examples.

I did exactly the same thing in PERL not long ago.

Lew

View solution in original post

2 REPLIES 2

lewisn
3,401 Views

If you are going through the DFM server using the API, you need to use the api-proxy call and provide system-get-info as the name and the name of the filer you need the serial for as the target. I believe there is an example for a dam api-proxy call in the NMSDK documentation examples.

I did exactly the same thing in PERL not long ago.

Lew

TThaens24
3,400 Views

Hi Lew,

Thank you very much for that info.

I finally was able to get it that way.

With the example of the api-proxy call, I was quickly able to get something back from the system-get-info. But I had a lot of issues extracting the system-serial-number and system-id out of that response.

Unlike all the examples of the system-get-version, the system-get-info has the information encapsuled in a system-info object.

After some struggle, I figured it out!!!

Well, so I thought it might be a good idea to post my solution here, if anyone would ever need it.

(guess I can do better on the allocation of the elements, but at least I got the answer for now)

Also, you would need an account on the filers with the same name as you use to connect to dfm (in my code below: MyDFMAccount)

import netapp.manage.*;

import java.util.List;

import java.util.Iterator;

public class MyTest

{

     public static void main(String[] args)

     {

          try

          {

                  NaServer s = new NaServer("myDFMServer", 1, 0);

              s.setStyle(NaServer.STYLE_LOGIN_PASSWORD);

              s.setTransportType(NaServer.TRANSPORT_TYPE_HTTP);

              s.setServerType(NaServer.SERVER_TYPE_DFM);

              s.setPort(8088);

              s.setAdminUser("myDFMAccount", "myDFMPassword";

              NaElement requestElem = new NaElement("host-list-info-iter-start");

              requestElem.addNewChild("host-types", "filer");

    

              NaElement responseElem = s.invokeElem(requestElem);

              String records = responseElem.getChildContent("records");

              String tag = responseElem.getChildContent("tag");

              System.out.println("Found " + records + "filer(s)");

              requestElem = new NaElement("host-list-info-iter-next");

              requestElem.addNewChild("maximum", records);

              requestElem.addNewChild("tag", tag);

              NaElement record = s.invokeElem(requestElem);

              NaElement stat = record.getChildByName("hosts");

              List infoList = null;

              if(stat != null)

                   infoList = stat.getChildren();

              else

                   return;

              Iterator infoIter = infoList.iterator();

    

              while(infoIter.hasNext())

              {

                   NaElement info = (NaElement) infoIter.next();

                   String name = info.getChildContent("host-name");

                   String type = info.getChildContent("host-type");

                   String model = info.getChildContent("host-model");

                   String version = info.getChildContent("host-version");

   

                   System.out.println("     Found host : " + name + " - " + type + " - " + model + " - " + version);

                   if(type.equals("filer"))

                   {

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

                        proxyElem.addNewChild("target", name);

                        NaElement apiRequest = new NaElement("request");

                        apiRequest.addNewChild("name", "system-get-info");

                        proxyElem.addChildElem(apiRequest);

                        NaElement out = s.invokeElem(proxyElem);

                        NaElement dfmResponse = out.getChildByName("response");

                        if (dfmResponse.getChildContent("status").equals("passed") != true)

                        {

                            System.out.println("Error: " + dfmResponse.getChildContent("reason"));

                        }

                        else

                        {

                             NaElement apiResponse = dfmResponse.getChildByName("results");

                             NaElement sysInfo = apiResponse.getChildByName("system-info");

                             System.out.println("            Serial number : " + sysInfo.getChildContent("system-serial-number"));

                             System.out.println("            System ID     : " + sysInfo.getChildContent("system-id"));

                        }

                   }

              }

              return;

          }

          catch (Exception e)

          {

              System.err.println(e.toString());

              System.exit(1);

          }

     }

}

Public