Quantcast
Channel: Infoblox Community - Infoblox Community Blog
Viewing all articles
Browse latest Browse all 76

NetMRI Scripting: Add Networks to Discovery

$
0
0

This script takes the Networks in DDI and then add them to NetMRI Discovery

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

use strict;
use warnings;
use NetMRI_Easy;
my $easy = new NetMRI_Easy;

# Connect to the NetMRI
my $easyddi = new NetMRI_Easy({ nios_api => 1,
    nios_ipaddress => "172.23.22.212",
    nios_username  => "admin",
    nios_password  => "infoblox"
});

# Connect to DDI
my $ddi_session = $easyddi->nios_session;
$easy->log_message('info', 'Session created successfully');

# log the DDI version
my $ddi_version = $ddi_session->server_version();
$easy->log_message('info', 'Version: '.$ddi_version);

#Search for the Networks with in DDI
my @_network_objs = $ddi_session->
search(    object       => "Infoblox::DHCP::Network",    network      => ".*",    network_view => "default");

#Add of the Networks returned from searching DDI into NetMRI as Discovery Range
$easy->log_message('info', 'The following Networks will be added to the INCLUDE');

foreach my $network_obj (@_network_objs) {
    my $network_val = sprintf("%s", $network_obj->network());
    $easy->log_message('info', 'Network to Include in Discovery : '.$network_val);
    my $devices = $easy->broker->discovery_settings->
    create({        range_value    => '$network_val',        range_type     => 'RANGE',        discovery_status => 'INCLUDE', });
}

Tags: 


Viewing all articles
Browse latest Browse all 76

Trending Articles