How to get Disks, Aggregate and LUNs information of storage system using netapp ontap api (8.1) and java?

1.3k views Asked by At

I want to get information about Disks, Aggregates and LUNs using netapp ontap api 8.1. I am able to get list of volumes using following code:

VolumeListInfoIterStartRequest volumeListReq = new VolumeListInfoIterStartRequest();
    Iterator<VolumeInfo> volumeIter = apirunner.iterate(volumeListReq,10);
    VolumeInfo volume ;

   while(volumeIter.hasNext()) {
         System.out.println("------------------------------------------------");
         volume = volumeIter.next();
         System.out.println("Name               : " + volume.getName()); 
         System.out.println("Type               : " + volume.getType()); 
         System.out.println("State              : " + volume.getState());
         System.out.println("Total size (bytes) : " + volume.getSizeTotal());
         System.out.println("Used size (bytes)  : " + volume.getSizeUsed());
         System.out.println("Total disk count is .. "+ volume.getDiskCount());
         System.out.println("sysinfo is .. "+ volume.getSis());
         System.out.println("Total available size .. " + volume.getSizeAvailable());
         System.out.println("UUID is .. "+volume.getUuid());
         String vol = volume.getName();
         System.out.println("snapshot is "+ volume);
         System.out.println("------------------------------------------------");

     }

But when I try to use api for LUN exactly same as above I get error in iterate function. My code is:

LunListInfoRequest lunreq = new LunListInfoRequest();
     System.out.println("luninfo is .. " + lunreq);

     Iterator<LunInfo> lunInfoIter = apirunner.iterate(lunreq,10);

I got error in last line.

How do I get information about Disks, aggregates and LUNs??

1

There are 1 answers

0
nitin On
import java.util.List;

import com.netapp.nmsdk.client.ApiRunner;
import com.netapp.nmsdk.client.ApiTarget;
import com.netapp.nmsdk.client.ApiTarget.TargetType;
import com.netapp.nmsdk.ontap.api.lun.LunStatsInfo;
import com.netapp.nmsdk.ontap.api.lun.LunStatsListInfoRequest;
import com.netapp.nmsdk.ontap.api.lun.LunStatsListInfoResponse;


public class LUN {
public static void main(String[] args) {

    String host="";
    String userName="";
    String password="";



        try {
            ApiRunner runner = new ApiRunner(ApiTarget.builder()
                .withHost(host)
                .withUserName(userName)
                .withPassword(password)
                .withTargetType(TargetType.FILER)
                .useHttp()
                .build());


            LunStatsListInfoRequest req=new LunStatsListInfoRequest();
            LunStatsListInfoResponse res= runner.run(req);
            List<LunStatsInfo> list=res.getLunStats();


            for (LunStatsInfo luninfo : list) {
                System.out.println("*****************************");
                System.out.println("Block Size=="+luninfo.getBlockSize());
                System.out.println("Read Blocks=="+luninfo.getReadBlocks());
                System.out.println("Read Ops=="+luninfo.getReadOps());
                System.out.println("Write Blocks=="+luninfo.getWriteBlocks());
                System.out.println("write Ops=="+luninfo.getWriteOps());
                System.out.println("Other OPs=="+luninfo.getOtherOps());
                System.out.println("*****************************");


            }




}
        catch(Exception e){

        }
}
}