Software Development Kit (SDK) and API Discussions

query not working on SDK 4.1

gasparuben
4,818 Views

hi There,

I most likely doing something wrong but I have started to use NMSDK and it looks to me the query doesnt work, at least as I think it's intended.

I have a C-mode cluster with 90 volumes on it, when I query to get attributes of just one volume using its properties: junction-path and name, I get nevertheless all of them. This is a piece of the code (in perl):


$nelem = NaElement->new("volume-get-iter");

$nelem->child_add_string("max-records",100);

$query = NaElement->new("query");

$volpath = NaElement->new("volume-id-attributes");

$volpath->child_add_string("junction-path", $mountpath);

#$volpath->child_add_string("name","edhp_backup01" );

$query->child_add($volpath);

$nelem->child_add($query);

my $desiredAttrs = NaElement->new("desired-attributes");

my $desiredAutoSpace = NaElement->new("volume-autosize-attributes");

my $desiredIdAttr = NaElement->new("volume-id-attributes");

my $desiredSpace = NaElement->new("volume-space-attributes");

$desiredAttrs->child_add($desiredAutoSpace);

$desiredAttrs->child_add($desiredIdAttr);

$desiredAttrs->child_add($desiredSpace);

$nelem->child_add($desiredAttrs);

my $out = $server->invoke_elem($nelem);

This give always the 90 volumes. am I missing something?, if I set max-records to 1, I do 90 round trips to get all volumes. The fact is that I never get just one. Name and Junction-path are like primary keys, they should return just one.

Thanks for any advice!

7 REPLIES 7

rle
NetApp Alumni
4,818 Views

Please state the ONTAP version.

   - Rick -

rle
NetApp Alumni
4,818 Views

Also what is the format of the volume name you are using?

Are you using this API at the cluster or vserver level?

Regards,

   - Rick -

gasparuben
4,818 Views

This is how I define my NAserver:

  my ($ipaddr, ,$username, $password, $vserver) = @_;

          my $server = NaServer->new($ipaddr, 1, 17);

          $server->set_style("LOGIN");

          $server->set_admin_user($username, $password);

          $server->set_transport_type("HTTPS");

          $server->set_vserver($vserver);

I also set the vserver. All the volumes are defined for this vserver, called 'dbvs'.

I must say I dont understand the question about the name format. This are the properties of the volume I am trying to retrieve in this example:

cluster01::> vol show -vserver dbvs -volume edhp_backup01

  (volume show)

                                   Vserver Name: dbvs

                                    Volume Name: edhp_backup01

                                 Aggregate Name: aggr1_c01n01

                                    Volume Size: 1.05TB

                             Volume Data Set ID: 1120

                      Volume Master Data Set ID: 2147484772

                                   Volume State: online

                                    Volume Type: RW

                                   Volume Style: flex

                         Is Cluster-Mode Volume: true

                          Is Constituent Volume: false

                                  Export Policy: 10.16.3.0/25

                                        User ID: oracle

                                       Group ID: ci

                                 Security Style: unix

                               UNIX Permissions: ---rwxr-xr-x

                                  Junction Path: /backup/dbs01/EDHP

                           Junction Path Source: RW_volume

                                Junction Active: true

                         Junction Parent Volume: root_vol

Thanks for your help,

Ruben

gasparuben
4,818 Views

Hi Rick,

I am running Ontap 8.1.1 C-mode

THanks,

Ruben

rle
NetApp Alumni
4,818 Views

Hi Ruben -

I believe the above code is incorrect.

Here is how the XML should look:

<volume-get-iter>

        <query>

                <volume-attributes>

                        <volume-id-attributes>

                                <name>new_school</name>

                        </volume-id-attributes>

                </volume-attributes>

        </query>

        <desired-attributes>

                <volume-attributes>

                        <volume-export-attributes></volume-export-attributes>

                        <volume-id-attributes></volume-id-attributes>

                        <volume-space-attributes></volume-space-attributes>

                        <volume-state-attributes>

                                <state></state>

                        </volume-state-attributes>

                </volume-attributes>

        </desired-attributes>

</volume-get-iter>

The code above forgot the <volume-attributes>.

I will post some code on my blog at: https://communities.netapp.com/people/rle/blog.

Regards,

   - Rick -

rle
NetApp Alumni
4,818 Views

The code is now posted at: https://communities.netapp.com/people/rle/blog.

Regards,

   - Rick -

gasparuben
4,818 Views

Thanks Rick!

I test it in a moment. By the way,you get this nice layout of the XML document calling NAelement sprintf function?

Thanks again for your help!

Public