How to list all volumes using netapp api and java?

437 views Asked by At

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?

1

There are 1 answers

1
Sachin On

There is probability of volumeIter.hasNext() returns false so volume will be null. If volumeIter.hasNext() returns false you should return null value.
As you want to return list you should add VolumeInfo in list