Reply
Highlighted

broker->script->run not working (PERL)

csi-net
Techie
Posts: 14
5201     0

Hello,

I'd like to run netmri CSS script from external PERL script and get the output file that I'm generatinq with this script.

(connection with netmri appliance work because I'm able to use other API and get correct output from them).

The script run on netmri but I get the below error and I'm not able to get access to remote files generated by the script ot the Jobid.

 

here the PERL script:

 

 

########### PERL script ##############

 

my $script = $client->broker->script->run({
name => 'testscript',
wait => 60,
device_ids => 83,
})->{JobID};

print "JobID :", $script, "\n";

 

#####################################

 

But as I run the script I get the folowing error

 

SERVER general/unexpected-error SQL::Error https://x.x.x.x/api/3.1/scripts/run.json at ./testnetmri4.pl line 48

line 48 is: my $script = $client->broker->script->run

 

 

thank you in advance ..

 

Re: broker->script->run not working (PERL)

csi-net
Techie
Posts: 14
5202     0

 

I get aroud the issue I used "broker->script->run" without input "wait" this will return me the Jobid.

I'll use Jobid with broker->job->search to get the status and as it is OK I'll get the filesname and file content with

broker->job->job_files.

 

 

Re: broker->script->run not working (PERL)

Expert
Posts: 185
5202     0

Well, after much head-banging, I found this post and removed "wait" and wha-la, it returns the job id.  

 

Sif / Ingmar - do you think you could get this fixed?  It fails in the API, it would be nice to have the wait param work as documented and return the payload Smiley Happy

 

# This one will fail - 
https://mynetmri/api/3.2/scripts/run?name=Ad%20Hoc%20Command%20Batch&device_ids=1989994802611670135&$commands_to_be_executed=show%20ver&credential_mode=manual&name=NW%20-%20Ad%20Hoc%20Command%20Batch&username=mynetmri&password=mypass&wait=600

# This one will work - 
https://mynetmri/api/3.2/scripts/run?name=Ad%20Hoc%20Command%20Batch&device_ids=1989994802611670135&$commands_to_be_executed=show%20ver&credential_mode=manual&name=NW%20-%20Ad%20Hoc%20Command%20Batch&username=mynetmri&password=mypass

Re: broker->script->run not working (PERL)

Expert
Posts: 185
5202     0

...and I did try in a script and passed the 'wait':'600' (as a string rather than an integer), but still get requests.exceptions.HTTPError: {u'message': u'SQL::Error', u'error': u'general/unexpected-error'}

Re: broker->script->run not working (PERL)

[ Edited ]
Expert
Posts: 185
5202     0

This issue has been resolved now via a hotfix.

v7.3.2-NETMRI-31568.gpg or v7.3.1-NETMRI-31427.

 

https://netmri/api/3.2/scripts/run?name=TestPayloadAPI&device_ids=2298094239504921600&credential_mode=manual&name=TestPayloadAPI&username=myusername&password=mypassword&wait=600

# BEGIN-SCRIPT-BLOCK
#
# Script-Filter:
#    true
#
# Script-Variables:
#    $command word "show version"
#
# END-SCRIPT-BLOCK
 
use strict;
use warnings;
use NetMRI_Easy;
 
# script variables are provided as a global
# variable from the NetMRI job engine.
 
# Connect to the NetMRI
my $easy = new NetMRI_Easy;
 
# post the output of the command as a payload in JSON format.
$easy->write_payload($easy->send_command("show version"));

Should return something like:

<response>
<JobID type="int">76847</JobID>
<Status>OK</Status>
<Payload>
["Cisco IOS Software, C3750E Software (C3750E-UNIVERSALK9-M), Version 15.2(2)E8, RELEASE SOFTWARE (fc1)\nTechnical Support: http://www.cisco.com/techsupport\nCopyright (c) 1986-2018 by Cisco Systems, Inc.\nCompiled Mon 22-Jan-18 04:07 by prod_rel_team\n\nROM: Bootstrap program is C3750E boot loader\nBOOTLDR: C3750E Boot Loader (C3750X-HBOOT-M) Version 12.2(53r)SE2, RELEASE SOFTWARE ...]
</Payload>
</response>
Showing results for 
Search instead for 
Do you mean 

Recommended for You