Infoblox’s global team of threat hunters uncovers a DNS operation with the ability to bypass traditional security measures and control the Great Firewall of China. Read about “Muddling Meerkat” and the many other threat actors discovered by Infoblox Threat Intel here.

How-to Articles

containerblogpic.jpg

NetMRI - Python Script to Get Data from a List

 Here is an example of how to use Python in NetMRI to get data from "List" within NetMRI 

 

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

from infoblox_netmri.easy import NetMRIEasy

# This values will be provided by NetMRI before execution 
defaults = {
   "api_url": api_url,
   "http_username": http_username,
   "http_password": http_password,
   "job_id": job_id,
   "device_id": device_id,
   "batch_id": batch_id
}

# Create NetMRI context manager. It will close session after execution
with NetMRIEasy(**defaults) as easy:
    # Everything has to be indented under the context manager if we are sending commmands to NetMRI
    #
    # This is how you get a list named "sif_test" and look up column "name" that contains "device_devicename" and get what's in the "location" column
    #
    mylocation = easy.get_list_value("sif_test", "name", device_devicename,"location", "null");
    print (mylocation)

 

I just printed it out here if we wanted to apply it to a config here is a better example, of course, I didn't put in an if statement to check if "null", do not apply the snmp-server location.  Feel free to add it

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

from infoblox_netmri.easy import NetMRIEasy

# This values will be provided by NetMRI before execution
defaults = {
   "api_url": api_url,
   "http_username": http_username,
   "http_password": http_password,
   "job_id": job_id,
   "device_id": device_id,
   "batch_id": batch_id 
}

# Create NetMRI context manager. It will close session after execution
with NetMRIEasy(**defaults) as easy:
    # Everything has to be indented under the context manager if we are sending commmands to NetMRI
    #
    # This is how you get a list named "sif_test" and look up column "name" that contains "device_devicename" and get what's in the "location" column
    #
    mylocation = easy.get_list_value("sif_test", "name", device_devicename,"location", "null");
    command = "snmp-server location {}".format(mylocation)
    easy.send_command("config t\r")
    easy.send_command(command)

 

Showing results for 
Search instead for 
Did you mean: