def apply_config(device_ip, admin_username=None, password=None): """ Applies all 'PacketmasterEX' method calls listed to Packetmaster device. See packetmaster_ex_rest object class for methods. """ ex = PacketmasterEX(device_ip, admin_username, password) #Enter ReST API calls for configuration below this line. ex.set_port_config('1', '10G', 'full', False, False, False) ex.set_port_config('2', '10G', 'full', False, False, False) ex.set_port_config('3', '10G', 'full', False, False, False) ex.set_port_config('4', '10G', 'full', False, False, False) ex.add_rule({ 'name': '1 & 2 to 3', 'description': 'Inbound traffic on ports 1 and 2 is output on port 3', 'priority': 32768, 'match[in_port]': '1,2', 'actions': '3' }) ex.add_rule({ 'name': '10.0.0.5 to 4', 'description': 'Filter IP 10.0.0.5 out of inbound traffic on ports 1 and 2 and output on port 4; reinsert into traffic on port 3', 'priority': 50000, 'match[in_port]': '1,2', 'match[protocol]': 'ip', 'match[nw_src]': '10.0.0.5', 'actions': '3,4' }) ex.start_app_ntp('0.north-america.pool.ntp.org', '', 'Use pool.ntp.org for NTP') ex.set_hash_algorithms(False, False, False, False, True, True, True, True) ex.set_rule_permanence('y') ex.add_user('Bob', '7', 'bobby boy!', 'Network Engineer', False) ex.add_user('Jim', '7', 'Jimminy Cricket', 'Security Guy', False) ex.set_dns('9.9.9.9', '149.112.112.112') ex.set_uac('t') return "Configuration Applied."
def apply_config(ip_list, savename=None): for address in ip_list: pm = PacketmasterEX(address) if savename: pass #Enter ReST calls for configuration below this line pm.set_port_config('1', '10G', 'full', False, False, False) pm.set_port_config('2', '10G', 'full', False, False, False) pm.set_port_config('3', '10G', 'full', False, False, False) pm.set_port_config('4', '10G', 'full', False, False, False) pm.add_rule({ 'name': '1 & 2 to 3', 'description': 'Inbound traffic on ports 1 and 2 is output on port 3', 'priority': 32768, 'match[in_port]': '1,2', 'actions': '3' }) pm.add_rule({ 'name': '10.0.0.5 to 4', 'description': 'Filter IP 10.0.0.5 out of inbound traffic on ports 1 and 2 and output on port 4; reinsert into traffic on port 3', 'priority': 50000, 'match[in_port]': '1,2', 'match[protocol]': 'ip', 'match[nw_src]': '10.0.0.5', 'actions': '3,4' }) pm.start_app_ntp('0.north-america.pool.ntp.org', '', 'Use pool.ntp.org for NTP') pm.set_hash_algorithms(False, False, False, False, True, True, True, True) pm.set_rule_permanence('y') pm.add_user('Bob', '7', 'bobby boy!', 'Network Engineer', False) pm.set_dns('9.9.9.9', '8.8.8.8', '8.8.4.4') pm.set_uac('t')