Пример #1
0
 def test_easy_send_command(self):
     init_data = {'device_id': 1, 'job_id': 1, 'batch_id': 1}
     init_data.update(self.opts)
     with NetMRIEasy(**init_data) as easy:
         with patch.object(easy.client.session,
                           'request',
                           side_effect=send_command_result) as mock_request:
             res = easy.send_command("show info")
             self.assertEquals(res, "OK")
Пример #2
0
 def test_easy(self):
     init_data = {'device_id': 1, 'job_id': 1, 'batch_id': 1}
     init_data.update(self.opts)
     with NetMRIEasy(**init_data) as easy:
         self.assertEquals(easy.device_id, 1)
         self.assertEquals(easy.job_id, 1)
         self.assertEquals(easy.batch_id, 1)
         self.assertIsNotNone(easy.dis_session)
         self.assertIsNotNone(easy.cli_connection)
Пример #3
0
# BEGIN-SCRIPT-BLOCK
#
# Script-Filter:
#     true
#
# END-SCRIPT-BLOCK

from infoblox_netmri.easy import NetMRIEasy
import re

# 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,
    "script_login": "******"
}

# Create NetMRI context manager. It will close session after execution
with NetMRIEasy(**defaults) as easy:
    subnet_broker = easy.client.get_broker('Subnet')
    all_subnets = subnet_broker.index
    print(all_subnets)
    params = {'select': 'SubnetCIDR'}
    results = all_subnets(**params)
    for entry in results:
        print(entry.SubnetCIDR)
Пример #4
0
                        easy.log_message(
                            "debug",
                            f"[-] DEBUG: target.dis.send_command({cmd})")
                    else:
                        target.dis.send_command(cmd)

            # Now add the "good" relays in from the list.
            for goodrelay in auth_relays:
                easy.log_message(
                    "info", f"[+] ... Adding {goodrelay} "
                    f"to {target.relay_intfs[intf_id]['name']}")
                cmd = relay_cmd_prefix + str(goodrelay)
                if dry_run == "on":
                    easy.log_message(
                        "debug", f"[-] DEBUG: target.dis.send_command({cmd})")
                else:
                    target.dis.send_command(cmd)

        # Exit and commit config to memory..
        if dry_run == "off":
            target.exit_global_config(True)

    # All done!
    easy.log_message("info", f"[+] SUCCESS: Job completed for {target.name}")
    exit(0)


if __name__ == "__main__":
    with NetMRIEasy(**easyparams) as easy:
        main(easy)
import requests, json, re
from infoblox_netmri.easy import NetMRIEasy
import time

# 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
}

myeasy = NetMRIEasy(**defaults)
broker = myeasy.broker('ConfigTemplate')
sif = {
   "id" : '35',
   "device_ids" : device_id,
   "$sif" : 'siftest',
   "$templatemode" : 'bulk'
}
broker.run (**sif)

broker_script = myeasy.broker('Script')

save_new = {
    "name" : "sif_adhoc",
    "device_ids" : device_id,
    "job_name" : "Save New Config"