NetApp Community Update
This site will enter Read Only mode on July 23 as we prepare to move to a new platform. You will still be able to view content, but posting and replying will be temporarily disabled.
We're excited to launch our new Community experience on July 30 and more information will follow soon.
Stay connected during the transition - Join our Discord community today.

Software Development Kit (SDK) and API Discussions

filestats command using system-cli API

haritha_n
5,934 Views

filestats command is available in CLI (an example below):

[root]# rsh myfiler filestats volume myvolume snapshot mysnapshot

VOL=myvolume SNAPSHOT=mysnapshot

INODES=983031 COUNTED_INODES=39845 TOTAL_BYTES=8725924057 TOTAL_KB=8586296

...

I am trying to run the same command using system-cli API. The API runs fine, no error is reported, but, I can't see any output in "cli-output".

use NaServer;

use NaElement;

use Data::Dumper;

my $filer = "myfiler";

my $volume = "myvolume";

my $snapshot = "mysnapshot";

my $user = "<user>";

my $passwd = "<passwd>";

my $api = NaServer->new( $filer, 1, 4 );

$api->set_style("LOGIN");

$api->set_admin_user($user, $passwd);

$api->set_transport_type(NA_SERVER_TRANSPORT_HTTP);

my $cmd      = new NaElement('system-cli');

my $cmd_args = new NaElement('args');

my @arg_arr  = ('filestats', 'volume', $volume, 'snapshot', $snapshot);

foreach my $arg (@arg_arr)

{

    $cmd_args->child_add(new NaElement('arg', $arg));

}

$cmd->child_add($cmd_args);

my $result = $api->invoke_elem($cmd);

print "Result ". Dumper($result) . "\n";

if ($result->results_errno != 0)

{

  my $reason = $out->results_reason();

  print "Invoke Failed: $reason\n";

}

my $output = $result->child_get_string("cli-output");

print "Output: " . Dumper($output) . "\n";

When I run this script, I see:

% perl test_filestats.pl

Result $VAR1 = bless( {

                 'content' => '',

                 'name' => 'results',

                 'children' => [

                                 bless( {

                                          'content' => '',

                                          'name' => 'cli-output',

                                          'children' => [],

                                          'attrvals' => [],

                                          'attrkeys' => []

                                        }, 'NaElement' ),

                                 bless( {

                                          'content' => '1',

                                          'name' => 'cli-result-value',

                                          'children' => [],

                                          'attrvals' => [],

                                          'attrkeys' => []

                                        }, 'NaElement' )

                               ],

                 'attrvals' => [

                                 'passed'

                               ],

                 'attrkeys' => [

                                 'status'

                               ]

               }, 'NaElement' );

Output: $VAR1 = '';

So, there is no error, but, no output either. Am I invoking the API in a wrong way? How to get the output of filestats command through system-cli call?

Thanks,

Haritha

3 REPLIES 3

rle
NetApp Alumni
5,934 Views

Hi Haritha -

I don't know what version of ONTAP you're running, but this sounds like burt 400086 which was fixed in ONTAP 8.0.2.

Also, a good debugging technique would be to do: print $cmd->sprintf() . "\n"; to verify the element input.

Regards,

   - Rick -

haritha_n
5,934 Views

Thanks Rick. I am running  ONTAP 7.3.4P4 version.

Thanks for the "sprintf" tip. It confirmed that the input is correct:

   Debug Command input :

     <system-cli>

        <args>

                <arg>filestats</arg>

                <arg>volume</arg>

                <arg>myvolume</arg>

                <arg>snapshot</arg>

                <arg>mysnapshot</arg>

        </args>

    </system-cli>

If any of you have access to ONTAP 8.0.2 or later versions, can you try running similar command and confirm that it works in 8.0.2+? Based on this information, I will have to recommend upgrade to the required ONTAP version as well as suggest a workaround for earlier versions.

Thanks,

Haritha

chris_algar
5,665 Views

 

I am also seeing this problem for system-cli for ndmpd commands in various 7.3.x releases. Does anyone have a list of which commands are not funcional via system-cli, and if this has been fixed for the general case so that all cli commands for which there is no spcific API call can be issued via system-cli.

 

I'd like to write a full coverage API for 7-Mode using the HTTPS connector, to do so I need to know what the target release for full coverage should be.

 

Thanks

Public