I want to list all volumes using netapp api and Java. I am using following code:
public void VolName() {
ApiRunner runner = new ApiRunner(ApiTarget.builder()
.withHost(host).withUserName(user).withPassword(pass)
.withTargetType(TargetType.FILER).useHttp().build());
VolumeListInfoIterStartRequest volListReq = new VolumeListInfoIterStartRequest();
Iterator<VolumeInfo> volumeIter = runner.iterate(volListReq, 20);
VolumeInfo volume = null;
while(volumeIter.hasNext()) {
volume = volumeIter.next();
System.out.println("Sample 1: " + volume.getName());
}
}
In this code I get error at volume.getName()
, if I used volume.getVolumeName()
it returns null
.
How do I get volume information using netapp api and Java?
There is probability of
volumeIter.hasNext()
returns false sovolume
will be null. IfvolumeIter.hasNext()
returns false you should return null value.As you want to return list you should add
VolumeInfo
inlist