Maintenance is complete- We've moved from the saas.hpe.com domain to softwaregrp.com click to read more
As part of our journey to complete our separation work and our future integration with Micro Focus, we've now updated our domain for the community. This is an interim step, which will be followed by a series of future update / improvements: - Piloting Idea boards - Refreshing the entire UI. (more to come later) - and more
Network Automation Practitioners Forum
cancel

invoke HPNA Script from external

Yassir_1
Super Contributor.

invoke HPNA Script from external

Dear,

what is the easiest way to call a script defined in HPNA from an external application?

is the SOAP API the only interface, or is there may be alternative way?

if SOAP API is the only way, would you please be able to advise where to start?

many thanks

Yassir

3 REPLIES
Chris_Powers
Outstanding Contributor.

Re: invoke HPNA Script from external

Hi,

As far as I know, SOAP is the only way.  Now, you can use SOAP however you want - for example, Python, .Net, HP Operations Orchestration, Perl, etc...

You didn't mention your version, but I've attached a 10.20 API User Guide.  Check that out for some ideas / syntax...  

But, it's generally not too difficult - I added a basic Perl scriupt below:


#!/usr/bin/perl
use strict;
use warnings;
use Getopt::Long;
use Opsware::NAS::Connect;

my($host, $port, $user, $pass) = ('localhost','8023','user','passwd');
my @output;

my $con = Opsware::NAS::Connect->new(-user => $user, -pass => $pass, -host => $host, -port => $port);

$con->login();

print "run checkdb -resolver nnmforce\n";
@output = $con->cmd("run checkdb -resolver nnmforce");
print join("\n", @output);

In your case, you want to run a command script, so you'd have run command script and whatever variables you need (script name for example, etc).  For details there, find your current version "HP Network Automation Software (NA) CLI/API Command Reference".  

Hope this helps,

Chris

agonza
Super Contributor.

Re: invoke HPNA Script from external

Also, you can create a SOAP script and run it via "Run external application" task, so you can have a history about the script that you are runnig.

Chris_Powers
Outstanding Contributor.

Re: invoke HPNA Script from external

Hi, yes you "can" do that, but it's more dependent on your external script as to what details you may see in the Result and / or the Task Status.  

So, for example, you'll be able to see when it was run, who kicked it off, and typical things like that.  The results would just show what you see when you run it and that (again, depending on your script) may be limited.  

So, it may look like this:

Aug-31-1217 06:30:00              Run External Application - sync NNMi hostnames              Succeeded     3       me5                          Executed application: /home/me5/na_scripts/JythonForHPNA/JythonForHPNA/runAPI.sh Scripts/XX_######.py.

Application returned: 0


Result:
Starting Jython...
Opening session to 127.0.0.1:1099...
Executing the command: run checkdb -resolver nnmforce
Result:
Status: 200
Succeeded: true
StackTrace: null
Text: Successfully updated 83 device hostnames.
ResultSetMetaData: null
ResultSetData: null

Done
.
Script has finished!

Sorry data doesn't paste that well, but you'll get the idea of the columns the data belongs to.  

Hope this helps,

Chris