The transition to NetApp MS Azure AD B2C is complete. If you missed the pre-registration, you will be invited to reigister at next log in.
Please note that access to your NetApp data may take up to 1 hour.
To learn more, read the FAQ and watch the video.
Need assistance? Complete this form and select “Registration Issue” as the Feedback Category.

Software Development Kit (SDK) and API Discussions

cDOT: volume-get-iter API returns same set of volumes every time

nitish

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;

}

1 ACCEPTED SOLUTION

rle
NetApp Alumni

Hi,

I think I ran into this problem as well.  I looked at the code I posted over a year ago, and the loop end condition was not the number of records, but the existence of next-tag.  Here is a snippet.

    # Get the tag for the next iteration and create the tag element.
    #
    $tag = $xout->child_get_string("next-tag");
    my $tag_elem = NaElement->new("tag");
    $xin->child_add($tag_elem);

    while (defined($tag)) {
            $tag_elem->set_content($tag);

            my $xout = $server->invoke_elem($xin);
            if ($xout->results_status() eq "failed") {
                    print("volume-get-iter error: " .
                            $xout->results_reason() . "\n");
                    exit(-1);
            }

            tellus(2, "Loop: " . $xout->sprintf());

            @vol_list = $xout->child_get("attributes-list")->children_get();
            foreach $vol_info (@vol_list) {
                    print_vol_info($vol_info);
            }

            $tag = $xout->child_get_string("next-tag");
    }

Regards,

   - Rick -

View solution in original post

2 REPLIES 2

rle
NetApp Alumni

Hi,

I think I ran into this problem as well.  I looked at the code I posted over a year ago, and the loop end condition was not the number of records, but the existence of next-tag.  Here is a snippet.

    # Get the tag for the next iteration and create the tag element.
    #
    $tag = $xout->child_get_string("next-tag");
    my $tag_elem = NaElement->new("tag");
    $xin->child_add($tag_elem);

    while (defined($tag)) {
            $tag_elem->set_content($tag);

            my $xout = $server->invoke_elem($xin);
            if ($xout->results_status() eq "failed") {
                    print("volume-get-iter error: " .
                            $xout->results_reason() . "\n");
                    exit(-1);
            }

            tellus(2, "Loop: " . $xout->sprintf());

            @vol_list = $xout->child_get("attributes-list")->children_get();
            foreach $vol_info (@vol_list) {
                    print_vol_info($vol_info);
            }

            $tag = $xout->child_get_string("next-tag");
    }

Regards,

   - Rick -

View solution in original post

aleex

Hello,

 

I'm having some problems with "snapshot-get-iter". Seems that I'm getting the same values again and again.

  

Is the post before this your solution? The other article mentioned from you isn't only anymore.

 

Thanks for any idea and best regards,

Alex

Announcements
NetApp on Discord Image

We're on Discord, are you?

Live Chat, Watch Parties, and More!

Explore Banner

Meet Explore, NetApp’s digital sales platform

Engage digitally throughout the sales process, from product discovery to configuration, and handle all your post-purchase needs.

NetApp Insights to Action
I2A Banner
Public