Reply

Need help running discover_now from NetMRI_Easy

[ Edited ]
Authority
Posts: 37
3966     0

 

This is as far as I have made it:

 

use strict;
use warnings;
use Data:Smiley Very Happyumper;
use NetMRI_Easy 0.6;


my $easy = new NetMRI_Easy({ api_version => 2.9 });
my $dev = $easy->device;


my $broker = $easy->broker->discovery_statuses;
print STDOUT "DUMPER: \$broker = ", Dumper $broker;

 

my %discover_hash = ( DeviceID => $dev->DeviceID, ignore_history_ind => 0 );

my $href = $broker->discover_now( \%discover_hash );

...

 

From the output file:

 

*

+++ Script-Filter ...................................................... MATCH
DUMPER: $broker = $VAR1 = bless( {
'client' => 0,
'_legacy' => 0
}, 'NetMRI::API::Broker::V2_9_0:Smiley Very HappyiscoveryStatuses' );

*** ERROR: Error 'NetMRI security/authentication-required Authentication is required to access this feature. http://netmri/api/2.9/discovery_statuses/discover_now.json at /mnt/host/script/6304376019496489375.ccs line 35

' ***

 

I thought since I was using NetMRI_Easy that the auth was already taken care of? It is if using "discover". I have been fighting with this all afternoon -- could someone help me understand what I am missing? Thanks in advance!!

Re: Anyone have a working example of using NetMRI_Easy to run discover_now?

Adviser
Posts: 357
3967     0
Are you running this externally from NetMRI? That is, NOT using the job engine? NetMRI_Easy is intended for use only when the script is being run by the job engine. Otherwise, you have to use the NetMRI::API client class directly.

John

Re: Anyone have a working example of using NetMRI_Easy to run discover_now?

Adviser
Posts: 357
3967     0

Oh, nevermind, I see from the output above you are running it in the job engine. That is very odd. It should already be authenticated.

Re: Anyone have a working example of using NetMRI_Easy to run discover_now?

Authority
Posts: 37
3967     0

Sorry, Within NetMRI. Using NetMRI 6.9.4. If I can get this to work the plan is to schedule it to deal with a problematic device that Discover Now from the GUI so far is the only thing that can back it up.

Re: Anyone have a working example of using NetMRI_Easy to run discover_now?

[ Edited ]
Adviser
Posts: 62
3967     0

Does the logged in NetMRI user have SysAdmin privileges ?

 

I am not a scripting expert myself and not sure, if this is needed. However, it would be nice, if you can try the same by using an account with SysAdmin privilege or the 'admin' account itself (if not already done)

Re: Anyone have a working example of using NetMRI_Easy to run discover_now?

Authority
Posts: 37
3967     0

Yes, I'm a SysAdmin. Sorry, should have mentioned that.

Re: Anyone have a working example of using NetMRI_Easy to run discover_now?

Authority
Posts: 37
3967     0

Any ideas anyone? I know I have seen some posts that make it sound do-able. Anyone have any example scripts that could help out? Thanks!

Re: Anyone have a working example of using NetMRI_Easy to run discover_now?

Authority
Posts: 32
3967     0

 

Could it be that NetMRI does not have credentials guessed for the device in question?  I mean, I assume the reason you want to do a "Discover Now" is that the device is not fully discovered?

 

NetMRI_Easy is designed with an underlying assumption that you intend to run CLI commands on the target device.  So, if you are running the script from NetMRI, and you select a particular device as the "target" of the job, the job engine automatically opens a CLI session to that device.  But if the device is not already fully discovered, that session is likely to fail since the credentials are not yet known.

 

I suspect that this will work if you disable the automatic login function, which you can do by adding the "Script-Login" option to the header block, like this:

 

# BEGIN-SCRIPT-BLOCK
#
# Script-Filter:
#     true
#
# Script-Login:
#     false
#
# END-SCRIPT-BLOCK


Note that, if Script-Login is set to "false", any NetMRI_Easy command that normally depends on having a CLI session, such as send_command() or log_message(), will cause the script to fail.

 

Re: Anyone have a working example of using NetMRI_Easy to run discover_now?

Authority
Posts: 37
3967     0

No, the DiscoverNow process is the only process that successfully backs this device up. I was told by Infoblox Support that the authorization failure is a bug in 6.4.9 that was fixed in 7.x (which doesn't help us since we cannot upgrade until later this year).

 

I just tried your idea and the script still fails with the same error. It's almost like discover_now doesn't like connections coming in on 127.0.0.1:80.

 

*** Error / HTTP 500 Can't connect to 127.0.0.1:80 (Connection refused) http://127.0.0.1/api/base_uri.json?version=2.9.0 at /mnt/host/script/518543103586703054.ccs line 45 
  
  ***
 Session log does not exist since there was an unknown error. 
Showing results for 
Search instead for 
Do you mean 

Recommended for You