Software Development Kit (SDK) and API Discussions

sdk -perl - getting snap_used ontapi 1.9

kfelipe
4,082 Views

Hello folks,


we are trying to automate quota assignment on qtrees and to do so, we need to get first some figures about volume occupancy (newbie - very first program).
We are ontapi 1.9 7-mode and I managed to get almost all data that we need except snapshot occupancy.

This is the output of df in the column used for a volume

 

cdcsx077:~ # ssh user@nat002 df /vol/<volumename>/.snapshot

Filesystem kbytes used avail capacity Mounted on
/vol/<volumename>/ 145920 31424 114496 22% /vol/<volumename>/
/vol/<volumename>/.snapshot 7680 27940 0 364% /vol/<volumename>/.snapshot

I basically would like to get 27940 or at least (27940 - 7680)

And this is important not to offer this amount of space to the end user.

Please, could you point me out how to get it? I got blind looking at the API, I also installed Zexlorer and parse many xmls, with no success.

I'd be a pitty if we had to revert sdk to rsh to solve this. I'd appreciate any suggestion.
Regards,
Felipe

1 ACCEPTED SOLUTION

chris_algar
4,016 Views

 

There are a number of gaps in the SDK coverage. This has been the case for years and contunies to be frustrating. I've never managed to get a comittment from NetApp to fix the gaps.

 

To avoid falling back to an alternate conneciton method you can send CLI commands over the existing HTTP(S) connection using a NaElelemt type 'system-cli'. I have no idea if this is supported or not, but I use it extensively to plug gaps in the SDK.

 

this is an exmple method from my OO API. I don't know your coding style (and this page will kill my indentation, so ignore that) but you should get the idea.

 

sub get_snapshot_used {

# Workaround API gap

my $self = shift;

$self->verbose;
$self->debug( { Passed => \@_ } );

my $serv = $self->get_classic->get_naserver;

($serv)
  || croak ( "No naserver object bound" );

my $name = $self->get_name();

my $cmd = NetAppApi::NaElement->new("system-cli");
my $cmd_args = NetAppApi::NaElement->new("args");

$cmd_args->child_add(NetAppApi::NaElement->new ("arg", "df"));
$cmd_args->child_add(NetAppApi::NaElement->new ("arg", "$name"));

$cmd->child_add($cmd_args);

my $output = $serv->invoke_elem( $cmd );

$self->debug( { Response => $output } );

if ( $output->results_status() eq "failed" ) {
croak (
"Unable to run system-cli $cmd,\n",
$output->results_reason() . "\n"
);
}

my @lines = split /\n/,$output->child_get_string("cli-output");;

my $used;

LINE:
for my $line (@lines){

#/vol/<name>/.snapshot 7680 27940 0 364% /vol/<volumename>/.snapshot

if ($line =~ m/$name\/.snapshot/){

my @parts = split /\s+/,$line;

$used = $parts[2];
last LINE;

}

}

return $used;
}

View solution in original post

4 REPLIES 4

chris_algar
4,017 Views

 

There are a number of gaps in the SDK coverage. This has been the case for years and contunies to be frustrating. I've never managed to get a comittment from NetApp to fix the gaps.

 

To avoid falling back to an alternate conneciton method you can send CLI commands over the existing HTTP(S) connection using a NaElelemt type 'system-cli'. I have no idea if this is supported or not, but I use it extensively to plug gaps in the SDK.

 

this is an exmple method from my OO API. I don't know your coding style (and this page will kill my indentation, so ignore that) but you should get the idea.

 

sub get_snapshot_used {

# Workaround API gap

my $self = shift;

$self->verbose;
$self->debug( { Passed => \@_ } );

my $serv = $self->get_classic->get_naserver;

($serv)
  || croak ( "No naserver object bound" );

my $name = $self->get_name();

my $cmd = NetAppApi::NaElement->new("system-cli");
my $cmd_args = NetAppApi::NaElement->new("args");

$cmd_args->child_add(NetAppApi::NaElement->new ("arg", "df"));
$cmd_args->child_add(NetAppApi::NaElement->new ("arg", "$name"));

$cmd->child_add($cmd_args);

my $output = $serv->invoke_elem( $cmd );

$self->debug( { Response => $output } );

if ( $output->results_status() eq "failed" ) {
croak (
"Unable to run system-cli $cmd,\n",
$output->results_reason() . "\n"
);
}

my @lines = split /\n/,$output->child_get_string("cli-output");;

my $used;

LINE:
for my $line (@lines){

#/vol/<name>/.snapshot 7680 27940 0 364% /vol/<volumename>/.snapshot

if ($line =~ m/$name\/.snapshot/){

my @parts = split /\s+/,$line;

$used = $parts[2];
last LINE;

}

}

return $used;
}

kfelipe
3,974 Views

Thanks for your reply Chris!

Yesterday I tested with Zexplorer and it worked, but wanted to create a function before replying, now I tested it and it works too. Perhaps it helps others.

 

 

 

 

liesc
3,986 Views

If you don't want to use the, for all intents and purposes, hidden, system-cli element, you can get what you are looking for with a little bit of collection and math.

 

snapshot-list-info returns 'total', the total number of 1024 byte blocks in a snapshot.

volume-list-info returns 'size-total', the total useable size in bytes of the volume (not including WAFL reserve or snapshot reserve). If you are using snap reserve, you'll have to take into accout the 'snapshot-blocks-reserve' value.

kfelipe
3,968 Views

Thanks Liesc

Perhaps I am missing how to get the information, I tried to collect it from snapshot-list-info and getting the info not with total but wiht cumulative-total  .
It just gives me a value that it does not match with df output:

<!-- last snapshot -->
<total>84</total>
<cumulative-total>1676</cumulative-total>
while df gives me:

/vol/<volname>/.snapshot 7680 28528 0 371% /vol/<volname>/.snapshot

 

I'd appreciate if you could explain me a bit more how to do the math with the data, I'd indeed prefer to use the sdk methods instead of the ssh backdoor.
Basically I want to get 28528 to substract to the volume reserved space, and this becomes the snap_delta, which cannot be shown as free to the end user. (Final goal is that this advanced users handle quotas themselfs, and this is to create proper limits)
I am not a Netapp admin, but my colleagues have also told me that perhaps this snapshot-list-info is based on snap list and if so, it can cause performance problems on big systems.

 

 

 

 

Public