Software Development Kit (SDK) and API Discussions

RequestIterator issues with Perl

lpetersPTO
2,051 Views

I am able to run non-iterator based calls, such as getStorageArrays, but the computeTotalStoragePerArray.pl example program loops through each array with

each array is not working.  It throws this error:

 

The method name 'null' in the request iterator, does not match the expected method name'VolumeRequest(storageId=86528). context=APISessionContext{clientVersion=1.0,id=3d92ee26:14be69a2397:-7fd2,time=1425575394391,limit=1000}

 

code snippet:

 

foreach my $storageArrayObject (@allStorageObjects) {

    # We need to build an empty request iterator to seed the call
    $iterObject = new SOAPParam( "RequestIterator_2", "namesp1:RequestIterator");

    print $storageArrayObject->name() . "\n\n";
    my $size = 0;
    my @allVolumeObjects;
    do {
        my $arrayRequester = new SOAP::Data(
            value => $storageArrayObject->id(),
            name => "String_3",
            type => "string");

print Dumper($APIContext);
print Dumper($iterObject);
print Dumper($arrayRequester);
        my $volumeResponse = $Soap->getVolumesByStorageArray($APIContext->getSOAP(), $iterObject->getSOAP(), $arrayRequester );
print "foo\n";
        $iterObject = Iterator->parseResult($volumeResponse);
        my @currVolumeObjects= Volume->parseResult($volumeResponse);

        push @allVolumeObjects, @currVolumeObjects;

    } while($iterObject->hasMore() eq "true");

    foreach my $volume (@allVolumeObjects){
        $size += $volume->capacityGB();
    }

    print "Size in GB as returned by summing the volume sizes: ". $size . "\n\n\n";

}

1 REPLY 1

lpetersPTO
2,027 Views

Solved my own problem.  The issue is that $iterObject _is_ null when the method is first called, so don't use it then.
Once the code gets the first response, then I can set the $iterObject to the proper value and use it accordingly:

 

my @allStorageObjects; 

my $iterObject;

do {
    my $storageArraysResponse;
    if ($iterObject) {
        $storageArraysResponse = $Soap->getStorageArrays($APIContext->getSOAP(), $iterObject->getSOAP());
    } else {
        $storageArraysResponse = $Soap->getStorageArrays($APIContext->getSOAP());
    }
    $iterObject = Iterator->parseResult($storageArraysResponse);
    my @currStorageArrayObjects = StorageArray->parseResult($storageArraysResponse);

    push @allStorageObjects, @currStorageArrayObjects;
} while($iterObject->hasMore() eq "true");

Public