Software Development Kit (SDK) and API Discussions

Error when using children get from “system-info"

Sokun
2,023 Views

My customer has a question after using the SDK.

 

Below is the output of the API script as well as the script’s code. Can someone please provide some guidance if he is doing something wrong?

 

"Basically, I would like to pull the system information by invoking API “system-get-info”, and down to children get from “system-info”. Unfortunately, I am getting the hash element but the system does not return any output when I try to call the child_get_string under system-info."

 

Output of the script:

 

XX11p00XX-storagedb001:/api_script => ./api_test 

System Name   

System Model  

System Name   

System Model  

System Name   

System Model  

System Name   

System Model  

System Name   

System Model  

System Name   

System Model  

System Name   

System Model  

System Name   

System Model  

System Name   

System Model  

System Name   

System Model  

System Name   

System Model  

System Name   

System Model  

System Name   

System Model  

System Name   

System Model  

System Name   

System Model  

System Name   

System Model  

System Name   

System Model  

System Name   

System Model  

System Name   

System Model  

System Name   

System Model  

 

======================

Script’s code:

 

#!/usr/bin/perl

 

use lib "/Netapp/lib/perl/NetApp"; 

use NaServer;

use NaElement;

use Path::Class;

use autodie;

use Time::Piece;

use MIME::Lite;

 

# Variable declaration

my $user = dfmuser;

my $pw = xxxxxx;

my $filer = "XX11p08XX-filerm08512";

 

my $s = NaServer->new ($filer, 1, 13);

        my $response = $s->set_style(LOGIN);

        if (ref ($response) eq "NaElement" && $response->results_errno != 0)

        {

                my $r = $response->results_reason();

                print "Unable to set authentication style $r\n";

                exit 2;

        }

        $s->set_admin_user($user, $pw);

        $response = $s->set_transport_type("HTTPS");

        $s->set_port(443);

        if (ref ($response) eq "NaElement" && $response->results_errno != 0)

        {

                my $r = $response->results_reason();

                print "Unable to set HTTPs transport $r\n";

                exit 2;

        }

 

my $out = $s->invoke("system-get-info");

if ($out->results_status() eq "failed"){

print($out->results_reason() ."\n");

exit (-2);

}

 

my $status = $out->child_get("system-info");

if ($status == "")

{

print " status_children_get was empty\n";

exit (0);

}

 

@result = $status->children_get();

foreach $line (@result)

{

print "System Name ";

print (" ");

print ($line->child_get_string("system-name"));

print " \n";

print "System Model ";

print (" ");

print ($line->child_get_string("system-model"));

print "\n";

}

1 REPLY 1

richard_payne
1,953 Views

This is 7mode, correct?

 

If you change:

 

@result = $status->children_get();

foreach $line (@result)

 

to:

 

foreach my $line ($out->children_get())

 

I think you'll get what you are looking for. I usually find it helpful to do a 'print Dumper($out)' if I'm working with new API calls, to get an idea of what the return structure looks like.

 

BTW, perl doesn't like this either:

if ($status == "")

 

I think it wants:

if ($status eq "")

 

since it's not a numeric comparison.

 

--rdp

Public