我想使用netapp ontap api 8.1获取有关磁盘,聚合和LUN的信息。 我可以使用以下代码获取卷列表:
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("------------------------------------------------");
}
但是当我尝试使用与上面完全相同的LUN的api时,我在迭代函数中得到错误。 我的代码是:
LunListInfoRequest lunreq = new LunListInfoRequest();
System.out.println("luninfo is .. " + lunreq);
Iterator<LunInfo> lunInfoIter = apirunner.iterate(lunreq,10);
我在最后一行收到错误。
如何获取有关磁盘,聚合和LUN的信息?
答案 0 :(得分:1)
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){
}
}
}