Having been chipping away at this problem, and with thanks to the excellent "toasters" mailing list (Archive) - my eventual solution was to make use of the system-cli
API call.
#!/usr/bin/env perl
use strict;
use warnings;
use XML::Twig;
use LWP;
my $twig = XML::Twig->new( 'pretty_print' => 'indented' );
$twig->set_root(
XML::Twig::Elt->new(
'netapp',
{ version => 1.7,
vfiler => "somevfiler",
xmlns => "http://www.netapp.com/filer/admin",
},
)
);
my $api_req = $twig->root->insert_new_elt('system-cli');
my $args = $api_req->insert_new_elt('args');
$args->insert_new_elt( 'last_child', 'arg', 'df' );
$args->insert_new_elt( 'last_child', 'arg', '-k' );
$twig->set_doctype('netapp SYSTEM "file:/etc/netapp_filer.dtd"');
$twig->set_xml_version("1.0");
$twig->set_encoding('utf-8');
$twig->print;
exit;
my $user_agent = LWP::UserAgent->new(
'ssl_opts' => {
'verify_hostname' => 0,
'SSL_version' => 'SSLv3',
}
);
my $request =
HTTP::Request->new( 'POST' =>
'https://myfilername/servlets/netapp.servlets.admin.XMLrequest_filer'
);
$request->authorization_basic( 'username_here', 'password_here' );
$request->content( $twig->sprint );
my $results = $user_agent->request($request);
if ( not $results->is_success ) {
print "Error: ", $results->status_line;
exit;
}
my $results_xml = XML::Twig->new( 'pretty_print' => 'indented_a' );
$results_xml->parse( $results->content );
$results_xml->print;
This works to capture the results of a df -k
via an API call. But there's just one drawback - you only get a plain text 'command output' blob, which you then have to parse yourself anyway, so you don't really gain much over ssh hostname df -k
- just a different authentication and fetch method, but that's really what I was after.
Also of note - this does't use the NetApp SDK. You might consider that an advantage or not. Personally I find XML::Twig
and LWP
quite good to work with - YMMV.
Anyway - other suggestions include:
ssh hostname df -k
- use SNMP to query it
- to a two pass API call, first to enumerate, second to query.