From 70d5f43a20f9cdd1f7c713a139eda273e3fecd39 Mon Sep 17 00:00:00 2001 From: David Barroso Date: Fri, 27 Nov 2015 12:42:02 +0100 Subject: [PATCH 01/11] Major enhancements to tests --- test/unit/TestFortiOSDriver.py | 39 +++++- ...diagnose_hardware_deviceinfo_nic_mgmt2.txt | 42 ++++++ ...diagnose_hardware_deviceinfo_nic_port1.txt | 93 ++++++++++++++ .../get_system_dns_|_grep_domain.txt | 1 + .../get_system_interface_|_grep_==.txt | 15 +++ .../get_system_performance_status.txt | 12 ++ .../fortios/mock_data/get_system_status.txt | 24 ++++ .../fortios/mock_data/system_interface.txt | 121 ++++++++++++++++++ 8 files changed, 345 insertions(+), 2 deletions(-) create mode 100644 test/unit/fortios/mock_data/diagnose_hardware_deviceinfo_nic_mgmt2.txt create mode 100644 test/unit/fortios/mock_data/diagnose_hardware_deviceinfo_nic_port1.txt create mode 100644 test/unit/fortios/mock_data/get_system_dns_|_grep_domain.txt create mode 100644 test/unit/fortios/mock_data/get_system_interface_|_grep_==.txt create mode 100644 test/unit/fortios/mock_data/get_system_performance_status.txt create mode 100644 test/unit/fortios/mock_data/get_system_status.txt create mode 100644 test/unit/fortios/mock_data/system_interface.txt diff --git a/test/unit/TestFortiOSDriver.py b/test/unit/TestFortiOSDriver.py index 3e7b8d3..52ca2b5 100644 --- a/test/unit/TestFortiOSDriver.py +++ b/test/unit/TestFortiOSDriver.py @@ -15,10 +15,11 @@ import unittest from napalm.fortios import FortiOSDriver -from base import TestNetworkDriver +from base import TestConfigNetworkDriver, TestGettersNetworkDriver +from pyFG.fortios import FortiConfig -class TestFortiOSDriver(unittest.TestCase, TestNetworkDriver): +class TestConfigFortiOSDriver(unittest.TestCase, TestConfigNetworkDriver): @classmethod def setUpClass(cls): @@ -29,3 +30,37 @@ class TestFortiOSDriver(unittest.TestCase, TestNetworkDriver): cls.device = FortiOSDriver(hostname, username, password, timeout=60) cls.device.open() + + +class TestGetterFortiOSDriver(unittest.TestCase, TestGettersNetworkDriver): + + @classmethod + def setUpClass(cls): + cls.mock = True + + hostname = '192.168.56.201' + username = 'vagrant' + password = 'vagrant' + cls.vendor = 'eos' + + cls.device = FortiOSDriver(hostname, username, password, timeout=60) + + if cls.mock: + cls.device.device = FakeFortiOSDevice() + else: + cls.device.open() + + +class FakeFortiOSDevice: + @staticmethod + def read_txt_file(filename): + with open(filename) as data_file: + return data_file.read().splitlines() + + def execute_command(self, command): + return self.read_txt_file('fortios/mock_data/{}.txt'.format(command.replace(' ', '_'))) + + def load_config(self, config_block): + self.running_config = FortiConfig('running') + self.running_config.parse_config_output(self.read_txt_file('fortios/mock_data/{}.txt'.format( + config_block.replace(' ', '_')))) \ No newline at end of file diff --git a/test/unit/fortios/mock_data/diagnose_hardware_deviceinfo_nic_mgmt2.txt b/test/unit/fortios/mock_data/diagnose_hardware_deviceinfo_nic_mgmt2.txt new file mode 100644 index 0000000..30d63c6 --- /dev/null +++ b/test/unit/fortios/mock_data/diagnose_hardware_deviceinfo_nic_mgmt2.txt @@ -0,0 +1,42 @@ +Description Broadcom 570x Tigon3 Ethernet Adapter +Part_Number BCM95718 +PHY_Device_ID 5718C +Driver_Name tg3 +Driver_Version 3.85l +PCI_Vendor 0x14e4 +PCI_Device_ID 0x1656 +PCI_Subsystem_Vendor 0x14e4 +PCI_Subsystem_ID 0x1656 +PCI_Revision_ID 0x5717100 +PCI_Address 5:0.1 +Memory 0xefe30000 +IRQ 17 +System_Device_Name mgmt2 +Current_HWaddr 00:09:0f:09:00:01 +Permanent_HWaddr 08:5b:0e:7a:66:83 +Link down +Speed N/A +FlowControl N/A +Rx_Packets 0 +Rx_Packets_Dropped 0 +Tx_Packets 0 +Rx_Bytes 0 +Tx_Bytes 0 +Rx_Errors 0 +Tx_errors 0 +Multicast 0 +Collisions 0 +Rx_Length_Errors 0 +Rx_Over_Errors 0 +Rx_Frame_Errors 0 +Tx_aborted_Errors 0 +Tx_carrier_errors 0 +Rx_CRC_Errors 0 +rx_pending 200 +tx_pending 511 +tg3_flags a648e425 +tg3_flags2 180c9600 +tg3_flags3 00603003 +rx_rcb_ptr 00000000 +rx_producer 00000000 +num_reset 0 diff --git a/test/unit/fortios/mock_data/diagnose_hardware_deviceinfo_nic_port1.txt b/test/unit/fortios/mock_data/diagnose_hardware_deviceinfo_nic_port1.txt new file mode 100644 index 0000000..0ae5a3b --- /dev/null +++ b/test/unit/fortios/mock_data/diagnose_hardware_deviceinfo_nic_port1.txt @@ -0,0 +1,93 @@ +Description :FortiASIC NP4 Adapter +Driver Name :FortiASIC Unified NPU Driver +Version :1.0 +PCI Slot :01:00.0 +PCI_Revision_ID :1 +Board :fgt800c +SN :FG800C3914800949 +Major ID :19 +Minor ID :0 +LIF ID :1 +NPU OID :1 +NPU OID_VID :3 +netdev flags :0x00001303 +Current_HWaddr 00:09:0f:09:00:02 +Permanent_HWaddr 08:5b:0e:7a:66:69 +Queue :On +rx_buffer_len :2048 +max_frame_size :1522 +min_frame_size :278 +MTU :1500 +Hidden :No +dyn_lif :0 +npu_cap :0000601f +ses_mask :40027dcb +cmd_in_queue :0 +half_id :1 +phy_addr :0x01 +phy_flags :0x4002 +medium_type :Copper +sw_port :3 +sw_np_port :29 +sw_stats_port :0 +phy_oid :0x01 +slot_id :0x00 +vid_phy[6] :[0003][0000][0000][0000][0000][0000] +vid_fwd[6] :[0000][0000][0000][0000][0000][0000] +oid_fwd[6] :[0000][0000][0000][0000][0000][0000] +========== Link Status ========== +Admin :up +PHY Status :up +PHY Speed :1000 +Duplex :Full +link_status :1 +rx_link_status :1 +remote_fault :0 +local_fault :0 +local_warning :0 +int_phy_link :0 +int_phy_reinit_cnt:0 +link_andone :0 +serdes_mode :SerDes +============ Counters =========== +clst_tx_orig :0 +clst_tx_o_free :0 +clst_tx_redir :0 +clst_tx_rd_free :0 +clst_tx_reply :0 +clst_tx_rp_free :0 +dd_wo_eop :0 +tcp_udp_csum_err:0 +rx_error :0 +rx_crc_error :0 +rx_len_error :0 +rx_carrier :0 +rx_oversize :0 +rx_undersize :0 +tx_collision :0 +ip_sum_offload :0 +ipsec_dec :0 +ipsec_dec_drop :0 +ipsec_antireplay_f:0 +ipsec_antireplay_p:0 +aps_log :0 +Rx Pkts :188895694 +Rx Bytes :82538535564 +Tx Pkts :297621641 +Tx Bytes :236894931491 +Host Rx Pkts :188895680 +Host Rx Bytes :79138411812 +Host Tx Pkts :297622192 +Host Tx Bytes :238680266080 +sw_rx_pkts :188895695 +sw_rx_bytes :934157048 +sw_tx_pkts :297621645 +sw_tx_bytes :671734297 +sw_rx_mc_pkts :166 +sw_rx_bc_pkts :110805703 +sw_np_rx_pkts :416031055 +sw_np_rx_bytes :251347608749 +sw_np_tx_pkts :299701544 +sw_np_tx_bytes :95704383998 +sw_np_rx_mc_pkts:78 +sw_np_rx_bc_pkts:236817338 diff --git a/test/unit/fortios/mock_data/get_system_dns_|_grep_domain.txt b/test/unit/fortios/mock_data/get_system_dns_|_grep_domain.txt new file mode 100644 index 0000000..d09b8f5 --- /dev/null +++ b/test/unit/fortios/mock_data/get_system_dns_|_grep_domain.txt @@ -0,0 +1 @@ +domain : spotify.net diff --git a/test/unit/fortios/mock_data/get_system_interface_|_grep_==.txt b/test/unit/fortios/mock_data/get_system_interface_|_grep_==.txt new file mode 100644 index 0000000..b8f6b87 --- /dev/null +++ b/test/unit/fortios/mock_data/get_system_interface_|_grep_==.txt @@ -0,0 +1,15 @@ +== [ mgmt1 ] +== [ mgmt2 ] +== [ wan1 ] +== [ wan2 ] +== [ port1 ] +== [ port2 ] +== [ modem ] +== [ ssl.root ] +== [ npu0-vlink0 ] +== [ npu0-vlink1 ] +== [ pub0 ] +== [ svc0 ] +== [ forticlient ] +== [ native ] +== [ MY_VPN ] diff --git a/test/unit/fortios/mock_data/get_system_performance_status.txt b/test/unit/fortios/mock_data/get_system_performance_status.txt new file mode 100644 index 0000000..c6d3dd4 --- /dev/null +++ b/test/unit/fortios/mock_data/get_system_performance_status.txt @@ -0,0 +1,12 @@ +CPU states: 0% user 18% system 0% nice 82% idle +CPU0 states: 0% user 22% system 0% nice 78% idle +CPU1 states: 0% user 15% system 0% nice 85% idle +CPU2 states: 0% user 17% system 0% nice 83% idle +CPU3 states: 0% user 19% system 0% nice 81% idle +Memory states: 49% used +Average network usage: 141989 kbps in 1 minute, 125760 kbps in 10 minutes, 146591 kbps in 30 minutes +Average sessions: 14482 sessions in 1 minute, 14837 sessions in 10 minutes, 14965 sessions in 30 minutes +Average session setup rate: 259 sessions per second in last 1 minute, 154 sessions per second in last 10 minutes, 193 sessions per second in last 30 minutes +Virus caught: 0 total in 1 minute +IPS attacks blocked: 0 total in 1 minute +Uptime: 274 days, 1 hours, 41 minutes diff --git a/test/unit/fortios/mock_data/get_system_status.txt b/test/unit/fortios/mock_data/get_system_status.txt new file mode 100644 index 0000000..965d768 --- /dev/null +++ b/test/unit/fortios/mock_data/get_system_status.txt @@ -0,0 +1,24 @@ +vpn-sto3-z8r307-2 # get system status +Version: FortiGate-800C v5.2.2,build0642,141118 (GA) +Virus-DB: 16.00560(2012-10-19 08:31) +Extended DB: 1.00000(2012-10-17 15:46) +Extreme DB: 1.00000(2012-10-17 15:47) +IPS-DB: 5.00555(2014-10-07 01:21) +IPS-ETDB: 0.00000(2001-01-01 00:00) +Serial-Number: FG800C3914800949 +Botnet DB: 1.00000(2012-05-28 22:51) +BIOS version: 04000038 +System Part-Number: P11496-05 +Log hard disk: Available +Hostname: vpn-sto3-z8r307-2 +Operation Mode: NAT +Current virtual domain: root +Max number of virtual domains: 10 +Virtual domains status: 1 in NAT mode, 0 in TP mode +Virtual domain configuration: disable +FIPS-CC mode: disable +Current HA mode: a-p, master +Branch point: 642 +Release Version Information: GA +FortiOS x86-64: Yes +System time: Thu Nov 26 06:46:57 2015 diff --git a/test/unit/fortios/mock_data/system_interface.txt b/test/unit/fortios/mock_data/system_interface.txt new file mode 100644 index 0000000..01d77c5 --- /dev/null +++ b/test/unit/fortios/mock_data/system_interface.txt @@ -0,0 +1,121 @@ +config system interface + edit "mgmt1" + set ip 10.209.32.126 255.255.240.0 + set allowaccess ping https ssh snmp + set vlanforward enable + set type physical + set dedicated-to management + set snmp-index 2 + set defaultgw disable + next + edit "mgmt2" + set vdom "root" + set vlanforward enable + set type physical + set snmp-index 4 + next + edit "wan1" + set vdom "root" + set vlanforward enable + set type physical + set snmp-index 5 + next + edit "wan2" + set vdom "root" + set vlanforward enable + set type physical + set snmp-index 6 + next + edit "port1" + set vdom "root" + set allowaccess ping https + set vlanforward enable + set type physical + set snmp-index 1 + next + edit "port2" + set vdom "root" + set vlanforward enable + set type physical + set snmp-index 7 + next + edit "modem" + set vdom "root" + set mode pppoe + set vlanforward enable + set type physical + set snmp-index 3 + next + edit "ssl.root" + set vdom "root" + set vlanforward enable + set status down + set type tunnel + set alias "sslvpn tunnel interface" + set snmp-index 30 + next + edit "npu0-vlink0" + set vdom "root" + set vlanforward enable + set status down + set type physical + set snmp-index 32 + next + edit "npu0-vlink1" + set vdom "root" + set vlanforward enable + set status down + set type physical + set snmp-index 33 + next + edit "pub0" + set vdom "root" + set ip 192.168.181.235 255.255.255.248 + set allowaccess ping + set vlanforward enable + set snmp-index 31 + set interface "port1" + set vlanid 22 + next + edit "svc0" + set vdom "root" + set ip 192.168.169.235 255.255.255.248 + set allowaccess ping + set vlanforward enable + set snmp-index 34 + set interface "port11" + set vlanid 32 + next + edit "forticlient" + set vdom "root" + set ip 10.210.0.1 255.255.255.255 + set allowaccess ping ssh + set vlanforward enable + set type tunnel + set remote-ip 10.210.0.1 + set listen-forticlient-connection enable + set snmp-index 39 + set interface "pub0" + next + edit "native" + set vdom "root" + set ip 10.210.1.1 255.255.255.255 + set allowaccess ping ssh + set vlanforward enable + set type tunnel + set remote-ip 10.210.1.1 + set snmp-index 40 + set interface "pub0" + next + edit "MY_VPN" + set vdom "root" + set ip 10.15.2.160 255.255.255.255 + set allowaccess ping ssh + set vlanforward enable + set type tunnel + set remote-ip 10.15.2.161 + set snmp-index 41 + set interface "pub0" + next + +end \ No newline at end of file From 806103c593b252a641cfc9f2169654fd88c57f5b Mon Sep 17 00:00:00 2001 From: Loke Berne Date: Tue, 1 Dec 2015 10:31:04 +0100 Subject: [PATCH 02/11] get_bgp_neighbor --- utils/junos_views.yml | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/utils/junos_views.yml b/utils/junos_views.yml index 4456616..424b183 100644 --- a/utils/junos_views.yml +++ b/utils/junos_views.yml @@ -36,9 +36,23 @@ junos_route_instance_view: fields: name: instance-name -junos_bgp_table: +junos_bgp_uptime_table: rpc: get-bgp-summary-information + args: + instance: '' item: bgp-peer + key: peer-address + view: junos_bgp_uptime_view + +junos_bgp_uptime_view: + fields: + uptime: { elapsed-time/@seconds: int } + tables: bgp-rib/name + +junos_bgp_table: + rpc: get-bgp-neighbor-information + item: bgp-peer + key: peer-address view: junos_bgp_view @@ -48,10 +62,14 @@ junos_bgp_view: description: description is_up: { peer-state: True=Established } is_enabled: { peer-state: False=True } - uptime: { elapsed-time/@seconds: int } received_prefixes: { bgp-rib/received-prefix-count: int } accepted_prefixes: { bgp-rib/accepted-prefix-count: int } - sent_prefixes: { bgp-rib/aadvertised-prefix-count: int } + sent_prefixes: { bgp-rib/advertised-prefix-count: int } + tables: bgp-rib/name + local_as: { local-as: int } + peer_as: { peer-as: int } + local_id: local-id + remote_id: peer-id #### #### LLDP table @@ -112,4 +130,4 @@ junos_iface_counter_view: fields_txerrs: tx_errors: { output-errors: int } - tx_discards: { output-drops: int } + tx_discards: { output-drops: int } \ No newline at end of file From e539738727729d1bf3c8543623bd1cba0eaf9986 Mon Sep 17 00:00:00 2001 From: Edward Zambrano Date: Tue, 1 Dec 2015 10:32:19 +0100 Subject: [PATCH 03/11] get bgp neighbors for fortios --- napalm/fortios.py | 119 +++++++++++++++++++++++++++++++--------------- 1 file changed, 81 insertions(+), 38 deletions(-) diff --git a/napalm/fortios.py b/napalm/fortios.py index 4899767..8fb22ec 100644 --- a/napalm/fortios.py +++ b/napalm/fortios.py @@ -11,8 +11,9 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations under # the License. +import re -from pyFG.fortios import FortiOS, FortiConfig +from pyFG.fortios import FortiOS, FortiConfig, logger from pyFG.exceptions import FailedCommit, CommandExecutionException from base import NetworkDriver @@ -26,9 +27,9 @@ def execute_get(device, cmd, separator=':', auto=False): if auto: if ':' in output[0]: - separator=':' + separator = ':' elif '\t' in output[0]: - separator='\t' + separator = '\t' else: raise Exception('Unknown separator for block:\n{}'.format(output)) @@ -36,7 +37,6 @@ def execute_get(device, cmd, separator=':', auto=False): class FortiOSDriver(NetworkDriver): - def __init__(self, hostname, username, password, timeout=60): self.hostname = hostname self.username = username @@ -166,7 +166,7 @@ class FortiOSDriver(NetworkDriver): ifs['is_enabled'] = self.device.running_config['system interface'][iface].get_param('status') != 'down' ifs['description'] = self.device.running_config['system interface'][iface].get_param('description') ifs['last_flapped'] = None - #ifs['mode'] = 'routed' + # ifs['mode'] = 'routed' ifs['last_flapped'] = None interface_statistics[iface] = ifs except CommandExecutionException: @@ -174,39 +174,82 @@ class FortiOSDriver(NetworkDriver): return interface_statistics - # def get_bgp_neighbors(self): - # bgp_sum = self.device.execute_command('get router info bgp sum') - # re_neigh = re.compile("^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+") - # neighbors = {n.split()[0]: n.split()[1:] for n in bgp_sum if re.match(re_neigh, n)} - # - # peers = dict() - # - # self.device.load_config('router bgp') - # - # for neighbor, parameters in neighbors.iteritems(): - # neigh_conf = self.device.running_config['router bgp']['neighbor']['{}'.format(neighbor)] - # peers[neighbor] = dict() - # peers[neighbor]['remote_as'] = int(neigh_conf.get_param('remote-as')) - # peers[neighbor]['is_enabled'] = neigh_conf.get_param('shutdown') != 'enable' or False - # peers[neighbor]['is_up'] = 'never' != parameters[7] or False - # peers[neighbor]['uptime'] = convert_uptime_string_seconds(parameters[7]) - # peers[neighbor]['accepted_prefixes'] = int(self.device.execute_command('get router info bgp neighbor {} | grep "accepted prefixes"'.format(neighbor))[0].split()[0]) - # peers[neighbor]['sent_prefixes'] = int(self.device.execute_command('get router info bgp neighbor {} | grep "announced prefixes"'.format(neighbor))[0].split()[0]) - # - # received = self.device.execute_command('get router info bgp neighbors {} received-routes | grep prefixes'.format(neighbor))[0].split() - # if len(received) > 0: - # peers[neighbor]['received_prefixes'] = int(received[-1]) - # else: - # # Soft-reconfig is not enabled - # peers[neighbor]['received_prefixes'] = 0 - # - # return { - # 'default': { - # 'local_as': int(bgp_sum[0].split()[7]), - # 'router_id': bgp_sum[0].split()[3], - # 'peers': peers - # } - # } + def get_bgp_neighbors(self): + + def search_line_in_lines(search, lines): + for l in lines: + if search in l: + return l + + families = ['ipv4', 'ipv6'] + terms = dict({'accepted_prefixes': 'accepted', 'sent_prefixes': 'announced'}) + command_sum = 'get router info bgp sum' + command_detail = 'get router info bgp neighbor {}' + command_received = 'get router info bgp neighbors {} received-routes | grep prefixes ' + peers = dict() + + bgp_sum = self.device.execute_command(command_sum) + re_neigh = re.compile("^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+") + neighbors = {n.split()[0]: n.split()[1:] for n in bgp_sum if re.match(re_neigh, n)} + + self.device.load_config('router bgp') + + for neighbor, parameters in neighbors.iteritems(): + logger.debug('NEW PEER') + neigh_conf = self.device.running_config['router bgp']['neighbor']['{}'.format(neighbor)] + + neighbor_dict = peers.get(neighbor, dict()) + + if not neighbor_dict: + neighbor_dict['local_as'] = int(bgp_sum[0].split()[7]) + neighbor_dict['remote_as'] = int(neigh_conf.get_param('remote-as')) + neighbor_dict['is_up'] = 'never' != parameters[7] or False + neighbor_dict['is_enabled'] = neigh_conf.get_param('shutdown') != 'enable' or False + neighbor_dict['description'] = '' + neighbor_dict['uptime'] = convert_uptime_string_seconds(parameters[7]) + neighbor_dict['ipv4'] = dict() + neighbor_dict['ipv6'] = dict() + + detail_output = [x.lower() for x in self.device.execute_command(command_detail.format(neighbor))] + m = re.search('remote router id (.+?)\n', '\n'.join(detail_output)) + if m: + neighbor_dict['remote_id'] = m.group(1) + else: + raise Exception('cannot find remote router id for %s' % neighbor) + + for family in families: + # find block + x = detail_output.index(' for address family: {} unicast'.format(family)) + block = detail_output[x:] + + for term, fortiname in terms.iteritems(): + text = search_line_in_lines('%s prefixes' % fortiname, block) + t = [int(s) for s in text.split() if s.isdigit()][0] + neighbor_dict[family][term] = t + + received = self.device.execute_command( + command_received.format(neighbor))[0].split() + if len(received) > 0: + neighbor_dict[family]['received_prefixes'] = received[-1] + else: + # Soft-reconfig is not enabled + neighbor_dict[family]['received_prefixes'] = 0 + peers[neighbor] = neighbor_dict + + return { + 'default': { + 'router_id': bgp_sum[0].split()[3], + 'peers': peers + } + } def get_lldp_neighbors(self): return {} + + + # def get_environment(self): + # sensors_output = self.device.execute_command('execute sensor list') + # from pprint import pprint + # pprint(sensors_output) + # + # return {} From 7400a19084088fb6644337ad42ce0d8211c5f482 Mon Sep 17 00:00:00 2001 From: Loke Berne Date: Tue, 1 Dec 2015 11:53:11 +0100 Subject: [PATCH 04/11] Interface counters for fortios --- napalm/fortios.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/napalm/fortios.py b/napalm/fortios.py index 4899767..b2bf9db 100644 --- a/napalm/fortios.py +++ b/napalm/fortios.py @@ -174,6 +174,35 @@ class FortiOSDriver(NetworkDriver): return interface_statistics + def get_interfaces_counters(self): + cmd = self.device.execute_command('fnsysctl ifconfig') + if_name = None + interface_counters = dict() + for line in cmd: + data = line.split('\t') + if (data[0] == '' or data[0] == ' ') and len(data) == 1: + continue + elif data[0] != '': + if_name = data[0] + interface_counters[if_name] = dict() + elif (data[1].startswith('RX packets') or data[1].startswith('TX packets')) and if_name: + if_data = data[1].split(' ') + direction = if_data[0].lower() + interface_counters[if_name][direction + '_unicast_packets'] = if_data[1].split(':')[1] + interface_counters[if_name][direction + '_errors'] = if_data[2].split(':')[1] + interface_counters[if_name][direction + '_discards'] = if_data[2].split(':')[1] + interface_counters[if_name][direction + '_multicast_packets'] = -1 + interface_counters[if_name][direction + '_broadcast_packets'] = -1 + elif data[1].startswith('RX bytes'): + if_data = data[1].split(' ') + interface_counters[if_name]['rx_octets'] = if_data[1].split(':')[1] + try: + interface_counters[if_name]['rx_octets'] = if_data[6].split(':')[1] + except IndexError: + interface_counters[if_name]['rx_octets'] = if_data[7].split(':')[1] + return interface_counters + + # def get_bgp_neighbors(self): # bgp_sum = self.device.execute_command('get router info bgp sum') # re_neigh = re.compile("^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+") From fe3d464473127ed71fc405a511a120bbf0d90d62 Mon Sep 17 00:00:00 2001 From: Loke Berne Date: Tue, 1 Dec 2015 13:31:16 +0100 Subject: [PATCH 05/11] Correct typo --- napalm/fortios.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/napalm/fortios.py b/napalm/fortios.py index dada7b4..dc03eaf 100644 --- a/napalm/fortios.py +++ b/napalm/fortios.py @@ -266,9 +266,9 @@ class FortiOSDriver(NetworkDriver): if_data = data[1].split(' ') interface_counters[if_name]['rx_octets'] = if_data[1].split(':')[1] try: - interface_counters[if_name]['rx_octets'] = if_data[6].split(':')[1] + interface_counters[if_name]['tx_octets'] = if_data[6].split(':')[1] except IndexError: - interface_counters[if_name]['rx_octets'] = if_data[7].split(':')[1] + interface_counters[if_name]['tx_octets'] = if_data[7].split(':')[1] return interface_counters def get_lldp_neighbors(self): From 74144cca32612609fe35f4c2deb58455da201da6 Mon Sep 17 00:00:00 2001 From: David Barroso Date: Tue, 1 Dec 2015 15:20:51 +0100 Subject: [PATCH 06/11] Description should a unicode object --- utils/junos_views.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/junos_views.yml b/utils/junos_views.yml index 424b183..d4e105b 100644 --- a/utils/junos_views.yml +++ b/utils/junos_views.yml @@ -16,7 +16,7 @@ junos_iface_view: fields: is_up: { oper-status: True=up } is_enabled: { admin-status: True=up } - description: description + description: { description: unicode } last_flapped: { interface-flapped/@seconds: int } #mode: logical-interface/address-family/address-family-name speed: speed From 6b7678f3e020ba370c6eef3943d7128cc4dccbe5 Mon Sep 17 00:00:00 2001 From: Loke Berne Date: Tue, 1 Dec 2015 16:24:56 +0100 Subject: [PATCH 07/11] Fixed type for counters --- napalm/fortios.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/napalm/fortios.py b/napalm/fortios.py index dc03eaf..61d38f2 100644 --- a/napalm/fortios.py +++ b/napalm/fortios.py @@ -257,18 +257,18 @@ class FortiOSDriver(NetworkDriver): elif (data[1].startswith('RX packets') or data[1].startswith('TX packets')) and if_name: if_data = data[1].split(' ') direction = if_data[0].lower() - interface_counters[if_name][direction + '_unicast_packets'] = if_data[1].split(':')[1] - interface_counters[if_name][direction + '_errors'] = if_data[2].split(':')[1] - interface_counters[if_name][direction + '_discards'] = if_data[2].split(':')[1] + interface_counters[if_name][direction + '_unicast_packets'] = int(if_data[1].split(':')[1]) + interface_counters[if_name][direction + '_errors'] = int(if_data[2].split(':')[1]) + interface_counters[if_name][direction + '_discards'] = int(if_data[2].split(':')[1]) interface_counters[if_name][direction + '_multicast_packets'] = -1 interface_counters[if_name][direction + '_broadcast_packets'] = -1 elif data[1].startswith('RX bytes'): if_data = data[1].split(' ') - interface_counters[if_name]['rx_octets'] = if_data[1].split(':')[1] + interface_counters[if_name]['rx_octets'] = int(if_data[1].split(':')[1]) try: - interface_counters[if_name]['tx_octets'] = if_data[6].split(':')[1] + interface_counters[if_name]['tx_octets'] = int(if_data[6].split(':')[1]) except IndexError: - interface_counters[if_name]['tx_octets'] = if_data[7].split(':')[1] + interface_counters[if_name]['tx_octets'] = int(if_data[7].split(':')[1]) return interface_counters def get_lldp_neighbors(self): From b5319aee5211bbd3022ff61e32f78c3796accef6 Mon Sep 17 00:00:00 2001 From: David Barroso Date: Wed, 2 Dec 2015 10:50:06 +0100 Subject: [PATCH 08/11] Bugfixes --- napalm/fortios.py | 19 ++++++++++--------- .../fortios/mock_data/fnsysctl_ifconfig.txt | 0 ...t_router_info_bgp_neighbor_10.15.2.101.txt | 0 ...t_router_info_bgp_neighbor_10.15.2.105.txt | 0 ...et_router_info_bgp_neighbor_10.15.2.99.txt | 0 ...2.101_received-routes_|_grep_prefixes_.txt | 0 ...2.105_received-routes_|_grep_prefixes_.txt | 1 + ....2.99_received-routes_|_grep_prefixes_.txt | 1 + .../mock_data/get_router_info_bgp_sum.txt | 0 test/unit/fortios/mock_data/router_bgp.txt | 0 10 files changed, 12 insertions(+), 9 deletions(-) create mode 100644 test/unit/fortios/mock_data/fnsysctl_ifconfig.txt create mode 100644 test/unit/fortios/mock_data/get_router_info_bgp_neighbor_10.15.2.101.txt create mode 100644 test/unit/fortios/mock_data/get_router_info_bgp_neighbor_10.15.2.105.txt create mode 100644 test/unit/fortios/mock_data/get_router_info_bgp_neighbor_10.15.2.99.txt create mode 100644 test/unit/fortios/mock_data/get_router_info_bgp_neighbors_10.15.2.101_received-routes_|_grep_prefixes_.txt create mode 100644 test/unit/fortios/mock_data/get_router_info_bgp_neighbors_10.15.2.105_received-routes_|_grep_prefixes_.txt create mode 100644 test/unit/fortios/mock_data/get_router_info_bgp_neighbors_10.15.2.99_received-routes_|_grep_prefixes_.txt create mode 100644 test/unit/fortios/mock_data/get_router_info_bgp_sum.txt create mode 100644 test/unit/fortios/mock_data/router_bgp.txt diff --git a/napalm/fortios.py b/napalm/fortios.py index dc03eaf..5e61f16 100644 --- a/napalm/fortios.py +++ b/napalm/fortios.py @@ -205,15 +205,16 @@ class FortiOSDriver(NetworkDriver): neighbor_dict['remote_as'] = int(neigh_conf.get_param('remote-as')) neighbor_dict['is_up'] = 'never' != parameters[7] or False neighbor_dict['is_enabled'] = neigh_conf.get_param('shutdown') != 'enable' or False - neighbor_dict['description'] = '' + neighbor_dict['description'] = u'' neighbor_dict['uptime'] = convert_uptime_string_seconds(parameters[7]) - neighbor_dict['ipv4'] = dict() - neighbor_dict['ipv6'] = dict() + neighbor_dict['address_family'] = dict() + neighbor_dict['address_family']['ipv4'] = dict() + neighbor_dict['address_family']['ipv6'] = dict() detail_output = [x.lower() for x in self.device.execute_command(command_detail.format(neighbor))] m = re.search('remote router id (.+?)\n', '\n'.join(detail_output)) if m: - neighbor_dict['remote_id'] = m.group(1) + neighbor_dict['remote_id'] = unicode(m.group(1)) else: raise Exception('cannot find remote router id for %s' % neighbor) @@ -225,20 +226,20 @@ class FortiOSDriver(NetworkDriver): for term, fortiname in terms.iteritems(): text = search_line_in_lines('%s prefixes' % fortiname, block) t = [int(s) for s in text.split() if s.isdigit()][0] - neighbor_dict[family][term] = t + neighbor_dict['address_family'][family][term] = t received = self.device.execute_command( command_received.format(neighbor))[0].split() if len(received) > 0: - neighbor_dict[family]['received_prefixes'] = received[-1] + neighbor_dict['address_family'][family]['received_prefixes'] = received[-1] else: # Soft-reconfig is not enabled - neighbor_dict[family]['received_prefixes'] = 0 + neighbor_dict['address_family'][family]['received_prefixes'] = 0 peers[neighbor] = neighbor_dict return { - 'default': { - 'router_id': bgp_sum[0].split()[3], + 'global': { + 'router_id': unicode(bgp_sum[0].split()[3]), 'peers': peers } } diff --git a/test/unit/fortios/mock_data/fnsysctl_ifconfig.txt b/test/unit/fortios/mock_data/fnsysctl_ifconfig.txt new file mode 100644 index 0000000..e69de29 diff --git a/test/unit/fortios/mock_data/get_router_info_bgp_neighbor_10.15.2.101.txt b/test/unit/fortios/mock_data/get_router_info_bgp_neighbor_10.15.2.101.txt new file mode 100644 index 0000000..e69de29 diff --git a/test/unit/fortios/mock_data/get_router_info_bgp_neighbor_10.15.2.105.txt b/test/unit/fortios/mock_data/get_router_info_bgp_neighbor_10.15.2.105.txt new file mode 100644 index 0000000..e69de29 diff --git a/test/unit/fortios/mock_data/get_router_info_bgp_neighbor_10.15.2.99.txt b/test/unit/fortios/mock_data/get_router_info_bgp_neighbor_10.15.2.99.txt new file mode 100644 index 0000000..e69de29 diff --git a/test/unit/fortios/mock_data/get_router_info_bgp_neighbors_10.15.2.101_received-routes_|_grep_prefixes_.txt b/test/unit/fortios/mock_data/get_router_info_bgp_neighbors_10.15.2.101_received-routes_|_grep_prefixes_.txt new file mode 100644 index 0000000..e69de29 diff --git a/test/unit/fortios/mock_data/get_router_info_bgp_neighbors_10.15.2.105_received-routes_|_grep_prefixes_.txt b/test/unit/fortios/mock_data/get_router_info_bgp_neighbors_10.15.2.105_received-routes_|_grep_prefixes_.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/test/unit/fortios/mock_data/get_router_info_bgp_neighbors_10.15.2.105_received-routes_|_grep_prefixes_.txt @@ -0,0 +1 @@ + diff --git a/test/unit/fortios/mock_data/get_router_info_bgp_neighbors_10.15.2.99_received-routes_|_grep_prefixes_.txt b/test/unit/fortios/mock_data/get_router_info_bgp_neighbors_10.15.2.99_received-routes_|_grep_prefixes_.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/test/unit/fortios/mock_data/get_router_info_bgp_neighbors_10.15.2.99_received-routes_|_grep_prefixes_.txt @@ -0,0 +1 @@ + diff --git a/test/unit/fortios/mock_data/get_router_info_bgp_sum.txt b/test/unit/fortios/mock_data/get_router_info_bgp_sum.txt new file mode 100644 index 0000000..e69de29 diff --git a/test/unit/fortios/mock_data/router_bgp.txt b/test/unit/fortios/mock_data/router_bgp.txt new file mode 100644 index 0000000..e69de29 From 1d0bad011e7fab1be6b600f891c9898b7bc08020 Mon Sep 17 00:00:00 2001 From: David Barroso Date: Wed, 2 Dec 2015 10:51:11 +0100 Subject: [PATCH 09/11] Mocking fortios for testing get_bgp_neighbors --- .../fortios/mock_data/fnsysctl_ifconfig.txt | 509 ++++++++++++++++++ ...t_router_info_bgp_neighbor_10.15.2.101.txt | 45 ++ ...t_router_info_bgp_neighbor_10.15.2.105.txt | 42 ++ ...et_router_info_bgp_neighbor_10.15.2.99.txt | 33 ++ ...2.101_received-routes_|_grep_prefixes_.txt | 1 + .../mock_data/get_router_info_bgp_sum.txt | 11 + test/unit/fortios/mock_data/router_bgp.txt | 60 +++ 7 files changed, 701 insertions(+) diff --git a/test/unit/fortios/mock_data/fnsysctl_ifconfig.txt b/test/unit/fortios/mock_data/fnsysctl_ifconfig.txt index e69de29..273f7ae 100644 --- a/test/unit/fortios/mock_data/fnsysctl_ifconfig.txt +++ b/test/unit/fortios/mock_data/fnsysctl_ifconfig.txt @@ -0,0 +1,509 @@ +mgmt1 Link encap:Ethernet HWaddr 08:5B:0E:1C:02:2C + inet addr:10.225.0.101 Bcast:10.225.15.255 Mask:255.255.240.0 + UP BROADCAST RUNNING ALLMULTI MULTICAST MTU:1500 Metric:1 + RX packets:779899549 errors:0 dropped:0 overruns:0 frame:0 + TX packets:9523098 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:100 + RX bytes:100706484996 (93.8 GB) TX bytes:2343371965 (2.2 GB) + Interrupt:16 + +mgmt2 Link encap:Ethernet HWaddr 00:09:0F:09:00:01 + UP BROADCAST PROMISC ALLMULTI MULTICAST MTU:1500 Metric:1 + RX packets:0 errors:0 dropped:0 overruns:0 frame:0 + TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:100 + RX bytes:0 (0 Bytes) TX bytes:0 (0 Bytes) + Interrupt:17 + +wan1 Link encap:Ethernet HWaddr 00:09:0F:09:00:1A + UP BROADCAST PROMISC ALLMULTI MULTICAST MTU:1500 Metric:1 + RX packets:0 errors:0 dropped:0 overruns:0 frame:0 + TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:100 + RX bytes:0 (0 Bytes) TX bytes:0 (0 Bytes) + +port1 Link encap:Ethernet HWaddr 00:09:0F:09:00:02 + UP BROADCAST RUNNING PROMISC ALLMULTI MULTICAST MTU:1500 Metric:1 + RX packets:63129134 errors:0 dropped:0 overruns:0 frame:0 + TX packets:64114385 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:100 + RX bytes:6998023850 (6.5 GB) TX bytes:8021760304 (7.5 GB) + +wan2 Link encap:Ethernet HWaddr 00:09:0F:09:00:1B + UP BROADCAST PROMISC ALLMULTI MULTICAST MTU:1500 Metric:1 + RX packets:0 errors:0 dropped:0 overruns:0 frame:0 + TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:100 + RX bytes:0 (0 Bytes) TX bytes:0 (0 Bytes) + +port2 Link encap:Ethernet HWaddr 00:09:0F:09:00:0D + UP BROADCAST RUNNING PROMISC ALLMULTI MULTICAST MTU:1500 Metric:1 + RX packets:56564667 errors:0 dropped:0 overruns:0 frame:0 + TX packets:56562812 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:100 + RX bytes:6108984036 (5.7 GB) TX bytes:6108783696 (5.7 GB) + +port3 Link encap:Ethernet HWaddr 00:09:0F:09:00:13 + UP BROADCAST PROMISC ALLMULTI MULTICAST MTU:1500 Metric:1 + RX packets:0 errors:0 dropped:0 overruns:0 frame:0 + TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:100 + RX bytes:0 (0 Bytes) TX bytes:0 (0 Bytes) + +port4 Link encap:Ethernet HWaddr 00:09:0F:09:00:14 + UP BROADCAST PROMISC ALLMULTI MULTICAST MTU:1500 Metric:1 + RX packets:0 errors:0 dropped:0 overruns:0 frame:0 + TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:100 + RX bytes:0 (0 Bytes) TX bytes:0 (0 Bytes) + +port5 Link encap:Ethernet HWaddr 00:09:0F:09:00:15 + UP BROADCAST PROMISC ALLMULTI MULTICAST MTU:1500 Metric:1 + RX packets:0 errors:0 dropped:0 overruns:0 frame:0 + TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:100 + RX bytes:0 (0 Bytes) TX bytes:0 (0 Bytes) + +port6 Link encap:Ethernet HWaddr 00:09:0F:09:00:16 + UP BROADCAST PROMISC ALLMULTI MULTICAST MTU:1500 Metric:1 + RX packets:0 errors:0 dropped:0 overruns:0 frame:0 + TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:100 + RX bytes:0 (0 Bytes) TX bytes:0 (0 Bytes) + +port7 Link encap:Ethernet HWaddr 00:09:0F:09:00:17 + UP BROADCAST PROMISC ALLMULTI MULTICAST MTU:1500 Metric:1 + RX packets:0 errors:0 dropped:0 overruns:0 frame:0 + TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:100 + RX bytes:0 (0 Bytes) TX bytes:0 (0 Bytes) + +port8 Link encap:Ethernet HWaddr 00:09:0F:09:00:18 + UP BROADCAST PROMISC ALLMULTI MULTICAST MTU:1500 Metric:1 + RX packets:0 errors:0 dropped:0 overruns:0 frame:0 + TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:100 + RX bytes:0 (0 Bytes) TX bytes:0 (0 Bytes) + +port9 Link encap:Ethernet HWaddr 00:09:0F:09:00:19 + UP BROADCAST PROMISC ALLMULTI MULTICAST MTU:1500 Metric:1 + RX packets:0 errors:0 dropped:0 overruns:0 frame:0 + TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:100 + RX bytes:0 (0 Bytes) TX bytes:0 (0 Bytes) + +port10 Link encap:Ethernet HWaddr 00:09:0F:09:00:03 + UP BROADCAST PROMISC ALLMULTI MULTICAST MTU:1500 Metric:1 + RX packets:0 errors:0 dropped:0 overruns:0 frame:0 + TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:100 + RX bytes:0 (0 Bytes) TX bytes:0 (0 Bytes) + +port11 Link encap:Ethernet HWaddr 00:09:0F:09:00:04 + UP BROADCAST PROMISC ALLMULTI MULTICAST MTU:1500 Metric:1 + RX packets:0 errors:0 dropped:0 overruns:0 frame:0 + TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:100 + RX bytes:0 (0 Bytes) TX bytes:0 (0 Bytes) + +port12 Link encap:Ethernet HWaddr 00:09:0F:09:00:05 + UP BROADCAST PROMISC ALLMULTI MULTICAST MTU:1500 Metric:1 + RX packets:0 errors:0 dropped:0 overruns:0 frame:0 + TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:100 + RX bytes:0 (0 Bytes) TX bytes:0 (0 Bytes) + +port13 Link encap:Ethernet HWaddr 00:09:0F:09:00:06 + UP BROADCAST PROMISC ALLMULTI MULTICAST MTU:1500 Metric:1 + RX packets:0 errors:0 dropped:0 overruns:0 frame:0 + TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:100 + RX bytes:0 (0 Bytes) TX bytes:0 (0 Bytes) + +port14 Link encap:Ethernet HWaddr 00:09:0F:09:00:07 + UP BROADCAST PROMISC ALLMULTI MULTICAST MTU:1500 Metric:1 + RX packets:0 errors:0 dropped:0 overruns:0 frame:0 + TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:100 + RX bytes:0 (0 Bytes) TX bytes:0 (0 Bytes) + +port15 Link encap:Ethernet HWaddr 00:09:0F:09:00:08 + UP BROADCAST PROMISC ALLMULTI MULTICAST MTU:1500 Metric:1 + RX packets:0 errors:0 dropped:0 overruns:0 frame:0 + TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:100 + RX bytes:0 (0 Bytes) TX bytes:0 (0 Bytes) + +port16 Link encap:Ethernet HWaddr 00:09:0F:09:00:09 + UP BROADCAST PROMISC ALLMULTI MULTICAST MTU:1500 Metric:1 + RX packets:0 errors:0 dropped:0 overruns:0 frame:0 + TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:100 + RX bytes:0 (0 Bytes) TX bytes:0 (0 Bytes) + +port17 Link encap:Ethernet HWaddr 00:09:0F:09:00:0A + UP BROADCAST PROMISC ALLMULTI MULTICAST MTU:1500 Metric:1 + RX packets:0 errors:0 dropped:0 overruns:0 frame:0 + TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:100 + RX bytes:0 (0 Bytes) TX bytes:0 (0 Bytes) + +port18 Link encap:Ethernet HWaddr 00:09:0F:09:00:0B + UP BROADCAST PROMISC ALLMULTI MULTICAST MTU:1500 Metric:1 + RX packets:0 errors:0 dropped:0 overruns:0 frame:0 + TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:100 + RX bytes:0 (0 Bytes) TX bytes:0 (0 Bytes) + +port19 Link encap:Ethernet HWaddr 00:09:0F:09:00:0C + UP BROADCAST PROMISC ALLMULTI MULTICAST MTU:1500 Metric:1 + RX packets:0 errors:0 dropped:0 overruns:0 frame:0 + TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:100 + RX bytes:0 (0 Bytes) TX bytes:0 (0 Bytes) + +port20 Link encap:Ethernet HWaddr 00:09:0F:09:00:0E + UP BROADCAST PROMISC ALLMULTI MULTICAST MTU:1500 Metric:1 + RX packets:0 errors:0 dropped:0 overruns:0 frame:0 + TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:100 + RX bytes:0 (0 Bytes) TX bytes:0 (0 Bytes) + +port21 Link encap:Ethernet HWaddr 00:09:0F:09:00:0F + UP BROADCAST PROMISC ALLMULTI MULTICAST MTU:1500 Metric:1 + RX packets:0 errors:0 dropped:0 overruns:0 frame:0 + TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:100 + RX bytes:0 (0 Bytes) TX bytes:0 (0 Bytes) + +port22 Link encap:Ethernet HWaddr 00:09:0F:09:00:10 + UP BROADCAST PROMISC ALLMULTI MULTICAST MTU:1500 Metric:1 + RX packets:0 errors:0 dropped:0 overruns:0 frame:0 + TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:100 + RX bytes:0 (0 Bytes) TX bytes:0 (0 Bytes) + +port23 Link encap:Ethernet HWaddr 00:09:0F:09:00:11 + UP BROADCAST RUNNING PROMISC ALLMULTI MULTICAST MTU:1500 Metric:1 + RX packets:86746961835 errors:0 dropped:0 overruns:0 frame:0 + TX packets:99786157719 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:100 + RX bytes:27883734996518 (25968.8 GB) TX bytes:35320005597799 (32894.3 GB) + +port24 Link encap:Ethernet HWaddr 00:09:0F:09:00:12 + UP BROADCAST PROMISC ALLMULTI MULTICAST MTU:1500 Metric:1 + RX packets:0 errors:0 dropped:0 overruns:0 frame:0 + TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:100 + RX bytes:0 (0 Bytes) TX bytes:0 (0 Bytes) + +root Link encap:Local Loopback + inet addr:127.0.0.1 Mask:255.0.0.0 + UP LOOPBACK RUNNING MTU:16436 Metric:1 + RX packets:352233 errors:0 dropped:0 overruns:0 frame:0 + TX packets:352233 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:0 + RX bytes:1077259718 (1.0 GB) TX bytes:1077259718 (1.0 GB) + +ssl.root Link encap:Point-Point Protocol + UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1 + RX packets:0 errors:0 dropped:0 overruns:0 frame:0 + TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:0 + RX bytes:0 (0 Bytes) TX bytes:0 (0 Bytes) + +pub0 Link encap:Ethernet HWaddr 00:09:0F:09:00:11 + inet addr:191.168.32.243 Bcast:193.235.32.255 Mask:255.255.255.240 + UP BROADCAST RUNNING PROMISC MULTICAST MTU:1500 Metric:1 + RX packets:45948704676 errors:0 dropped:0 overruns:0 frame:0 + TX packets:41279349776 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:0 + RX bytes:11620407995936 (10822.3 GB) TX bytes:18790279964525 (17499.8 GB) + +svc0 Link encap:Ethernet HWaddr 00:09:0F:09:00:11 + inet addr:172.20.96.131 Bcast:23.92.96.143 Mask:255.255.255.240 + UP BROADCAST RUNNING PROMISC MULTICAST MTU:1500 Metric:1 + RX packets:40792225191 errors:0 dropped:0 overruns:0 frame:0 + TX packets:58506810107 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:0 + RX bytes:15915591848230 (14822.5 GB) TX bytes:16130582366133 (15022.8 GB) + +vsys_hamgmt Link encap:Local Loopback + inet addr:127.0.0.1 Mask:255.0.0.0 + UP LOOPBACK RUNNING MTU:16436 Metric:1 + RX packets:45 errors:0 dropped:0 overruns:0 frame:0 + TX packets:45 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:0 + RX bytes:11717 (11.4 KB) TX bytes:11717 (11.4 KB) + +MY_VPN Link encap:Unknown + inet addr:10.15.2.100 Mask:255.255.255.255 + UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1438 Metric:1 + RX packets:3802963042 errors:19403 dropped:0 overruns:0 frame:0 + TX packets:4405184959 errors:18 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:0 + RX bytes:1401932944256 (1305.7 GB) TX bytes:3390894856257 (3158.0 GB) + +vsys_ha Link encap:Local Loopback + inet addr:127.0.0.1 Mask:255.0.0.0 + UP LOOPBACK RUNNING MTU:16436 Metric:1 + RX packets:525955 errors:0 dropped:0 overruns:0 frame:0 + TX packets:525955 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:0 + RX bytes:40507822 (38.6 MB) TX bytes:40507822 (38.6 MB) + +port_ha Link encap:Ethernet HWaddr 08:5B:0E:1C:02:13 + inet addr:169.254.0.1 Bcast:169.254.0.63 Mask:255.255.255.192 + UP BROADCAST RUNNING MULTICAST MTU:1496 Metric:1 + RX packets:6564405 errors:0 dropped:0 overruns:0 frame:0 + TX packets:7551508 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:0 + RX bytes:770850098 (735.1 MB) TX bytes:1882738875 (1.8 GB) + +vsys_fgfm Link encap:Local Loopback + inet addr:127.0.0.1 Mask:255.0.0.0 + UP LOOPBACK RUNNING MTU:16436 Metric:1 + RX packets:0 errors:0 dropped:0 overruns:0 frame:0 + TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:0 + RX bytes:0 (0 Bytes) TX bytes:0 (0 Bytes) + +havdlink0 Link encap:Point-Point Protocol + inet addr:169.254.0.65 Mask:255.255.255.192 + UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1 + RX packets:15886 errors:0 dropped:0 overruns:0 frame:0 + TX packets:9211 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:100 + RX bytes:22847822 (21.8 MB) TX bytes:505250 (493.4 KB) + +havdlink1 Link encap:Point-Point Protocol + inet addr:169.254.0.66 Mask:255.255.255.192 + UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1 + RX packets:9211 errors:0 dropped:0 overruns:0 frame:0 + TX packets:15886 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:100 + RX bytes:505250 (493.4 KB) TX bytes:22847822 (21.8 MB) + +forticlient_3 Link encap:Unknown + inet addr:10.226.0.1 Mask:255.255.255.255 + UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1438 Metric:1 + RX packets:15534 errors:0 dropped:0 overruns:0 frame:0 + TX packets:13524 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:0 + RX bytes:2247112 (2.1 MB) TX bytes:71795 (70.1 KB) + +native_2 Link encap:Unknown + inet addr:10.226.1.1 Mask:255.255.255.255 + UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1422 Metric:1 + RX packets:91542 errors:0 dropped:0 overruns:0 frame:0 + TX packets:80053 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:0 + RX bytes:12083568 (11.5 MB) TX bytes:15028967 (14.3 MB) + +forticlient_2 Link encap:Unknown + inet addr:10.226.0.1 Mask:255.255.255.255 + UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1438 Metric:1 + RX packets:3079 errors:0 dropped:0 overruns:0 frame:0 + TX packets:2042 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:0 + RX bytes:197672 (193.0 KB) TX bytes:132023 (128.9 KB) + +forticlient_0 Link encap:Unknown + inet addr:10.226.0.1 Mask:255.255.255.255 + UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1422 Metric:1 + RX packets:13702 errors:0 dropped:0 overruns:0 frame:0 + TX packets:13820 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:0 + RX bytes:2884770 (2.8 MB) TX bytes:10488565 (10.0 MB) + +forticlient_1 Link encap:Unknown + inet addr:10.226.0.1 Mask:255.255.255.255 + UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1438 Metric:1 + RX packets:1797 errors:0 dropped:0 overruns:0 frame:0 + TX packets:1788 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:0 + RX bytes:262802 (256.6 KB) TX bytes:524834 (512.5 KB) + +native_0 Link encap:Unknown + inet addr:10.226.1.1 Mask:255.255.255.255 + UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1422 Metric:1 + RX packets:44431 errors:0 dropped:0 overruns:0 frame:0 + TX packets:48129 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:0 + RX bytes:12257836 (11.7 MB) TX bytes:39259957 (37.4 MB) + +native_12 Link encap:Unknown + inet addr:10.226.1.1 Mask:255.255.255.255 + UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1422 Metric:1 + RX packets:4748 errors:0 dropped:0 overruns:0 frame:0 + TX packets:4486 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:0 + RX bytes:789430 (770.9 KB) TX bytes:1377722 (1.3 MB) + +native_13 Link encap:Unknown + inet addr:10.226.1.1 Mask:255.255.255.255 + UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1422 Metric:1 + RX packets:20234 errors:0 dropped:0 overruns:0 frame:0 + TX packets:25601 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:0 + RX bytes:4327094 (4.1 MB) TX bytes:28183480 (26.9 MB) + +forticlient_6 Link encap:Unknown + inet addr:10.226.0.1 Mask:255.255.255.255 + UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1438 Metric:1 + RX packets:3077 errors:0 dropped:0 overruns:0 frame:0 + TX packets:2688 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:0 + RX bytes:722376 (705.4 KB) TX bytes:1050853 (1.0 MB) + +native_8 Link encap:Unknown + inet addr:10.226.1.1 Mask:255.255.255.255 + UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1422 Metric:1 + RX packets:25861 errors:0 dropped:0 overruns:0 frame:0 + TX packets:30206 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:0 + RX bytes:7341560 (7.0 MB) TX bytes:13828520 (13.2 MB) + +forticlient_7 Link encap:Unknown + inet addr:10.226.0.1 Mask:255.255.255.255 + UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1438 Metric:1 + RX packets:3972 errors:0 dropped:0 overruns:0 frame:0 + TX packets:3454 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:0 + RX bytes:1245858 (1.2 MB) TX bytes:2163625 (2.1 MB) + +native_15 Link encap:Unknown + inet addr:10.226.1.1 Mask:255.255.255.255 + UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1422 Metric:1 + RX packets:3214 errors:0 dropped:0 overruns:0 frame:0 + TX packets:1413 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:0 + RX bytes:526560 (514.2 KB) TX bytes:918582 (897.1 KB) + +native_3 Link encap:Unknown + inet addr:10.226.1.1 Mask:255.255.255.255 + UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1422 Metric:1 + RX packets:8330 errors:0 dropped:0 overruns:0 frame:0 + TX packets:10370 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:0 + RX bytes:1312384 (1.3 MB) TX bytes:9178427 (8.8 MB) + +forticlient_8 Link encap:Unknown + inet addr:10.226.0.1 Mask:255.255.255.255 + UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1438 Metric:1 + RX packets:8578 errors:0 dropped:0 overruns:0 frame:0 + TX packets:6398 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:0 + RX bytes:1507782 (1.4 MB) TX bytes:6228587 (5.9 MB) + +forticlient_11 Link encap:Unknown + inet addr:10.226.0.1 Mask:255.255.255.255 + UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1438 Metric:1 + RX packets:643 errors:0 dropped:0 overruns:0 frame:0 + TX packets:639 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:0 + RX bytes:132682 (129.6 KB) TX bytes:131218 (128.1 KB) + +forticlient_9 Link encap:Unknown + inet addr:10.226.0.1 Mask:255.255.255.255 + UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1438 Metric:1 + RX packets:5923 errors:0 dropped:0 overruns:0 frame:0 + TX packets:3455 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:0 + RX bytes:1228870 (1.2 MB) TX bytes:917637 (896.1 KB) + +native_10 Link encap:Unknown + inet addr:10.226.1.1 Mask:255.255.255.255 + UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1422 Metric:1 + RX packets:136 errors:0 dropped:0 overruns:0 frame:0 + TX packets:257 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:0 + RX bytes:1152 (1.1 KB) TX bytes:328002 (320.3 KB) + +forticlient_12 Link encap:Unknown + inet addr:10.226.0.1 Mask:255.255.255.255 + UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1438 Metric:1 + RX packets:8193 errors:0 dropped:0 overruns:0 frame:0 + TX packets:13439 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:0 + RX bytes:1376446 (1.3 MB) TX bytes:13829166 (13.2 MB) + +forticlient_4 Link encap:Unknown + inet addr:10.226.0.1 Mask:255.255.255.255 + UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1438 Metric:1 + RX packets:2561 errors:0 dropped:0 overruns:0 frame:0 + TX packets:2047 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:0 + RX bytes:1179812 (1.1 MB) TX bytes:1311111 (1.3 MB) + +native_16 Link encap:Unknown + inet addr:10.226.1.1 Mask:255.255.255.255 + UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1422 Metric:1 + RX packets:4 errors:0 dropped:0 overruns:0 frame:0 + TX packets:2 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:0 + RX bytes:576 (576 Bytes) TX bytes:234 (234 Bytes) + +forticlient_13 Link encap:Unknown + inet addr:10.226.0.1 Mask:255.255.255.255 + UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1438 Metric:1 + RX packets:22658 errors:0 dropped:0 overruns:0 frame:0 + TX packets:33151 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:0 + RX bytes:3277076 (3.1 MB) TX bytes:40895077 (39.0 MB) + +native_17 Link encap:Unknown + inet addr:10.226.1.1 Mask:255.255.255.255 + UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1422 Metric:1 + RX packets:1668 errors:0 dropped:0 overruns:0 frame:0 + TX packets:1534 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:0 + RX bytes:394172 (384.9 KB) TX bytes:853214 (833.2 KB) + +forticlient_10 Link encap:Unknown + inet addr:10.226.0.1 Mask:255.255.255.255 + UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1438 Metric:1 + RX packets:1537 errors:0 dropped:0 overruns:0 frame:0 + TX packets:1407 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:0 + RX bytes:327842 (320.2 KB) TX bytes:721528 (704.6 KB) + +native_1 Link encap:Unknown + inet addr:10.226.1.1 Mask:255.255.255.255 + UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1422 Metric:1 + RX packets:261 errors:0 dropped:0 overruns:0 frame:0 + TX packets:130 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:0 + RX bytes:67266 (65.7 KB) TX bytes:66750 (65.2 KB) + +native_5 Link encap:Unknown + inet addr:10.226.1.1 Mask:255.255.255.255 + UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1422 Metric:1 + RX packets:65157 errors:0 dropped:0 overruns:0 frame:0 + TX packets:45441 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:0 + RX bytes:78447844 (74.8 MB) TX bytes:3080693 (2.9 MB) + +native_6 Link encap:Unknown + inet addr:10.226.1.1 Mask:255.255.255.255 + UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1422 Metric:1 + RX packets:263 errors:0 dropped:0 overruns:0 frame:0 + TX packets:131 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:0 + RX bytes:66870 (65.3 KB) TX bytes:66274 (64.7 KB) + +native_4 Link encap:Unknown + inet addr:10.226.1.1 Mask:255.255.255.255 + UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1422 Metric:1 + RX packets:1 errors:0 dropped:0 overruns:0 frame:0 + TX packets:1 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:0 + RX bytes:144 (144 Bytes) TX bytes:100 (100 Bytes) + +forticlient_14 Link encap:Unknown + inet addr:10.226.0.1 Mask:255.255.255.255 + UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1438 Metric:1 + RX packets:1 errors:0 dropped:0 overruns:0 frame:0 + TX packets:2 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:0 + RX bytes:144 (144 Bytes) TX bytes:262 (262 Bytes) diff --git a/test/unit/fortios/mock_data/get_router_info_bgp_neighbor_10.15.2.101.txt b/test/unit/fortios/mock_data/get_router_info_bgp_neighbor_10.15.2.101.txt index e69de29..bb032f4 100644 --- a/test/unit/fortios/mock_data/get_router_info_bgp_neighbor_10.15.2.101.txt +++ b/test/unit/fortios/mock_data/get_router_info_bgp_neighbor_10.15.2.101.txt @@ -0,0 +1,45 @@ +BGP neighbor is 10.15.2.101, remote AS 65208, local AS 65432, external link + BGP version 4, remote router ID 74.201.254.126 + BGP state = Established, up for 14:03:33 + Last read 00:00:35, hold time is 180, keepalive interval is 60 seconds + Configured hold time is 180, keepalive interval is 60 seconds + Neighbor capabilities: + Route refresh: advertised and received (old and new) + Address family IPv4 Unicast: advertised and received + Address family IPv6 Unicast: advertised and received + Received 178916 messages, 76 notifications, 0 in queue + Sent 227304 messages, 94 notifications, 0 in queue + Route refresh request: received 0, sent 0 + Minimum time between advertisement runs is 30 seconds + + For address family: IPv4 Unicast + BGP table version 20239, neighbor version 20238 + Index 6, Offset 0, Mask 0x40 + Community attribute sent to this neighbor (both) + Inbound path policy configured + Outbound path policy configured + Route map for incoming advertisements is *allow-officeroot + Route map for outgoing advertisements is *allow-taggedroot + 1 accepted prefixes + 666 announced prefixes + + For address family: IPv6 Unicast + BGP table version 580, neighbor version 580 + Index 7, Offset 0, Mask 0x80 + Community attribute sent to this neighbor (both) + Inbound path policy configured + Outbound path policy configured + Route map for incoming advertisements is *allow-officeroot + Route map for outgoing advertisements is *deny-allroot + 0 accepted prefixes + 0 announced prefixes + + Connections established 38; dropped 37 +Local host: 10.15.2.100, Local port: 21921 +Foreign host: 10.15.2.101, Foreign port: 179 +Nexthop: 10.15.2.100 +Nexthop global: :: +Nexthop local: :: +BGP connection: non shared network +Last Reset: 14:03:47, due to BGP Notification sent +Notification Error Message: (CeaseUnspecified Error Subcode) diff --git a/test/unit/fortios/mock_data/get_router_info_bgp_neighbor_10.15.2.105.txt b/test/unit/fortios/mock_data/get_router_info_bgp_neighbor_10.15.2.105.txt index e69de29..bd7c2f5 100644 --- a/test/unit/fortios/mock_data/get_router_info_bgp_neighbor_10.15.2.105.txt +++ b/test/unit/fortios/mock_data/get_router_info_bgp_neighbor_10.15.2.105.txt @@ -0,0 +1,42 @@ +BGP neighbor is 10.15.2.105, remote AS 65209, local AS 65432, external link + BGP version 4, remote router ID 209.92.66.34 + BGP state = Established, up for 01w3d19h + Last read 00:00:31, hold time is 180, keepalive interval is 60 seconds + Configured hold time is 180, keepalive interval is 60 seconds + Neighbor capabilities: + Route refresh: advertised and received (old and new) + Address family IPv4 Unicast: advertised and received + Address family IPv6 Unicast: advertised and received + Received 164115 messages, 207 notifications, 0 in queue + Sent 222373 messages, 223 notifications, 0 in queue + Route refresh request: received 0, sent 0 + Minimum time between advertisement runs is 30 seconds + + For address family: IPv4 Unicast + BGP table version 20294, neighbor version 20293 + Index 0, Offset 0, Mask 0x1 + Community attribute sent to this neighbor (both) + Inbound path policy configured + Outbound path policy configured + Route map for incoming advertisements is *allow-officeroot + Route map for outgoing advertisements is *allow-taggedroot + 1 accepted prefixes + 668 announced prefixes + + For address family: IPv6 Unicast + BGP table version 583, neighbor version 583 + Index 11, Offset 1, Mask 0x8 + Community attribute sent to this neighbor (both) + 0 accepted prefixes + 3 announced prefixes + + Connections established 111; dropped 111 +Local host: 10.15.2.104, Local port: 18347 +Foreign host: 10.15.2.105, Foreign port: 179 +Nexthop: 10.15.2.104 +Nexthop global: :: +Nexthop local: :: +BGP connection: non shared network +Last Reset: 01w3d19h, due to BGP Notification sent +Notification Error Message: (CeaseUnspecified Error Subcode) + diff --git a/test/unit/fortios/mock_data/get_router_info_bgp_neighbor_10.15.2.99.txt b/test/unit/fortios/mock_data/get_router_info_bgp_neighbor_10.15.2.99.txt index e69de29..ef864c2 100644 --- a/test/unit/fortios/mock_data/get_router_info_bgp_neighbor_10.15.2.99.txt +++ b/test/unit/fortios/mock_data/get_router_info_bgp_neighbor_10.15.2.99.txt @@ -0,0 +1,33 @@ +BGP neighbor is 10.15.2.99, remote AS 65307, local AS 65432, external link + Administratively shut down + BGP version 4, remote router ID 0.0.0.0 + BGP state = Idle + Not directly connected EBGP + Last read 11w0d23h, hold time is 180, keepalive interval is 60 seconds + Configured hold time is 180, keepalive interval is 60 seconds + Received 81901 messages, 0 notifications, 0 in queue + Sent 90330 messages, 6 notifications, 0 in queue + Route refresh request: received 3, sent 0 + Minimum time between advertisement runs is 30 seconds + + For address family: IPv4 Unicast + BGP table version 20294, neighbor version 0 + Index 5, Offset 0, Mask 0x20 + Community attribute sent to this neighbor (both) + Inbound path policy configured + Outbound path policy configured + Route map for incoming advertisements is *allow-taggedroot + Route map for outgoing advertisements is *allow-taggedroot + 0 accepted prefixes + 0 announced prefixes + + For address family: IPv6 Unicast + BGP table version 583, neighbor version 0 + Index 6, Offset 0, Mask 0x40 + Community attribute sent to this neighbor (both) + 0 accepted prefixes + 0 announced prefixes + + Connections established 6; dropped 6 +Last Reset: 11w0d23h, due to BGP Notification sent +Notification Error Message: (Cease/Administratively Shutdown.) diff --git a/test/unit/fortios/mock_data/get_router_info_bgp_neighbors_10.15.2.101_received-routes_|_grep_prefixes_.txt b/test/unit/fortios/mock_data/get_router_info_bgp_neighbors_10.15.2.101_received-routes_|_grep_prefixes_.txt index e69de29..8b13789 100644 --- a/test/unit/fortios/mock_data/get_router_info_bgp_neighbors_10.15.2.101_received-routes_|_grep_prefixes_.txt +++ b/test/unit/fortios/mock_data/get_router_info_bgp_neighbors_10.15.2.101_received-routes_|_grep_prefixes_.txt @@ -0,0 +1 @@ + diff --git a/test/unit/fortios/mock_data/get_router_info_bgp_sum.txt b/test/unit/fortios/mock_data/get_router_info_bgp_sum.txt index e69de29..5cbd1da 100644 --- a/test/unit/fortios/mock_data/get_router_info_bgp_sum.txt +++ b/test/unit/fortios/mock_data/get_router_info_bgp_sum.txt @@ -0,0 +1,11 @@ +BGP router identifier 193.235.32.243, local AS number 65432 +BGP table version is 20239 +454 BGP AS-PATH entries +54 BGP community entries + +Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd +10.15.2.99 4 65307 81901 90336 0 0 0 never Idle (Admin) +10.15.2.101 4 65208 178986 227392 20238 0 0 13:58:12 1 +10.15.2.105 4 65209 163073 221322 20238 0 0 01w3d00h 1 + +Total number of neighbors 3 \ No newline at end of file diff --git a/test/unit/fortios/mock_data/router_bgp.txt b/test/unit/fortios/mock_data/router_bgp.txt index e69de29..682f9b9 100644 --- a/test/unit/fortios/mock_data/router_bgp.txt +++ b/test/unit/fortios/mock_data/router_bgp.txt @@ -0,0 +1,60 @@ +config router bgp + set as 65432 + set router-id 10.235.32.243 + config aggregate-address + edit 1 + set prefix 192.168.53.0 255.255.255.0 + next + edit 2 + set prefix 192.168.4.0 255.255.252.0 + next + end + config neighbor + edit "10.15.2.99" + set bfd enable + set shutdown enable + set description "LOMGW-ASH2-1 PRIMARY TUNNEL" + set remote-as 65307 + set route-map-in "allow-tagged" + set route-map-out "allow-tagged" + next + edit "10.15.2.101" + set bfd enable + set description "OFFICE NYC620 PRIMARY TUNNEL" + set remote-as 65208 + set route-map-in "allow-office" + set route-map-in6 "allow-office" + set route-map-out "allow-tagged" + set route-map-out6 "deny-all" + next + edit "10.15.2.105" + set bfd enable + set description "OFFICE SFO988 SECONDARY TUNNEL" + set remote-as 65209 + set route-map-in "allow-office" + set route-map-out "allow-tagged" + next + end + config redistribute "connected" + end + config redistribute "rip" + end + config redistribute "ospf" + end + config redistribute "static" + set status enable + set route-map "tag-static-with-community" + end + config redistribute "isis" + end + config redistribute6 "connected" + end + config redistribute6 "rip" + end + config redistribute6 "ospf" + end + config redistribute6 "static" + end + config redistribute6 "isis" + end +end \ No newline at end of file From 68ab0bf250fedf29235b4a22979bb22a93d71cfa Mon Sep 17 00:00:00 2001 From: David Barroso Date: Wed, 2 Dec 2015 13:38:18 +0100 Subject: [PATCH 10/11] Bugfixes --- napalm/fortios.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/napalm/fortios.py b/napalm/fortios.py index 5e61f16..f1ccd37 100644 --- a/napalm/fortios.py +++ b/napalm/fortios.py @@ -124,13 +124,13 @@ class FortiOSDriver(NetworkDriver): domain = execute_get(self.device, 'get system dns | grep domain')['domain'] return { - 'vendor': 'Fortigate', - 'os_version': system_status['Version'].split(',')[0].split()[1], + 'vendor': unicode('Fortigate'), + 'os_version': unicode(system_status['Version'].split(',')[0].split()[1]), 'uptime': convert_uptime_string_seconds(performance_status['Uptime']), - 'serial_number': system_status['Serial-Number'], - 'model': system_status['Version'].split(',')[0].split()[0], - 'hostname': system_status['Hostname'], - 'fqdn': '{}.{}'.format(system_status['Hostname'], domain), + 'serial_number': unicode(system_status['Serial-Number']), + 'model': unicode(system_status['Version'].split(',')[0].split()[0]), + 'hostname': unicode(system_status['Hostname']), + 'fqdn': u'{}.{}'.format(system_status['Hostname'], domain), 'interface_list': interface_list } From f1e8ebb1d02f543f14545186277c74353413a013 Mon Sep 17 00:00:00 2001 From: David Barroso Date: Wed, 2 Dec 2015 13:38:37 +0100 Subject: [PATCH 11/11] Add quick todo so i don't forget --- utils/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/utils/__init__.py b/utils/__init__.py index e69de29..4b2198c 100644 --- a/utils/__init__.py +++ b/utils/__init__.py @@ -0,0 +1 @@ +# TODO move utils folder inside napalm \ No newline at end of file