Active IQ Unified Manager Articles and Resources

How to: Using APIs in WFA with Perl and Clustered ONTAP


I wanted to be able to use perl to use the APIs to run commands against Clustered ONTAP, currently WFA does not have this functionality built in but if you would like to use Perl to write commands for Clustered ONTAP, here is how you can do that:

1. Download the attached WFAUtil.PM, here is what I actually added to it, basically I just copied the existing 7mode connection information and converted it to Clustered ONTAP friendly information:

sub connectCM {

          my ($self, $cmarray, $vserver) = @_;


          my $server = NaServer->new($cmarray, 1, 15);



          if (defined $vserver)





          my @credentials = getCredentials($self, $cmarray);


          if(defined @credentials[0] && defined @credentials[1])


  # use regular authentication


                    $server->set_admin_user($credentials[0], $credentials[1]);





  # use domain authentication



        # disable certification verification (since simulators have self signed certificates)




# connect over HTTPS and fall back to HTTP in case of failure

          my $result = checkConnectionCM($self, $server);

          if($result == 0)


  # connection over HTTPS failed - fall back to HTTP



  # chech the connection again

                    my $result = checkConnectionCM($self, $server);

                    if($result == 0)


  warn "\nUnable to connect to array\n";

                              exit 2;




          return $server;


sub checkConnectionCM {

          my ($self, $server ) = @_;


# invoke a command in order to verify connection

          my $output = $server->invoke( "system-get-ontapi-version" );

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


  # failed to establish connection

  return 0;




  # successfully connected

  return 1;



2. Place the WFAUtil.PM in your perl library folder on your WFA server

3. You can use the attached command as an example for how it works


Please Note:

All content posted on the NetApp Community is publicly searchable and viewable. Participation in the NetApp Community is voluntary.

In accordance with our Code of Conduct and Community Terms of Use, DO NOT post or attach the following:

  • Software files (compressed or uncompressed)
  • Files that require an End User License Agreement (EULA)
  • Confidential information
  • Personal data you do not want publicly available
  • Another’s personally identifiable information (PII)
  • Copyrighted materials without the permission of the copyright owner

Continued non-compliance may result in NetApp Community account restrictions or termination.


Excellent Post. 5 Stars.


I agree.  Truely awesome stuff!


Great stuff! thanks!


Nice info.Helpful.thnks.

One question..

I want to create new User and role in the filer using the WFA(I wanna perl code for that).Can you plz share with me if you have code for that?.

I have tried with below code..but not working..


use strict;

use warnings;

use  NaServer;

use NaElement;

use Getopt::Long;

use WFAUtil;

our $array;our $server;our $vfiler;our $RoleName;our $comment;our $CapaName;our $api;our $xi1;

GetOptions("array=s" => \$array,

                 "RoleName" => \$RoleName,

                       "comment"   =>  \$comment,

                       "CapaName"  =>  \$CapaName

             ) or die "Illigal Options";

if(!  defined $array){ die "Array Name/ip Address is mendatory";}

my $wfautil=WFAUtil->new();

$wfautil->sendLog('INFO','Connecting to array:',$array);


my $api = WFAUtil->new('useradmin-role-add');

my $xi = WFAUtil->new('useradmin-role');


my $xi2 = WFAUtil->new('allowed-capabilities');

my $xi1->child_add($xi2);

my $xi3 = WFAUtil->new('useradmin-capability-info');





my $xi4=$wfautil->checkFailure("Failed to run the command",$server->invoke($api));

$wfautil->sendLog('INFO','Create the role for the user failed'.$array);

Thanks in advance..



Thanks in advance..

All Community Forums