I tried to fetch volume info from a clustered ONTAP filer via NMSDK and I have an issue with iterate a list of volume objects.
The “volume-get-iter” element seems like most relevant to what I am looking for. However the tag I specified with from the last call, always return the same set of the volume objects.
Here is my code snip. Any ideas?
I suspect something might be wrong with the way tag I specified.
This cluster has 15 volume objects, I should get 4 different list of volume objects each time (and the last one will be 3 volume objects).
However, i get the same set of volumes every time.
=== === === ===
my $api = create_element();
my $xo = $s->invoke_elem($api);
if ( $xo->results_status() eq 'failed' ) {
print 'Error:\n';
print $xo->sprintf();
exit 1;
}
my $tag;
my $number_records;
do {
$number_records = $xo->child_get_int("num-records");
last if $number_records == 0;
$tag = $xo->child_get_string("next-tag");
print $xo->sprintf();
$api = create_element();
$api->child_add_string( "tag", $tag );
my $xo = $s->invoke_elem($api);
if ( $xo->results_status() eq 'failed' ) {
print 'Error:\n';
print $xo->sprintf();
exit 1;
}
sleep 5;
} while ( $number_records != 0 );
sub create_element {
my $api = new NaElement('volume-get-iter');
my $xi = new NaElement('desired-attributes');
$api->child_add($xi);
my $xi1 = new NaElement('volume-attributes');
$xi->child_add($xi1);
my $xi12 = new NaElement('volume-id-attributes');
$xi1->child_add($xi12);
$xi12->child_add_string('name');
$xi12->child_add_string('junction-path');
$api->child_add_string( 'max-records', '4' );
return $api;
}