Subscribe

storage_disk_get_iter not able to iterate over each attribute

Hi,

I am using perl api storage_disk_get_iter for 7-mode to get the disk details my code looks like below but i am not able to get desired output.

can someone please guide me how to iterate over each attribute list

$out = $s->invoke("storage-disk-get-iter");
if($out->results_status() eq "failed")
{
print($out->results_reason() ."\n");
exit(-2);
}
my $aggrs = $out->child_get("attributes-list");
my @aresult = $aggrs->children_get();

foreach $aggr (@aresult){
my $storage = $aggr->child_get("storage-disk-info");
my @get_info = $storage->children_get();
foreach $pat(@get_info){
my $get = $storage->child_get("disk-inventory-info");
my @good = $get->children_get();
foreach $met(@good){
my $raid_type = $pat->child_get_string("disk-type");
print "$raid_type";
}

Re: storage_disk_get_iter not able to iterate over each attribute

[ Edited ]

The NMSDK documentation has some sample code which might have what you need, or something very close.  In particular, look for the sample script named "vollist.pl".

 

What is the output you are wanting?

 

Andrew

If this post resolved your issue, please help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

Re: storage_disk_get_iter not able to iterate over each attribute

my want number of disk which are unowned + type of disk + reason of failed disk + rpm

 

i checked disk-list-info + sanown info...both of them dosen't have the all information 

Re: storage_disk_get_iter not able to iterate over each attribute

Hi,

The api parameters can vary depending of ontapi version.

You can use ZExplore Development Interface to see what is available with which version.

 

Here an example wirh Python in 1.21, where diskname, ownership, isfailed are retrieved. A lot of other information exist

 

import sys
from NaServer import *


PASSWORD= "xxxxx"

filer = NaServer("xxxxxx", 1 , 21)
filer.set_transport_type("HTTPS")
filer.set_port(443)
filer.set_server_type("FILER")

filer.set_style("LOGIN")
filer.set_admin_user("root", PASSWORD)

api = NaElement("storage-disk-get-iter")
api.child_add_string("max-records",500)

xo = filer.invoke_elem(api)

 

if (xo.results_status() == "failed") :
   print ("Error:\n")
   print (xo.sprintf())
   sys.exit (1)

 

attrib = xo.child_get("attributes-list")
disks = attrib.children_get()
for disk in disks:
   diskname = disk.child_get_string("disk-name")
   diskownership = disk.child_get("disk-ownership-info")
   diskfailed = diskownership.child_get_string("is-failed")
   print(diskname)
   print(diskfailed)
   print(diskownership.child_get_string("owner-node-id"))
   print("-------------------")