class test_show_service_group_stats(unittest.TestCase): device = Device(name='aDevice') empty_output = {'execute.return_value': ''} golden_parsed_output_1 = { 'service_group_statistics': { 'global': { 'num_of_groups': 5, 'num_of_members': 8005 }, '1': { 'num_of_interfaces': 1, 'num_of_members': { 3000: { 'service_instance': 3000 } }, 'members_joined': 13000, 'members_left': 10000 }, '2': { 'num_of_interfaces': 1, 'num_of_members': { 2000: { 'service_instance': 2000 } }, 'members_joined': 10000, 'members_left': 8000 }, '3': { 'num_of_interfaces': 1, 'num_of_members': { 3000: { 'service_instance': 3000 } }, 'members_joined': 9000, 'members_left': 6000 }, '10': { 'num_of_interfaces': 1, 'num_of_members': { 3: { 'service_instance': 3 } }, 'members_joined': 8003, 'members_left': 8000 }, '20': { 'num_of_interfaces': 1, 'num_of_members': { 2: { 'service_instance': 2 } }, 'members_joined': 8002, 'members_left': 8000 } } } golden_parsed_output_2 = { 'service_group_statistics': { 'global': { 'num_of_groups': 1, 'num_of_members': 2 }, '1': { 'num_of_interfaces': 1, 'num_of_members': { 2: { 'sub_interface': 2 } }, 'members_joined': 103, 'members_left': 101 } } } golden_output_1 = { 'execute.return_value': '''\ Service Group global statistics: Number of groups: 5 Number of members: 8005 Service Group 1 statistics: Number of Interfaces: 1 Number of members: 3000 Service Instance 3000 Members joined: 13000 Members left: 10000 Service Group 2 statistics: Number of Interfaces: 1 Number of members: 2000 Service Instance 2000 Members joined: 10000 Members left: 8000 Service Group 3 statistics: Number of Interfaces: 1 Number of members: 3000 Service Instance 3000 Members joined: 9000 Members left: 6000 Service Group 10 statistics: Number of Interfaces: 1 Number of members: 3 Service Instance 3 Members joined: 8003 Members left: 8000 Service Group 20 statistics: Number of Interfaces: 1 Number of members: 2 Service Instance 2 Members joined: 8002 Members left: 8000 ''' } golden_output_2 = { 'execute.return_value': '''\ Service Group global statistics: Number of groups: 1 Number of members: 2 Service Group 1 statistics: Number of Interfaces: 1 Number of members: 2 Sub-interface 2 Members joined: 103 Members left: 101 ''' } def test_empty(self): self.device1 = Mock(**self.empty_output) obj = ShowServiceGroupStats(device=self.device1) with self.assertRaises(SchemaEmptyParserError): parsed_output = obj.parse() def test_golden_1(self): self.device = Mock(**self.golden_output_1) obj = ShowServiceGroupStats(device=self.device) parsed_output = obj.parse() self.assertEqual(parsed_output, self.golden_parsed_output_1) def test_golden_2(self): self.device = Mock(**self.golden_output_2) obj = ShowServiceGroupStats(device=self.device) parsed_output = obj.parse() self.assertEqual(parsed_output, self.golden_parsed_output_2)
class TestShowVersion(unittest.TestCase): device_empty = Device(name='empty') device_c7600 = Device(name='c7600') empty_output = {'execute.return_value': ''} output_c7600 = {'execute.return_value': ''' Cisco IOS Software, s72033_rp Software (s72033_rp-ADVENTERPRISEK9_DBG-M), Version 15.4(0.10)S, EARLY DEPLOYMENT ENGINEERING WEEKLY BUILD, synced to BLD_DARLING_122S_040709_1301 Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2013 by Cisco Systems, Inc. Compiled Wed 26-Jun-13 02:21 by alnguyen ROM: System Bootstrap, Version 12.2(17r)SX7, RELEASE SOFTWARE (fc1) BOOTLDR: Cisco IOS Software, s72033_rp Software (s72033_rp-ADVENTERPRISEK9_DBG-M), Version 15.4(0.10)S, EARLY DEPLOYMENT ENGINEERING WEEKLY BUILD, synced to BLD_DARLING_122S_040709_1301 ipcore-ssr-uut2 uptime is 22 weeks, 6 days, 2 hours, 1 minute Uptime for this control processor is 22 weeks, 6 days, 1 hour, 57 minutes System returned to ROM by power cycle at 03:04:03 PDT Thu May 18 2017 (SP by power on) System image file is "disk0:s72033-adventerprisek9_dbg-mz.154-0.10.S-ipcore-ssr-uut2" Last reload type: Normal Reload Last reload reason: abort at PC 0x433A11BC This product contains cryptographic features and is subject to United States and local country laws governing import, export, transfer and use. Delivery of Cisco cryptographic products does not imply third-party authority to import, export, distribute or use encryption. Importers, exporters, distributors and users are responsible for compliance with U.S. and local country laws. By using this product you agree to comply with applicable laws and regulations. If you are unable to comply with U.S. and local laws, return this product immediately. A summary of U.S. laws governing Cisco cryptographic products may be found at: http://www.cisco.com/wwl/export/crypto/tool/stqrg.html If you require further assistance please contact us by sending email to [email protected]. cisco CISCO7606 (R7000) processor (revision 1.0) with 983008K/65536K bytes of memory. Processor board ID FOX11140RN8 SR71000 CPU at 600MHz, Implementation 1284, Rev 1.2, 512KB L2 Cache Last reset from s/w reset 1 Enhanced FlexWAN controller (4 Serial). 1 Virtual Ethernet interface 52 Gigabit Ethernet interfaces 4 Serial interfaces 1917K bytes of non-volatile configuration memory. 8192K bytes of packet buffer memory. 65536K bytes of Flash internal SIMM (Sector size 512K). Configuration register is 0x2 '''} parsed_output_c7600 = { 'version': { 'bootldr_version': 'Cisco IOS Software, s72033_rp Software (s72033_rp-ADVENTERPRISEK9_DBG-M), Version 15.4(0.10)S, EARLY DEPLOYMENT ENGINEERING WEEKLY BUILD, synced to BLD_DARLING_122S_040709_1301', 'chassis': 'CISCO7606', 'compiled_by': 'alnguyen', 'compiled_date': 'Wed 26-Jun-13 02:21', 'control_processor_uptime': '22 weeks, 6 days, 1 hour, 57 minutes', 'controller': { 'counts': 1, 'serial': 4, 'type': 'Enhanced FlexWAN', }, 'cpu': { 'implementation': '1284', 'l2_cache': '512KB', 'name': 'SR71000', 'rev': '1.2', 'speed': '600MHz', }, 'curr_config_register': '0x2', 'hostname': 'ipcore-ssr-uut2', 'image_id': 's72033_rp-ADVENTERPRISEK9_DBG-M', 'interfaces': { 'gigabit_ethernet': 52, 'serial': 4, 'virtual_ethernet': 1, }, 'last_reload': { 'reason': 'abort at PC 0x433A11BC', 'type': 'Normal Reload', }, 'last_reset': 's/w', 'main_mem': '983008', 'memory': { 'flash_internal_SIMM': 65536, 'non_volatile_conf': 1917, 'packet_buffer': 8192, }, 'os': 'IOS', 'platform': 's72033_rp', 'processor_board_id': 'FOX11140RN8', 'processor_type': 'R7000', 'returned_to_rom_by': 'power cycle at 03:04:03 PDT Thu May 18 2017 (SP by power on)', 'rom': 'System Bootstrap, Version 12.2(17r)SX7, RELEASE SOFTWARE', 'rom_version': '(fc1)', 'system_image': 'disk0:s72033-adventerprisek9_dbg-mz.154-0.10.S-ipcore-ssr-uut2', 'uptime': '22 weeks, 6 days, 2 hours, 1 minute', 'version': '15.4(0.10)S', }, } def test_empty(self): self.device_empty = Mock(**self.empty_output) obj = ShowVersion(device=self.device_empty) with self.assertRaises(SchemaEmptyParserError): empty_parsed_output = obj.parse() def test_c7600(self): self.maxDiff = None self.device_c7600 = Mock(**self.output_c7600) obj = ShowVersion(device=self.device_c7600) parsed_output = obj.parse() self.assertEqual(parsed_output, self.parsed_output_c7600)
class TestShowInventory(unittest.TestCase): dev1 = Device(name='empty') dev_iosv = Device(name='c7600') empty_output = {'execute.return_value': ''} output_c7600 = {'execute.return_value': ''' NAME: "CISCO7606", DESCR: "Cisco Systems Cisco 7600 6-slot Chassis System" PID: CISCO7606 , VID: , SN: FOX11140RN8 NAME: "CLK-7600 1", DESCR: "OSR-7600 Clock FRU 1" PID: CLK-7600 , VID: , SN: NWG1112014W NAME: "CLK-7600 2", DESCR: "OSR-7600 Clock FRU 2" PID: CLK-7600 , VID: , SN: NWG1112014W NAME: "module 1", DESCR: "WS-X6748-GE-TX CEF720 48 port 10/100/1000mb Ethernet Rev. 2.7" PID: WS-X6748-GE-TX , VID: V02, SN: SAL1209HMW3 NAME: "switching engine sub-module of 1", DESCR: "WS-F6700-CFC Centralized Forwarding Card Rev. 4.0" PID: WS-F6700-CFC , VID: V05, SN: SAL1207G5V1 NAME: "module 2", DESCR: "2 port adapter Enhanced FlexWAN Rev. 2.1" PID: WS-X6582-2PA , VID: V06, SN: JAE0939LYNQ NAME: "module 2/1", DESCR: "Serial Port Adapter" PID: PA-4T+ , VID: , SN: 32861325 NAME: "module 5", DESCR: "WS-SUP720-3BXL 2 ports Supervisor Engine 720 Rev. 4.1" PID: WS-SUP720-3BXL , VID: V11, SN: SAD09020BF8 NAME: "msfc sub-module of 5", DESCR: "WS-SUP720 MSFC3 Daughterboard Rev. 2.2" PID: WS-SUP720 , VID: , SN: SAD090105M6 NAME: "switching engine sub-module of 5", DESCR: "WS-F6K-PFC3BXL Policy Feature Card 3 Rev. 1.4" PID: WS-F6K-PFC3BXL , VID: , SN: SAD090301K6 NAME: "module 6", DESCR: "WS-SUP720-3BXL 2 ports Supervisor Engine 720 Rev. 5.12" PID: WS-SUP720-3BXL , VID: V11, SN: SAL15129MRC NAME: "msfc sub-module of 6", DESCR: "WS-SUP720 MSFC3 Daughterboard Rev. 5.1" PID: WS-SUP720 , VID: , SN: SAL15045PYS NAME: "switching engine sub-module of 6", DESCR: "WS-F6K-PFC3BXL Policy Feature Card 3 Rev. 1.11" PID: WS-F6K-PFC3BXL , VID: V02, SN: SAL15129KW4 NAME: "PS 1 PWR-1900-AC/6", DESCR: "AC_6 power supply, 1900 watt 1" PID: PWR-1900-AC/6 , VID: V02, SN: DCA1104401B NAME: "PS 2 PWR-1900-AC/6", DESCR: "AC_6 power supply, 1900 watt 2" PID: PWR-1900-AC/6 , VID: V02, SN: DCA11044011 '''} parsed_output = { 'index': { 1: { 'descr': 'Cisco Systems Cisco 7600 6-slot Chassis System', 'name': 'CISCO7606', 'pid': 'CISCO7606', 'sn': 'FOX11140RN8', }, 2: { 'descr': 'OSR-7600 Clock FRU 1', 'name': 'CLK-7600 1', 'pid': 'CLK-7600', 'sn': 'NWG1112014W', }, 3: { 'descr': 'OSR-7600 Clock FRU 2', 'name': 'CLK-7600 2', 'pid': 'CLK-7600', 'sn': 'NWG1112014W', }, 4: { 'descr': 'WS-X6748-GE-TX CEF720 48 port 10/100/1000mb Ethernet Rev. 2.7', 'name': 'module 1', 'pid': 'WS-X6748-GE-TX', 'sn': 'SAL1209HMW3', 'vid': 'V02', }, 5: { 'descr': 'WS-F6700-CFC Centralized Forwarding Card Rev. 4.0', 'name': 'switching engine sub-module of 1', 'pid': 'WS-F6700-CFC', 'sn': 'SAL1207G5V1', 'vid': 'V05', }, 6: { 'descr': '2 port adapter Enhanced FlexWAN Rev. 2.1', 'name': 'module 2', 'pid': 'WS-X6582-2PA', 'sn': 'JAE0939LYNQ', 'vid': 'V06', }, 7: { 'descr': 'Serial Port Adapter', 'name': 'module 2/1', 'pid': 'PA-4T+', 'sn': '32861325', }, 8: { 'descr': 'WS-SUP720-3BXL 2 ports Supervisor Engine 720 Rev. 4.1', 'name': 'module 5', 'pid': 'WS-SUP720-3BXL', 'sn': 'SAD09020BF8', 'vid': 'V11', }, 9: { 'descr': 'WS-SUP720 MSFC3 Daughterboard Rev. 2.2', 'name': 'msfc sub-module of 5', 'pid': 'WS-SUP720', 'sn': 'SAD090105M6', }, 10: { 'descr': 'WS-F6K-PFC3BXL Policy Feature Card 3 Rev. 1.4', 'name': 'switching engine sub-module of 5', 'pid': 'WS-F6K-PFC3BXL', 'sn': 'SAD090301K6', }, 11: { 'descr': 'WS-SUP720-3BXL 2 ports Supervisor Engine 720 Rev. 5.12', 'name': 'module 6', 'pid': 'WS-SUP720-3BXL', 'sn': 'SAL15129MRC', 'vid': 'V11', }, 12: { 'descr': 'WS-SUP720 MSFC3 Daughterboard Rev. 5.1', 'name': 'msfc sub-module of 6', 'pid': 'WS-SUP720', 'sn': 'SAL15045PYS', }, 13: { 'descr': 'WS-F6K-PFC3BXL Policy Feature Card 3 Rev. 1.11', 'name': 'switching engine sub-module of 6', 'pid': 'WS-F6K-PFC3BXL', 'sn': 'SAL15129KW4', 'vid': 'V02', }, 14: { 'descr': 'AC_6 power supply, 1900 watt 1', 'name': 'PS 1 PWR-1900-AC/6', 'pid': 'PWR-1900-AC/6', 'sn': 'DCA1104401B', 'vid': 'V02', }, 15: { 'descr': 'AC_6 power supply, 1900 watt 2', 'name': 'PS 2 PWR-1900-AC/6', 'pid': 'PWR-1900-AC/6', 'sn': 'DCA11044011', 'vid': 'V02', }, }, } def test_empty(self): self.dev1 = Mock(**self.empty_output) version_obj = ShowInventory(device=self.dev1) with self.assertRaises(SchemaEmptyParserError): empty_parsed_output = version_obj.parse() def test_c7600(self): self.maxDiff = None self.device = Mock(**self.output_c7600) obj = ShowInventory(device=self.device) parsed_output = obj.parse() self.assertEqual(parsed_output, self.parsed_output)
class TestShowRedundancy(unittest.TestCase): dev1 = Device(name='empty') dev_c9500 = Device(name='c9500') empty_output = {'execute.return_value': ''} golden_parsed_output_c9500 = { "red_sys_info": { "available_system_uptime": "1 day, 18 hours, 48 minutes", "switchovers_system_experienced": "0", "standby_failures": "0", "last_switchover_reason": "none", "hw_mode": "Simplex", "conf_red_mode": "Non-redundant", "oper_red_mode": "Non-redundant", "maint_mode": "Disabled", "communications": "Down", "communications_reason": "Failure" }, "slot": { "slot 1": { "curr_sw_state": "ACTIVE", "uptime_in_curr_state": "1 day, 18 hours, 48 minutes", "image_ver": "Cisco IOS Software [Amsterdam], Catalyst L3 Switch Software (CAT9K_IOSXE), Experimental Version 17.2.20191101:003833 [HEAD-/nobackup/makale/puntject2/polaris 106]", "compiled_by": "makale", "compiled_date": "Thu 31-Oct-19 17:43", "boot": "bootflash:/ecr.bin;", "config_register": "0x102", } } } golden_output_c9500 = { 'execute.return_value': '''\ show redundancy Redundant System Information : ------------------------------ Available system uptime = 1 day, 18 hours, 48 minutes Switchovers system experienced = 0 Standby failures = 0 Last switchover reason = none Hardware Mode = Simplex Configured Redundancy Mode = Non-redundant Operating Redundancy Mode = Non-redundant Maintenance Mode = Disabled Communications = Down Reason: Failure Current Processor Information : ------------------------------- Active Location = slot 1 Current Software state = ACTIVE Uptime in current state = 1 day, 18 hours, 48 minutes Image Version = Cisco IOS Software [Amsterdam], Catalyst L3 Switch Software (CAT9K_IOSXE), Experimental Version 17.2.20191101:003833 [HEAD-/nobackup/makale/puntject2/polaris 106] Copyright (c) 1986-2019 by Cisco Systems, Inc. Compiled Thu 31-Oct-19 17:43 by makale BOOT = bootflash:/ecr.bin; Configuration register = 0x102 Peer (slot: 1) information is not available because it is in 'DISABLED' state ''' } def test_empty(self): self.dev1 = Mock(**self.empty_output) redundancy_obj = ShowRedundancy(device=self.dev1) with self.assertRaises(SchemaEmptyParserError): parsed_output = redundancy_obj.parse() def test_golden_c9500(self): self.maxDiff = None self.dev_c9500 = Mock(**self.golden_output_c9500) redundancy_obj = ShowRedundancy(device=self.dev_c9500) parsed_output = redundancy_obj.parse() self.assertEqual(parsed_output, self.golden_parsed_output_c9500)
class TestShowPlatform(unittest.TestCase): dev1 = Device(name='empty') dev_c9500 = Device(name='c9500') empty_output = {'execute.return_value': ''} golden_parsed_output_c9500 = { "chassis": "C9500-32QC", "slot": { "1": { "name": "C9500-32QC", "state": "ok", "insert_time": "1d18h", "slot": "1", "cpld_ver": "19061022", "fw_ver": "17.1.1[FC2]", "subslot": { "0": { "name": "C9500-32QC", "state": "ok", "insert_time": "1d18h", "subslot": "0" } } }, "R0": { "name": "C9500-32QC", "state": "ok, active", "insert_time": "1d18h", "slot": "R0" }, "P0": { "name": "C9K-PWR-650WAC-R", "state": "ok", "insert_time": "1d18h", "slot": "P0" }, "P2": { "name": "C9K-T1-FANTRAY", "state": "ok", "insert_time": "1d18h", "slot": "P2" }, "P3": { "name": "C9K-T1-FANTRAY", "state": "ok", "insert_time": "1d18h", "slot": "P3", } } } golden_output_c9500 = { 'execute.return_value': '''\ show platform Chassis type: C9500-32QC Slot Type State Insert time (ago) --------- ------------------- --------------------- ----------------- 1 C9500-32QC ok 1d18h 1/0 C9500-32QC ok 1d18h R0 C9500-32QC ok, active 1d18h P0 C9K-PWR-650WAC-R ok 1d18h P2 C9K-T1-FANTRAY ok 1d18h P3 C9K-T1-FANTRAY ok 1d18h Slot CPLD Version Firmware Version --------- ------------------- --------------------------------------- 1 19061022 17.1.1[FC2] ''' } def test_empty(self): self.dev1 = Mock(**self.empty_output) platform_obj = ShowPlatform(device=self.dev1) with self.assertRaises(SchemaEmptyParserError): parsed_output = platform_obj.parse() def test_golden_c9500(self): self.maxDiff = None self.dev_c9500 = Mock(**self.golden_output_c9500) platform_obj = ShowPlatform(device=self.dev_c9500) parsed_output = platform_obj.parse() self.assertEqual(parsed_output, self.golden_parsed_output_c9500)
class test_show_lldp_interface(unittest.TestCase): dev1 = Device(name='empty') dev_c3850 = Device(name='c3850') empty_output = {'execute.return_value': ' '} golden_parsed_output = { 'interfaces': { 'GigabitEthernet1/0/15': { 'tx': 'enabled', 'rx': 'enabled', 'tx_state': 'idle', 'rx_state': 'wait for frame', }, 'GigabitEthernet1/0/16': { 'tx': 'enabled', 'rx': 'enabled', 'tx_state': 'idle', 'rx_state': 'wait for frame', }, 'GigabitEthernet1/0/17': { 'tx': 'enabled', 'rx': 'enabled', 'tx_state': 'idle', 'rx_state': 'wait for frame', }, 'GigabitEthernet2/0/15': { 'tx': 'enabled', 'rx': 'enabled', 'tx_state': 'idle', 'rx_state': 'wait for frame', }, } } golden_output = { 'execute.return_value': '''\ GigabitEthernet1/0/15: Tx: enabled Rx: enabled Tx state: IDLE Rx state: WAIT FOR FRAME GigabitEthernet1/0/16: Tx: enabled Rx: enabled Tx state: IDLE Rx state: WAIT FOR FRAME GigabitEthernet1/0/17: Tx: enabled Rx: enabled Tx state: IDLE Rx state: WAIT FOR FRAME GigabitEthernet2/0/15: Tx: enabled Rx: enabled Tx state: IDLE Rx state: WAIT FOR FRAME ''' } def test_empty(self): self.dev1 = Mock(**self.empty_output) obj = ShowLldpInterface(device=self.dev1) with self.assertRaises(SchemaEmptyParserError): parsed_output = obj.parse() def test_golden(self): self.maxDiff = None self.dev_c3850 = Mock(**self.golden_output) obj = ShowLldpInterface(device=self.dev_c3850) parsed_output = obj.parse() self.assertEqual(parsed_output, self.golden_parsed_output)
class test_show_lldp_neighbor_detail(unittest.TestCase): dev1 = Device(name='empty') dev_c3850 = Device(name='c3850') empty_output = {'execute.return_value': ' '} golden_parsed_output = { 'interfaces': { 'GigabitEthernet2/0/15': { 'if_name': 'GigabitEthernet2/0/15', 'port_id': { 'GigabitEthernet1/0/4': { 'neighbors': { 'R5': { 'neighbor_id': 'R5', 'chassis_id': '843d.c638.b980', 'port_id': 'GigabitEthernet1/0/4', 'port_description': 'GigabitEthernet1/0/4', 'system_description': 'Cisco IOS Software, C3750E Software (C3750E-UNIVERSALK9-M), Version 12.2(58)SE2, RELEASE SOFTWARE (fc1)\nTechnical Support: http://www.cisco.com/techsupport\nCopyright (c) 1986-2011 by Cisco Systems, Inc.\nCompiled Thu 21-Jul-11 01:23 by prod_rel_team', 'system_name': 'R5', 'time_remaining': 101, 'capabilities': { 'mac_bridge': { 'name': 'mac_bridge', 'system': True, 'enabled': True, }, 'router': { 'name': 'router', 'system': True, 'enabled': True, }, }, 'management_address': '10.9.1.1', 'auto_negotiation': 'supported, enabled', 'physical_media_capabilities': [ '1000baseT(FD)', '100base-TX(FD)', '100base-TX(HD)', '10base-T(FD)', '10base-T(HD)' ], 'unit_type': 30, 'vlan_id': 1, }, }, }, }, }, 'GigabitEthernet1/0/16': { 'if_name': 'GigabitEthernet1/0/16', 'port_id': { 'GigabitEthernet1/0/2': { 'neighbors': { 'R5': { 'neighbor_id': 'R5', 'chassis_id': '843d.c638.b980', 'port_id': 'GigabitEthernet1/0/2', 'port_description': 'GigabitEthernet1/0/2', 'system_description': 'Cisco IOS Software, C3750E Software (C3750E-UNIVERSALK9-M), Version 12.2(58)SE2, RELEASE SOFTWARE (fc1)\nTechnical Support: http://www.cisco.com/techsupport\nCopyright (c) 1986-2011 by Cisco Systems, Inc.\nCompiled Thu 21-Jul-11 01:23 by prod_rel_team', 'system_name': 'R5', 'time_remaining': 99, 'capabilities': { 'mac_bridge': { 'name': 'mac_bridge', 'system': True, 'enabled': True, }, 'router': { 'name': 'router', 'system': True, 'enabled': True, }, }, 'management_address': '10.9.1.1', 'auto_negotiation': 'supported, enabled', 'physical_media_capabilities': [ '1000baseT(FD)', '100base-TX(FD)', '100base-TX(HD)', '10base-T(FD)', '10base-T(HD)' ], 'unit_type': 30, 'vlan_id': 1, }, }, }, }, }, 'GigabitEthernet1/0/17': { 'if_name': 'GigabitEthernet1/0/17', 'port_id': { 'GigabitEthernet1/0/3': { 'neighbors': { 'R5': { 'neighbor_id': 'R5', 'chassis_id': '843d.c638.b980', 'port_id': 'GigabitEthernet1/0/3', 'port_description': 'GigabitEthernet1/0/3', 'system_name': 'R5', 'system_description': 'Cisco IOS Software, C3750E Software (C3750E-UNIVERSALK9-M), Version 12.2(58)SE2, RELEASE SOFTWARE (fc1)\nTechnical Support: http://www.cisco.com/techsupport\nCopyright (c) 1986-2011 by Cisco Systems, Inc.\nCompiled Thu 21-Jul-11 01:23 by prod_rel_team', 'time_remaining': 94, 'capabilities': { 'mac_bridge': { 'name': 'mac_bridge', 'system': True, 'enabled': True, }, 'router': { 'name': 'router', 'system': True, 'enabled': True, }, }, 'management_address': '10.9.1.1', 'auto_negotiation': 'supported, enabled', 'physical_media_capabilities': [ '1000baseT(FD)', '100base-TX(FD)', '100base-TX(HD)', '10base-T(FD)', '10base-T(HD)' ], 'unit_type': 30, 'vlan_id': 1, }, }, }, }, }, 'GigabitEthernet1/0/15': { 'if_name': 'GigabitEthernet1/0/15', 'port_id': { 'GigabitEthernet1/0/1': { 'neighbors': { 'R5': { 'neighbor_id': 'R5', 'chassis_id': '843d.c638.b980', 'port_id': 'GigabitEthernet1/0/1', 'port_description': 'GigabitEthernet1/0/1', 'system_name': 'R5', 'system_description': 'Cisco IOS Software, C3750E Software (C3750E-UNIVERSALK9-M), Version 12.2(58)SE2, RELEASE SOFTWARE (fc1)\nTechnical Support: http://www.cisco.com/techsupport\nCopyright (c) 1986-2011 by Cisco Systems, Inc.\nCompiled Thu 21-Jul-11 01:23 by prod_rel_team', 'time_remaining': 98, 'capabilities': { 'mac_bridge': { 'name': 'mac_bridge', 'system': True, 'enabled': True, }, 'router': { 'name': 'router', 'system': True, 'enabled': True, }, }, 'management_address': '10.9.1.1', 'auto_negotiation': 'supported, enabled', 'physical_media_capabilities': [ '1000baseT(FD)', '100base-TX(FD)', '100base-TX(HD)', '10base-T(FD)', '10base-T(HD)' ], 'unit_type': 30, 'vlan_id': 1, }, }, }, }, }, }, 'total_entries': 4, } golden_output = { 'execute.return_value': '''\ ------------------------------------------------ Local Intf: Gi2/0/15 Chassis id: 843d.c638.b980 Port id: Gi1/0/4 Port Description: GigabitEthernet1/0/4 System Name: R5 System Description: Cisco IOS Software, C3750E Software (C3750E-UNIVERSALK9-M), Version 12.2(58)SE2, RELEASE SOFTWARE (fc1) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2011 by Cisco Systems, Inc. Compiled Thu 21-Jul-11 01:23 by prod_rel_team Time remaining: 101 seconds System Capabilities: B,R Enabled Capabilities: B,R Management Addresses: IP: 10.9.1.1 Auto Negotiation - supported, enabled Physical media capabilities: 1000baseT(FD) 100base-TX(FD) 100base-TX(HD) 10base-T(FD) 10base-T(HD) Media Attachment Unit type: 30 Vlan ID: 1 ------------------------------------------------ Local Intf: Gi1/0/16 Chassis id: 843d.c638.b980 Port id: Gi1/0/2 Port Description: GigabitEthernet1/0/2 System Name: R5 System Description: Cisco IOS Software, C3750E Software (C3750E-UNIVERSALK9-M), Version 12.2(58)SE2, RELEASE SOFTWARE (fc1) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2011 by Cisco Systems, Inc. Compiled Thu 21-Jul-11 01:23 by prod_rel_team Time remaining: 99 seconds System Capabilities: B,R Enabled Capabilities: B,R Management Addresses: IP: 10.9.1.1 Auto Negotiation - supported, enabled Physical media capabilities: 1000baseT(FD) 100base-TX(FD) 100base-TX(HD) 10base-T(FD) 10base-T(HD) Media Attachment Unit type: 30 Vlan ID: 1 ------------------------------------------------ Local Intf: Gi1/0/17 Chassis id: 843d.c638.b980 Port id: Gi1/0/3 Port Description: GigabitEthernet1/0/3 System Name: R5 System Description: Cisco IOS Software, C3750E Software (C3750E-UNIVERSALK9-M), Version 12.2(58)SE2, RELEASE SOFTWARE (fc1) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2011 by Cisco Systems, Inc. Compiled Thu 21-Jul-11 01:23 by prod_rel_team Time remaining: 94 seconds System Capabilities: B,R Enabled Capabilities: B,R Management Addresses: IP: 10.9.1.1 Auto Negotiation - supported, enabled Physical media capabilities: 1000baseT(FD) 100base-TX(FD) 100base-TX(HD) 10base-T(FD) 10base-T(HD) Media Attachment Unit type: 30 Vlan ID: 1 ------------------------------------------------ Local Intf: Gi1/0/15 Chassis id: 843d.c638.b980 Port id: Gi1/0/1 Port Description: GigabitEthernet1/0/1 System Name: R5 System Description: Cisco IOS Software, C3750E Software (C3750E-UNIVERSALK9-M), Version 12.2(58)SE2, RELEASE SOFTWARE (fc1) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2011 by Cisco Systems, Inc. Compiled Thu 21-Jul-11 01:23 by prod_rel_team Time remaining: 98 seconds System Capabilities: B,R Enabled Capabilities: B,R Management Addresses: IP: 10.9.1.1 Auto Negotiation - supported, enabled Physical media capabilities: 1000baseT(FD) 100base-TX(FD) 100base-TX(HD) 10base-T(FD) 10base-T(HD) Media Attachment Unit type: 30 Vlan ID: 1 Total entries displayed: 4 ''' } def test_empty(self): self.dev1 = Mock(**self.empty_output) obj = ShowLldpNeighborsDetail(device=self.dev1) with self.assertRaises(SchemaEmptyParserError): parsed_output = obj.parse() def test_golden(self): self.maxDiff = None self.dev_c3850 = Mock(**self.golden_output) obj = ShowLldpNeighborsDetail(device=self.dev_c3850) parsed_output = obj.parse() self.assertEqual(parsed_output, self.golden_parsed_output)
class test_show_system_internal_sysmgr_service_name(unittest.TestCase): maxDiff = None device = Device(name='aDevice') empty_output = {'execute.return_value': ''} golden_parsed_output = { "instance": { "__inst_007__ospf": { "tag": { "N/A": { "process_name": "ospf", "internal_id": 41, "state_start_date": "Sat Jul 1 14:49:10 2017", "uuid": "0x47000119", "reboot_state": "never_started", "plugin_id": "1", "state": "SRV_STATE_WAIT_SPAWN_CONDITION" } } }, "__inst_002__ospf": { "tag": { "100": { "sap": 321, "process_name": "ospf", "internal_id": 18, "state_start_date": "Sat Jul 1 14:49:12 2017", "uuid": "0x42000119", "reboot_state": "never_crashed", "restart_count": 1, "plugin_id": "1", "last_restart_date": "Sat Jul 1 14:49:10 2017", "pid": 7150, "state": "SRV_STATE_HANDSHAKED" } } }, "__inst_001__ospf": { "tag": { "1": { "sap": 320, "process_name": "ospf", "internal_id": 13, "state_start_date": "Sat Jul 1 14:49:12 2017", "uuid": "0x41000119", "reboot_state": "never_crashed", "restart_count": 1, "plugin_id": "1", "last_restart_date": "Sat Jul 1 14:49:10 2017", "pid": 7154, "state": "SRV_STATE_HANDSHAKED" } } } } } golden_output = { 'execute.return_value': ''' Service "__inst_001__ospf" ("ospf", 13): UUID = 0x41000119, PID = 7154, SAP = 320 State: SRV_STATE_HANDSHAKED (entered at time Sat Jul 1 14:49:12 2017). Restart count: 1 Time of last restart: Sat Jul 1 14:49:10 2017. The service never crashed since the last reboot. Tag = 1 Plugin ID: 1 Service "__inst_002__ospf" ("ospf", 18): UUID = 0x42000119, PID = 7150, SAP = 321 State: SRV_STATE_HANDSHAKED (entered at time Sat Jul 1 14:49:12 2017). Restart count: 1 Time of last restart: Sat Jul 1 14:49:10 2017. The service never crashed since the last reboot. Tag = 100 Plugin ID: 1 Service "__inst_007__ospf" ("ospf", 41): UUID = 0x47000119, -- Currently not running -- State: SRV_STATE_WAIT_SPAWN_CONDITION (entered at time Sat Jul 1 14:49:10 2017). The service has never been started since the last reboot. Tag = N/A Plugin ID: 1 ''' } golden_parsed_output2 = { 'instance': { '__inst_001__ospf': { 'tag': { 'ENT': { 'internal_id': 83, 'last_restart_date': 'Wed ' 'Mar ' '18 ' '10:14:35 ' '2020', 'pid': 23994, 'plugin_id': '1', 'process_name': 'ospf', 'reboot_state': 'never_crashed', 'restart_count': 1, 'sap': 320, 'state': 'SRV_STATE_HANDSHAKED', 'state_start_date': 'Wed ' 'Mar 18 ' '10:14:35 ' '2020', 'uuid': '0x41000119' } } }, '__inst_002__ospf': { 'tag': { 'IPN': { 'internal_id': 88, 'last_restart_date': 'Wed ' 'Mar ' '18 ' '10:14:35 ' '2020', 'pid': 23993, 'plugin_id': '1', 'process_name': 'ospf', 'reboot_state': 'never_crashed', 'restart_count': 1, 'sap': 321, 'state': 'SRV_STATE_HANDSHAKED', 'state_start_date': 'Wed ' 'Mar 18 ' '10:14:35 ' '2020', 'uuid': '0x42000119' } } }, '__inst_003__ospf': { 'tag': { 'l3vpn': { 'internal_id': 93, 'last_restart_date': 'Wed ' 'Mar ' '18 ' '10:14:35 ' '2020', 'pid': 23992, 'plugin_id': '1', 'process_name': 'ospf', 'reboot_state': 'never_crashed', 'restart_count': 1, 'sap': 322, 'state': 'SRV_STATE_HANDSHAKED', 'state_start_date': 'Wed ' 'Mar ' '18 ' '10:14:35 ' '2020', 'uuid': '0x43000119' } } }, '__inst_004__ospf': { 'tag': { 'N/A': { 'internal_id': 98, 'plugin_id': '1', 'process_name': 'ospf', 'reboot_state': 'never_started', 'state': 'SRV_STATE_WAIT_SPAWN_CONDITION', 'state_start_date': 'Wed ' 'Mar 18 ' '10:14:35 ' '2020', 'uuid': '0x44000119' } } }, '__inst_005__ospf': { 'tag': { 'N/A': { 'internal_id': 103, 'plugin_id': '1', 'process_name': 'ospf', 'reboot_state': 'never_started', 'state': 'SRV_STATE_WAIT_SPAWN_CONDITION', 'state_start_date': 'Wed ' 'Mar 18 ' '10:14:35 ' '2020', 'uuid': '0x45000119' } } }, '__inst_006__ospf': { 'tag': { 'N/A': { 'internal_id': 107, 'plugin_id': '1', 'process_name': 'ospf', 'reboot_state': 'never_started', 'state': 'SRV_STATE_WAIT_SPAWN_CONDITION', 'state_start_date': 'Wed ' 'Mar 18 ' '10:14:35 ' '2020', 'uuid': '0x46000119' } } }, '__inst_007__ospf': { 'tag': { 'N/A': { 'internal_id': 111, 'plugin_id': '1', 'process_name': 'ospf', 'reboot_state': 'never_started', 'state': 'SRV_STATE_WAIT_SPAWN_CONDITION', 'state_start_date': 'Wed ' 'Mar 18 ' '10:14:35 ' '2020', 'uuid': '0x47000119' } } }, '__inst_008__ospf': { 'tag': { 'N/A': { 'internal_id': 115, 'plugin_id': '1', 'process_name': 'ospf', 'reboot_state': 'never_started', 'state': 'SRV_STATE_WAIT_SPAWN_CONDITION', 'state_start_date': 'Wed ' 'Mar 18 ' '10:14:35 ' '2020', 'uuid': '0x48000119' } } }, '__inst_009__ospf': { 'tag': { 'N/A': { 'internal_id': 119, 'plugin_id': '1', 'process_name': 'ospf', 'reboot_state': 'never_started', 'state': 'SRV_STATE_WAIT_SPAWN_CONDITION', 'state_start_date': 'Wed ' 'Mar 18 ' '10:14:35 ' '2020', 'uuid': '0x49000119' } } }, '__inst_010__ospf': { 'tag': { 'N/A': { 'internal_id': 123, 'plugin_id': '1', 'process_name': 'ospf', 'reboot_state': 'never_started', 'state': 'SRV_STATE_WAIT_SPAWN_CONDITION', 'state_start_date': 'Wed ' 'Mar 18 ' '10:14:35 ' '2020', 'uuid': '0x4A000119' } } }, '__inst_011__ospf': { 'tag': { 'N/A': { 'internal_id': 127, 'plugin_id': '1', 'process_name': 'ospf', 'reboot_state': 'never_started', 'state': 'SRV_STATE_WAIT_SPAWN_CONDITION', 'state_start_date': 'Wed ' 'Mar 18 ' '10:14:35 ' '2020', 'uuid': '0x4B000119' } } }, '__inst_012__ospf': { 'tag': { 'N/A': { 'internal_id': 131, 'plugin_id': '1', 'process_name': 'ospf', 'reboot_state': 'never_started', 'state': 'SRV_STATE_WAIT_SPAWN_CONDITION', 'state_start_date': 'Wed ' 'Mar 18 ' '10:14:35 ' '2020', 'uuid': '0x4C000119' } } }, '__inst_013__ospf': { 'tag': { 'N/A': { 'internal_id': 135, 'plugin_id': '1', 'process_name': 'ospf', 'reboot_state': 'never_started', 'state': 'SRV_STATE_WAIT_SPAWN_CONDITION', 'state_start_date': 'Wed ' 'Mar 18 ' '10:14:35 ' '2020', 'uuid': '0x4D000119' } } }, '__inst_014__ospf': { 'tag': { 'N/A': { 'internal_id': 139, 'plugin_id': '1', 'process_name': 'ospf', 'reboot_state': 'never_started', 'state': 'SRV_STATE_WAIT_SPAWN_CONDITION', 'state_start_date': 'Wed ' 'Mar 18 ' '10:14:35 ' '2020', 'uuid': '0x4E000119' } } }, '__inst_015__ospf': { 'tag': { 'N/A': { 'internal_id': 143, 'plugin_id': '1', 'process_name': 'ospf', 'reboot_state': 'never_started', 'state': 'SRV_STATE_WAIT_SPAWN_CONDITION', 'state_start_date': 'Wed ' 'Mar 18 ' '10:14:35 ' '2020', 'uuid': '0x4F000119' } } }, '__inst_016__ospf': { 'tag': { 'N/A': { 'internal_id': 147, 'plugin_id': '1', 'process_name': 'ospf', 'reboot_state': 'never_started', 'state': 'SRV_STATE_WAIT_SPAWN_CONDITION', 'state_start_date': 'Wed ' 'Mar 18 ' '10:14:35 ' '2020', 'uuid': '0x50000119' } } } } } golden_output2 = { 'execute.return_value': ''' show system internal sysmgr service name ospf Service "__inst_001__ospf" ("ospf", 83): UUID = 0x41000119, PID = 23994, SAP = 320 State: SRV_STATE_HANDSHAKED (entered at time Wed Mar 18 10:14:35 2020). Restart count: 1 Time of last restart: Wed Mar 18 10:14:35 2020. The service never crashed since the last reboot. Tag = ENT Plugin ID: 1 Service "__inst_002__ospf" ("ospf", 88): UUID = 0x42000119, PID = 23993, SAP = 321 State: SRV_STATE_HANDSHAKED (entered at time Wed Mar 18 10:14:35 2020). Restart count: 1 Time of last restart: Wed Mar 18 10:14:35 2020. The service never crashed since the last reboot. Tag = IPN Plugin ID: 1 Service "__inst_003__ospf" ("ospf", 93): UUID = 0x43000119, PID = 23992, SAP = 322 State: SRV_STATE_HANDSHAKED (entered at time Wed Mar 18 10:14:35 2020). Restart count: 1 Time of last restart: Wed Mar 18 10:14:35 2020. The service never crashed since the last reboot. Tag = l3vpn Plugin ID: 1 Service "__inst_004__ospf" ("ospf", 98): UUID = 0x44000119, -- Currently not running -- State: SRV_STATE_WAIT_SPAWN_CONDITION (entered at time Wed Mar 18 10:14:35 2020). The service has never been started since the last reboot. Tag = N/A Plugin ID: 1 Service "__inst_005__ospf" ("ospf", 103): UUID = 0x45000119, -- Currently not running -- State: SRV_STATE_WAIT_SPAWN_CONDITION (entered at time Wed Mar 18 10:14:35 2020). The service has never been started since the last reboot. Tag = N/A Plugin ID: 1 Service "__inst_006__ospf" ("ospf", 107): UUID = 0x46000119, -- Currently not running -- State: SRV_STATE_WAIT_SPAWN_CONDITION (entered at time Wed Mar 18 10:14:35 2020). The service has never been started since the last reboot. Tag = N/A Plugin ID: 1 Service "__inst_007__ospf" ("ospf", 111): UUID = 0x47000119, -- Currently not running -- State: SRV_STATE_WAIT_SPAWN_CONDITION (entered at time Wed Mar 18 10:14:35 2020). The service has never been started since the last reboot. Tag = N/A Plugin ID: 1 Service "__inst_008__ospf" ("ospf", 115): UUID = 0x48000119, -- Currently not running -- State: SRV_STATE_WAIT_SPAWN_CONDITION (entered at time Wed Mar 18 10:14:35 2020). The service has never been started since the last reboot. Tag = N/A Plugin ID: 1 Service "__inst_009__ospf" ("ospf", 119): UUID = 0x49000119, -- Currently not running -- State: SRV_STATE_WAIT_SPAWN_CONDITION (entered at time Wed Mar 18 10:14:35 2020). The service has never been started since the last reboot. Tag = N/A Plugin ID: 1 Service "__inst_010__ospf" ("ospf", 123): UUID = 0x4A000119, -- Currently not running -- State: SRV_STATE_WAIT_SPAWN_CONDITION (entered at time Wed Mar 18 10:14:35 2020). The service has never been started since the last reboot. Tag = N/A Plugin ID: 1 Service "__inst_011__ospf" ("ospf", 127): UUID = 0x4B000119, -- Currently not running -- State: SRV_STATE_WAIT_SPAWN_CONDITION (entered at time Wed Mar 18 10:14:35 2020). The service has never been started since the last reboot. Tag = N/A Plugin ID: 1 Service "__inst_012__ospf" ("ospf", 131): UUID = 0x4C000119, -- Currently not running -- State: SRV_STATE_WAIT_SPAWN_CONDITION (entered at time Wed Mar 18 10:14:35 2020). The service has never been started since the last reboot. Tag = N/A Plugin ID: 1 Service "__inst_013__ospf" ("ospf", 135): UUID = 0x4D000119, -- Currently not running -- State: SRV_STATE_WAIT_SPAWN_CONDITION (entered at time Wed Mar 18 10:14:35 2020). The service has never been started since the last reboot. Tag = N/A Plugin ID: 1 Service "__inst_014__ospf" ("ospf", 139): UUID = 0x4E000119, -- Currently not running -- State: SRV_STATE_WAIT_SPAWN_CONDITION (entered at time Wed Mar 18 10:14:35 2020). The service has never been started since the last reboot. Tag = N/A Plugin ID: 1 Service "__inst_015__ospf" ("ospf", 143): UUID = 0x4F000119, -- Currently not running -- State: SRV_STATE_WAIT_SPAWN_CONDITION (entered at time Wed Mar 18 10:14:35 2020). The service has never been started since the last reboot. Tag = N/A Plugin ID: 1 Service "__inst_016__ospf" ("ospf", 147): UUID = 0x50000119, -- Currently not running -- State: SRV_STATE_WAIT_SPAWN_CONDITION (entered at time Wed Mar 18 10:14:35 2020). The service has never been started since the last reboot. Tag = N/A Plugin ID: 1 ''' } def test_show_system_internal_sysmgr_service_name_golden(self): self.device = Mock(**self.golden_output) obj = ShowSystemInternalSysmgrServiceName(device=self.device) parsed_output = obj.parse(process='ospf') self.assertEqual(parsed_output, self.golden_parsed_output) def test_golden2(self): self.device = Mock(**self.golden_output2) obj = ShowSystemInternalSysmgrServiceName(device=self.device) parsed_output = obj.parse(process='ospf') self.assertEqual(parsed_output, self.golden_parsed_output2) def test_show_system_internal_sysmgr_service_name_empty(self): self.device = Mock(**self.empty_output) obj = ShowSystemInternalSysmgrServiceName(device=self.device) with self.assertRaises(SchemaEmptyParserError): parsed_output = obj.parse(process='ospf')
class test_show_system_internal_l2fwder(unittest.TestCase): device = Device(name='aDevice') empty_output = {'execute.return_value': ''} golden_parsed_output = { 'vlans': { '1': { 'mac_addresses': { '5e01.80ff.0007': { 'entry': 'G', 'mac_aging_time': '-', 'mac_type': 'static', 'ntfy': 'F', 'ports': 'sup-eth1(R)', 'secure': 'F' } } }, '100': { 'mac_addresses': { '5e01.80ff.0007': { 'entry': 'G', 'mac_aging_time': '-', 'mac_type': 'static', 'ntfy': 'F', 'ports': 'sup-eth1(R)', 'secure': 'F' }, 'fa16.3eff.2a0c': { 'entry': '*', 'mac_aging_time': '-', 'mac_type': 'static', 'ntfy': 'F', 'ports': '(0x47000001) ' 'nve-peer1 ' '93.1.1.', 'secure': 'F' }, 'fa16.3eff.6b31': { 'entry': '*', 'mac_aging_time': '00:01:43', 'mac_type': 'dynamic', 'ntfy': 'F', 'ports': 'Eth1/4', 'secure': 'F' } } }, '1000': { 'mac_addresses': { '5e01.80ff.0007': { 'entry': 'G', 'mac_aging_time': '-', 'mac_type': 'static', 'ntfy': 'F', 'ports': 'sup-eth1(R)', 'secure': 'F' } } }, '1005': { 'mac_addresses': { '5e01.80ff.0007': { 'entry': 'G', 'mac_aging_time': '-', 'mac_type': 'static', 'ntfy': 'F', 'ports': 'sup-eth1(R)', 'secure': 'F' } } }, '1006': { 'mac_addresses': { '5e01.80ff.0007': { 'entry': 'G', 'mac_aging_time': '-', 'mac_type': 'static', 'ntfy': 'F', 'ports': 'sup-eth1(R)', 'secure': 'F' } } }, '1007': { 'mac_addresses': { '5e01.80ff.0007': { 'entry': 'G', 'mac_aging_time': '-', 'mac_type': 'static', 'ntfy': 'F', 'ports': 'sup-eth1(R)', 'secure': 'F' } } }, '1008': { 'mac_addresses': { '5e01.80ff.0007': { 'entry': 'G', 'mac_aging_time': '-', 'mac_type': 'static', 'ntfy': 'F', 'ports': 'sup-eth1(R)', 'secure': 'F' } } }, '1009': { 'mac_addresses': { '5e01.80ff.0007': { 'entry': 'G', 'mac_aging_time': '-', 'mac_type': 'static', 'ntfy': 'F', 'ports': 'sup-eth1(R)', 'secure': 'F' } } }, '101': { 'mac_addresses': { '5e01.80ff.0007': { 'entry': 'G', 'mac_aging_time': '-', 'mac_type': 'static', 'ntfy': 'F', 'ports': 'sup-eth1(R)', 'secure': 'F' } } }, '102': { 'mac_addresses': { '5e01.80ff.0007': { 'entry': 'G', 'mac_aging_time': '-', 'mac_type': 'static', 'ntfy': 'F', 'ports': 'sup-eth1(R)', 'secure': 'F' } } }, '103': { 'mac_addresses': { '5e01.80ff.0007': { 'entry': 'G', 'mac_aging_time': '-', 'mac_type': 'static', 'ntfy': 'F', 'ports': 'sup-eth1(R)', 'secure': 'F' } } }, '105': { 'mac_addresses': { '5e01.80ff.0007': { 'entry': 'G', 'mac_aging_time': '-', 'mac_type': 'static', 'ntfy': 'F', 'ports': 'sup-eth1(R)', 'secure': 'F' } } }, '106': { 'mac_addresses': { '5e01.80ff.0007': { 'entry': 'G', 'mac_aging_time': '-', 'mac_type': 'static', 'ntfy': 'F', 'ports': 'sup-eth1(R)', 'secure': 'F' } } }, '107': { 'mac_addresses': { '5e01.80ff.0007': { 'entry': 'G', 'mac_aging_time': '-', 'mac_type': 'static', 'ntfy': 'F', 'ports': 'sup-eth1(R)', 'secure': 'F' } } }, '108': { 'mac_addresses': { '5e01.80ff.0007': { 'entry': 'G', 'mac_aging_time': '-', 'mac_type': 'static', 'ntfy': 'F', 'ports': 'sup-eth1(R)', 'secure': 'F' } } }, '109': { 'mac_addresses': { '5e01.80ff.0007': { 'entry': 'G', 'mac_aging_time': '-', 'mac_type': 'static', 'ntfy': 'F', 'ports': 'sup-eth1(R)', 'secure': 'F' } } }, '110': { 'mac_addresses': { '5e01.80ff.0007': { 'entry': 'G', 'mac_aging_time': '-', 'mac_type': 'static', 'ntfy': 'F', 'ports': 'sup-eth1(R)', 'secure': 'F' } } }, '111': { 'mac_addresses': { '5e01.80ff.0007': { 'entry': 'G', 'mac_aging_time': '-', 'mac_type': 'static', 'ntfy': 'F', 'ports': 'sup-eth1(R)', 'secure': 'F' } } }, '112': { 'mac_addresses': { '5e01.80ff.0007': { 'entry': 'G', 'mac_aging_time': '-', 'mac_type': 'static', 'ntfy': 'F', 'ports': 'sup-eth1(R)', 'secure': 'F' } } }, '113': { 'mac_addresses': { '5e01.80ff.0007': { 'entry': 'G', 'mac_aging_time': '-', 'mac_type': 'static', 'ntfy': 'F', 'ports': 'sup-eth1(R)', 'secure': 'F' } } }, '114': { 'mac_addresses': { '5e01.80ff.0007': { 'entry': 'G', 'mac_aging_time': '-', 'mac_type': 'static', 'ntfy': 'F', 'ports': 'sup-eth1(R)', 'secure': 'F' } } } } } golden_output = { 'execute.return_value': ''' N95_1# show system internal l2fwder Mac Legend: * - primary entry, G - Gateway MAC, (R) - Routed MAC, O - Overlay MAC age - seconds since last seen,+ - primary entry using vPC Peer-Link, (T) - True, (F) - False, C - ControlPlane MAC VLAN MAC Address Type age Secure NTFY Ports ---------+-----------------+--------+---------+------+----+------------------ G 1008 5e01.80ff.0007 static - F F sup-eth1(R) G 1009 5e01.80ff.0007 static - F F sup-eth1(R) G 1006 5e01.80ff.0007 static - F F sup-eth1(R) G 1007 5e01.80ff.0007 static - F F sup-eth1(R) G 1005 5e01.80ff.0007 static - F F sup-eth1(R) G 1000 5e01.80ff.0007 static - F F sup-eth1(R) G 114 5e01.80ff.0007 static - F F sup-eth1(R) G 112 5e01.80ff.0007 static - F F sup-eth1(R) G 113 5e01.80ff.0007 static - F F sup-eth1(R) G 110 5e01.80ff.0007 static - F F sup-eth1(R) G 111 5e01.80ff.0007 static - F F sup-eth1(R) G 108 5e01.80ff.0007 static - F F sup-eth1(R) G 109 5e01.80ff.0007 static - F F sup-eth1(R) G 106 5e01.80ff.0007 static - F F sup-eth1(R) G 107 5e01.80ff.0007 static - F F sup-eth1(R) * 100 fa16.3eff.2a0c static - F F (0x47000001) nve-peer1 93.1.1. G 105 5e01.80ff.0007 static - F F sup-eth1(R) G 102 5e01.80ff.0007 static - F F sup-eth1(R) G 103 5e01.80ff.0007 static - F F sup-eth1(R) G 100 5e01.80ff.0007 static - F F sup-eth1(R) G 101 5e01.80ff.0007 static - F F sup-eth1(R) G 1 5e01.80ff.0007 static - F F sup-eth1(R) * 100 fa16.3eff.6b31 dynamic 00:01:43 F F Eth1/4 1 1 -00:00:de:ff:6c:9d - 1 ''' } def test_show_system_internal_l2fwder_golden(self): self.device = Mock(**self.golden_output) obj = ShowSystemInternalL2fwderMac(device=self.device) parsed_output = obj.parse() self.assertEqual(parsed_output, self.golden_parsed_output) def test_show_system_internal_l2fwder_empty(self): self.device = Mock(**self.empty_output) obj = ShowSystemInternalL2fwderMac(device=self.device) with self.assertRaises(SchemaEmptyParserError): parsed_output = obj.parse()
class test_show_interface_ip_brief(unittest.TestCase): device = Device(name='aDevice') empty_output = {'execute.return_value': ''} golden_parsed_output = { 'interfaces': { 'Control0/0': { 'ipv4': { '10.10.1.1': { 'ip': '10.10.1.1' }, }, 'check': 'YES', 'method': 'CONFIG', 'link_status': 'up', 'line_protocol': 'up' }, 'GigabitEthernet0/0': { 'ipv4': { '10.10.1.1': { 'ip': '10.10.1.1' }, }, 'check': 'YES', 'method': 'CONFIG', 'link_status': 'up', 'line_protocol': 'up' }, 'GigabitEthernet0/1': { 'ipv4': { 'unnumbered': { 'unnumbered_intf_ref': 'unassigned' }, }, 'check': 'YES', 'method': 'unset admin', 'link_status': 'down', 'line_protocol': 'down' }, 'GigabitEthernet0/2': { 'ipv4': { '10.10.1.1': { 'ip': '10.10.1.1' }, }, 'check': 'YES', 'method': 'manual admin', 'link_status': 'down', 'line_protocol': 'down' }, 'GigabitEthernet0/3': { 'ipv4': { '10.10.1.1': { 'ip': '10.10.1.1' }, }, 'check': 'YES', 'method': 'DHCP admin', 'link_status': 'down', 'line_protocol': 'down' }, 'Management0/0': { 'ipv4': { '10.10.1.1': { 'ip': '10.10.1.1' }, }, 'check': 'YES', 'method': 'CONFIG', 'link_status': 'up' }, 'Vlan150': { 'ipv4': { '10.10.1.1': { 'ip': '10.10.1.1' }, }, 'check': 'YES', 'method': 'CONFIG', 'link_status': 'up', 'line_protocol': 'up' }, 'Vlan160': { 'ipv4': { '10.10.1.1': { 'ip': '10.10.1.1' }, }, 'check': 'YES', 'method': 'CONFIG', 'link_status': 'down', 'line_protocol': 'down' }, 'Vlan170': { 'ipv4': { 'unnumbered': { 'unnumbered_intf_ref': 'unassigned' }, }, 'check': 'YES', 'method': 'unset', 'link_status': 'up', 'line_protocol': 'up' } } } golden_output = { 'execute.return_value': ''' Interface IP-Address OK? Method Status Protocol Control0/0 10.10.1.1 YES CONFIG up up GigabitEthernet0/0 10.10.1.1 YES CONFIG up up GigabitEthernet0/1 unassigned YES unset admin down down GigabitEthernet0/2 10.10.1.1 YES manual admin down down GigabitEthernet0/3 10.10.1.1 YES DHCP admin down down Management0/0 10.10.1.1 YES CONFIG up Vlan150 10.10.1.1 YES CONFIG up up Vlan160 10.10.1.1 YES CONFIG down down Vlan170 unassigned YES unset up up ''' } def test_empty(self): self.device1 = Mock(**self.empty_output) interface_obj = ShowInterfaceIpBrief(device=self.device1) with self.assertRaises(SchemaEmptyParserError): parsed_output = interface_obj.parse() def test_golden(self): self.device = Mock(**self.golden_output) interface_obj = ShowInterfaceIpBrief(device=self.device) parsed_output = interface_obj.parse() self.maxDiff = None self.assertEqual(parsed_output, self.golden_parsed_output)
class test_show_interface_detail(unittest.TestCase): device = Device(name='aDevice') empty_output = {'execute.return_value': ''} golden_parsed_output = { 'interfaces': { 'Vlan5000': { 'interface_state': True, 'config_status': True, 'name': 'pod248', 'link_status': True, 'line_protocol': True, 'mac_address': 'aa11.bbff.ee55', 'mtu': 1500, 'ipv4': { '10.10.1.1': { 'ip': '10.10.1.1' }, }, 'subnet': '255.255.255.0', 'traffic_statistics': { 'packets_input': 34354322, 'bytes_input': 32443242111, 'packets_output': 92739172, 'bytes_output': 4309803982, 'packets_dropped': 2551519 }, 'control_point_states': { 'interface': { 'interface_number': 899, 'interface_config_status': 'active', 'interface_state': 'active' }, 'Vlan5000': { 'interface_vlan_config_status': 'active', 'interface_vlan_state': 'UP' }, } } } } golden_output = { 'execute.return_value': ''' DevNet-asa-sm-1/admin# show interface detail Interface Vlan5000 "pod248", is up, line protocol is up MAC address aa11.bbff.ee55, MTU 1500 IP address 10.10.1.1, subnet mask 255.255.255.0 Traffic Statistics for "pod248": 34354322 packets input, 32443242111 bytes 92739172 packets output, 4309803982 bytes 2551519 packets dropped Control Point Interface States: Interface number is 899 Interface config status is active Interface state is active Control Point Vlan5000 States: Interface vlan config status is active Interface vlan state is UP ''' } golden_parsed_output_2 = { 'interfaces': { 'Vlan6000': { 'interface_state': False, 'config_status': True, 'name': 'pod555', 'link_status': False, 'line_protocol': False, 'mac_address': 'aa11.bbff.ee55', 'mtu': 1500, 'ipv4': { '10.10.1.1': { 'ip': '10.10.1.1' }, }, 'subnet': '255.255.255.0', 'traffic_statistics': { 'packets_input': 0, 'bytes_input': 0, 'packets_output': 0, 'bytes_output': 0, 'packets_dropped': 0 }, 'control_point_states': { 'interface': { 'interface_number': 612, 'interface_config_status': 'active', 'interface_state': 'not active' }, 'Vlan6000': { 'interface_vlan_config_status': 'not active', 'interface_vlan_state': 'DOWN' }, } } } } golden_output_2 = { 'execute.return_value': ''' DevNet-asa-sm-1/admin# show interface detail Interface Vlan6000 "pod555", is down, line protocol is down MAC address aa11.bbff.ee55, MTU 1500 IP address 10.10.1.1, subnet mask 255.255.255.0 Traffic Statistics for "pod555": 0 packets input, 0 bytes 0 packets output, 0 bytes 0 packets dropped Control Point Interface States: Interface number is 612 Interface config status is active Interface state is not active Control Point Vlan1600 States: Interface vlan config status is not active Interface vlan state is DOWN (down in system space) ''' } golden_parsed_output_3 = { 'interfaces': { 'Vlan300': { 'interface_state': True, 'config_status': True, 'name': 'admin-out', 'link_status': True, 'line_protocol': True, 'mac_address': 'aa11.bbff.ee55', 'mtu': 1500, 'ipv4': { '10.10.1.1': { 'ip': '10.10.1.1' }, }, 'subnet': '255.255.255.0', 'traffic_statistics': { 'packets_input': 889007666, 'bytes_input': 785740327549, 'packets_output': 621453837, 'bytes_output': 428046938178, 'packets_dropped': 2988535 }, 'control_point_states': { 'interface': { 'interface_number': 5, 'interface_config_status': 'active', 'interface_state': 'active' }, 'Vlan300': { 'interface_vlan_config_status': 'active', 'interface_vlan_state': 'UP' }, } }, 'Vlan400': { 'interface_state': True, 'config_status': True, 'name': 'pod10-in', 'link_status': True, 'line_protocol': True, 'mac_address': 'aa11.bbff.ee55', 'mtu': 1500, 'ipv4': { '10.10.1.1': { 'ip': '10.10.1.1' }, }, 'subnet': '255.255.255.0', 'traffic_statistics': { 'packets_input': 1286035, 'bytes_input': 100030768, 'packets_output': 1, 'bytes_output': 28, 'packets_dropped': 1285569 }, 'control_point_states': { 'interface': { 'interface_number': 105, 'interface_config_status': 'active', 'interface_state': 'active' }, 'Vlan400': { 'interface_vlan_config_status': 'active', 'interface_vlan_state': 'UP' }, } }, 'Vlan500': { 'interface_state': True, 'config_status': False, 'name': '', 'link_status': True, 'line_protocol': True, 'config_issue': 'nameif' }, 'Vlan600': { 'interface_state': True, 'config_status': True, 'name': 'adminTEST', 'link_status': True, 'line_protocol': True, 'mac_address': 'aa11.bbff.ee55', 'mtu': 1500, 'ipv4': { '10.10.1.1': { 'ip': '10.10.1.1' }, }, 'subnet': '255.255.255.0', 'traffic_statistics': { 'packets_input': 1212307, 'bytes_input': 96880666, 'packets_output': 1, 'bytes_output': 28, 'packets_dropped': 1212268 }, 'control_point_states': { 'interface': { 'interface_number': 507, 'interface_config_status': 'active', 'interface_state': 'active' }, 'Vlan600': { 'interface_vlan_config_status': 'active', 'interface_vlan_state': 'UP' }, } }, 'Vlan700': { 'interface_state': True, 'config_status': True, 'name': 'pod1', 'link_status': True, 'line_protocol': True, 'mac_address': 'aa11.bbff.ee55', 'mtu': 1500, 'ipv4': { '10.10.1.1': { 'ip': '10.10.1.1' }, }, 'subnet': '255.255.255.0', 'traffic_statistics': { 'packets_input': 7299914, 'bytes_input': 6411442725, 'packets_output': 2862092, 'bytes_output': 118819269, 'packets_dropped': 1288374 }, 'control_point_states': { 'interface': { 'interface_number': 508, 'interface_config_status': 'active', 'interface_state': 'active' }, 'Vlan700': { 'interface_vlan_config_status': 'active', 'interface_vlan_state': 'UP' }, } }, 'Vlan1600': { 'interface_state': False, 'config_status': True, 'name': 'pod249', 'link_status': False, 'line_protocol': False, 'mac_address': 'aa11.bbff.ee55', 'mtu': 1500, 'ipv4': { '10.10.1.1': { 'ip': '10.10.1.1' }, }, 'subnet': '255.255.255.0', 'traffic_statistics': { 'packets_input': 0, 'bytes_input': 0, 'packets_output': 0, 'bytes_output': 0, 'packets_dropped': 0 }, 'control_point_states': { 'interface': { 'interface_number': 757, 'interface_config_status': 'active', 'interface_state': 'not active' }, 'Vlan1600': { 'interface_vlan_config_status': 'not active', 'interface_vlan_state': 'DOWN' }, } } } } golden_output_3 = { 'execute.return_value': ''' ciscoasa/admin# show interface detail Interface Vlan300 "admin-out", is up, line protocol is up MAC address aa11.bbff.ee55, MTU 1500 IP address 10.10.1.1, subnet mask 255.255.255.0 Traffic Statistics for "admin-out": 889007666 packets input, 785740327549 bytes 621453837 packets output, 428046938178 bytes 2988535 packets dropped Control Point Interface States: Interface number is 5 Interface config status is active Interface state is active Control Point Vlan300 States: Interface vlan config status is active Interface vlan state is UP Interface Vlan400 "pod10-in", is up, line protocol is up MAC address aa11.bbff.ee55, MTU 1500 IP address 10.10.1.1, subnet mask 255.255.255.0 Traffic Statistics for "pod10-in": 1286035 packets input, 100030768 bytes 1 packets output, 28 bytes 1285569 packets dropped Control Point Interface States: Interface number is 105 Interface config status is active Interface state is active Control Point Vlan400 States: Interface vlan config status is active Interface vlan state is UP Interface Vlan500 "", is up, line protocol is up Available but not configured via nameif Interface Vlan600 "adminTEST", is up, line protocol is up MAC address aa11.bbff.ee55, MTU 1500 IP address 10.10.1.1, subnet mask 255.255.255.0 Traffic Statistics for "adminTEST": 1212307 packets input, 96880666 bytes 1 packets output, 28 bytes 1212268 packets dropped Control Point Interface States: Interface number is 507 Interface config status is active Interface state is active Control Point Vlan600 States: Interface vlan config status is active Interface vlan state is UP Interface Vlan700 "pod1", is up, line protocol is up MAC address aa11.bbff.ee55, MTU 1500 IP address 10.10.1.1, subnet mask 255.255.255.0 Traffic Statistics for "pod1": 7299914 packets input, 6411442725 bytes 2862092 packets output, 118819269 bytes 1288374 packets dropped Control Point Interface States: Interface number is 508 Interface config status is active Interface state is active Control Point Vlan700 States: Interface vlan config status is active Interface vlan state is UP Interface Vlan1600 "pod249", is down, line protocol is down MAC address aa11.bbff.ee55, MTU 1500 IP address 10.10.1.1, subnet mask 255.255.255.0 Traffic Statistics for "pod249": 0 packets input, 0 bytes 0 packets output, 0 bytes 0 packets dropped Control Point Interface States: Interface number is 757 Interface config status is active Interface state is not active Control Point Vlan1600 States: Interface vlan config status is not active Interface vlan state is DOWN (down in system space) ''' } def test_empty(self): self.device1 = Mock(**self.empty_output) interface_obj = ShowInterfaceDetail(device=self.device1) with self.assertRaises(SchemaEmptyParserError): parsed_output = interface_obj.parse() def test_golden(self): self.device = Mock(**self.golden_output) interface_obj = ShowInterfaceDetail(device=self.device) parsed_output = interface_obj.parse() self.maxDiff = None self.assertEqual(parsed_output, self.golden_parsed_output) def test_golden_2(self): self.device = Mock(**self.golden_output_2) interface_obj = ShowInterfaceDetail(device=self.device) parsed_output = interface_obj.parse() self.maxDiff = None self.assertEqual(parsed_output, self.golden_parsed_output_2) def test_golden_3(self): self.device = Mock(**self.golden_output_3) interface_obj = ShowInterfaceDetail(device=self.device) parsed_output = interface_obj.parse() self.maxDiff = None self.assertEqual(parsed_output, self.golden_parsed_output_3)
class test_show_interface_summary(unittest.TestCase): device = Device(name='aDevice') empty_output = {'execute.return_value': ''} golden_parsed_output = { 'interfaces': { 'Vlan100': { 'interface_state': True, 'config_status': True, 'name': 'pod10', 'link_status': True, 'line_protocol': True, 'mac_address': 'aa11.bbff.ee55', 'mtu': 1500, 'ipv4': { '10.10.1.1': { 'ip': '10.10.1.1' }, }, 'subnet': '255.255.255.0' } } } golden_output = { 'execute.return_value': ''' ciscoasa/admin# show interface summary Interface Vlan100 "pod10", is up, line protocol is up MAC address aa11.bbff.ee55, MTU 1500 IP address 10.10.1.1, subnet mask 255.255.255.0 ''' } golden_parsed_output_2 = { 'interfaces': { 'Vlan300': { 'interface_state': True, 'config_status': True, 'name': 'admin-out', 'link_status': True, 'line_protocol': True, 'mac_address': 'aa11.bbff.ee55', 'mtu': 1500, 'ipv4': { '10.10.1.1': { 'ip': '10.10.1.1' }, }, 'subnet': '255.255.255.0' }, 'Vlan400': { 'interface_state': True, 'config_status': True, 'name': 'pod10-in', 'link_status': True, 'line_protocol': True, 'mac_address': 'aa11.bbff.ee55', 'mtu': 1500, 'ipv4': { '10.10.1.1': { 'ip': '10.10.1.1' }, }, 'subnet': '255.255.255.0' }, 'Vlan500': { 'interface_state': True, 'config_status': False, 'config_issue': 'nameif', 'name': '', 'link_status': True, 'line_protocol': True, }, 'Vlan600': { 'interface_state': True, 'config_status': True, 'name': 'adminTEST', 'link_status': True, 'line_protocol': True, 'mac_address': 'aa11.bbff.ee55', 'mtu': 1500, 'ipv4': { '10.10.1.1': { 'ip': '10.10.1.1' }, }, 'subnet': '255.255.255.0' }, 'Vlan700': { 'interface_state': True, 'config_status': True, 'name': 'pod1', 'link_status': True, 'line_protocol': True, 'mac_address': 'aa11.bbff.ee55', 'mtu': 1500, 'ipv4': { '10.10.1.1': { 'ip': '10.10.1.1' }, }, 'subnet': '255.255.255.0' }, 'Vlan902': { 'interface_state': True, 'config_status': True, 'name': 'pod2', 'link_status': True, 'line_protocol': True, 'mac_address': 'aa11.bbff.ee55', 'mtu': 1500, 'ipv4': { '10.10.1.1': { 'ip': '10.10.1.1' }, }, 'subnet': '255.255.255.0' }, 'Vlan900': { 'interface_state': True, 'config_status': True, 'name': 'pod3', 'link_status': True, 'line_protocol': True, 'mac_address': 'aa11.bbff.ee55', 'mtu': 1500, 'ipv4': { '10.10.1.1': { 'ip': '10.10.1.1' }, }, 'subnet': '255.255.255.0' }, 'Vlan1000': { 'interface_state': True, 'config_status': True, 'name': 'pod4', 'link_status': True, 'line_protocol': True, 'mac_address': 'aa11.bbff.ee55', 'mtu': 1500, 'ipv4': { '10.10.1.1': { 'ip': '10.10.1.1' }, }, 'subnet': '255.255.255.0' }, 'Vlan1100': { 'interface_state': True, 'config_status': True, 'name': 'pod5', 'link_status': True, 'line_protocol': True, 'mac_address': 'aa11.bbff.ee55', 'mtu': 1500, 'ipv4': { '10.10.1.1': { 'ip': '10.10.1.1' }, }, 'subnet': '255.255.255.0' }, 'Vlan1200': { 'interface_state': True, 'config_status': True, 'name': 'pod6', 'link_status': True, 'line_protocol': True, 'mac_address': 'aa11.bbff.ee55', 'mtu': 1500, 'ipv4': { '10.10.1.1': { 'ip': '10.10.1.1' }, }, 'subnet': '255.255.255.0' }, 'Vlan1300': { 'interface_state': True, 'config_status': True, 'name': 'pod7', 'link_status': True, 'line_protocol': True, 'mac_address': 'aa11.bbff.ee55', 'mtu': 1500, 'ipv4': { '10.10.1.1': { 'ip': '10.10.1.1' }, }, 'subnet': '255.255.255.0' }, 'Vlan1400': { 'interface_state': True, 'config_status': True, 'name': 'pod8', 'link_status': True, 'line_protocol': True, 'mac_address': 'aa11.bbff.ee55', 'mtu': 1500, 'ipv4': { '10.10.1.1': { 'ip': '10.10.1.1' }, }, 'subnet': '255.255.255.0' }, 'Vlan1500': { 'interface_state': True, 'config_status': True, 'name': 'pod9', 'link_status': True, 'line_protocol': True, 'mac_address': 'aa11.bbff.ee55', 'mtu': 1500, 'ipv4': { '10.10.1.1': { 'ip': '10.10.1.1' }, }, 'subnet': '255.255.255.0' }, 'Vlan1600': { 'interface_state': False, 'config_status': True, 'name': 'pod249', 'link_status': False, 'line_protocol': False, 'mac_address': 'aa11.bbff.ee55', 'mtu': 1500, 'ipv4': { '10.10.1.1': { 'ip': '10.10.1.1' }, }, 'subnet': '255.255.255.0' } } } golden_output_2 = { 'execute.return_value': ''' ciscoasa/admin# show interface summary Interface Vlan300 "admin-out", is up, line protocol is up MAC address aa11.bbff.ee55, MTU 1500 IP address 10.10.1.1, subnet mask 255.255.255.0 Interface Vlan400 "pod10-in", is up, line protocol is up MAC address aa11.bbff.ee55, MTU 1500 IP address 10.10.1.1, subnet mask 255.255.255.0 Interface Vlan500 "", is up, line protocol is up Available but not configured via nameif Interface Vlan600 "adminTEST", is up, line protocol is up MAC address aa11.bbff.ee55, MTU 1500 IP address 10.10.1.1, subnet mask 255.255.255.0 Interface Vlan700 "pod1", is up, line protocol is up MAC address aa11.bbff.ee55, MTU 1500 IP address 10.10.1.1, subnet mask 255.255.255.0 Interface Vlan902 "pod2", is up, line protocol is up MAC address aa11.bbff.ee55, MTU 1500 IP address 10.10.1.1, subnet mask 255.255.255.0 Interface Vlan900 "pod3", is up, line protocol is up MAC address aa11.bbff.ee55, MTU 1500 IP address 10.10.1.1, subnet mask 255.255.255.0 Interface Vlan1000 "pod4", is up, line protocol is up MAC address aa11.bbff.ee55, MTU 1500 IP address 10.10.1.1, subnet mask 255.255.255.0 Interface Vlan1100 "pod5", is up, line protocol is up MAC address aa11.bbff.ee55, MTU 1500 IP address 10.10.1.1, subnet mask 255.255.255.0 Interface Vlan1200 "pod6", is up, line protocol is up MAC address aa11.bbff.ee55, MTU 1500 IP address 10.10.1.1, subnet mask 255.255.255.0 Interface Vlan1300 "pod7", is up, line protocol is up MAC address aa11.bbff.ee55, MTU 1500 IP address 10.10.1.1, subnet mask 255.255.255.0 Interface Vlan1400 "pod8", is up, line protocol is up MAC address aa11.bbff.ee55, MTU 1500 IP address 10.10.1.1, subnet mask 255.255.255.0 Interface Vlan1500 "pod9", is up, line protocol is up MAC address aa11.bbff.ee55, MTU 1500 IP address 10.10.1.1, subnet mask 255.255.255.0 Interface Vlan1600 "pod249", is down, line protocol is down MAC address aa11.bbff.ee55, MTU 1500 IP address 10.10.1.1, subnet mask 255.255.255.0 ''' } def test_empty(self): self.device1 = Mock(**self.empty_output) interface_obj = ShowInterfaceSummary(device=self.device1) with self.assertRaises(SchemaEmptyParserError): parsed_output = interface_obj.parse() def test_golden(self): self.device = Mock(**self.golden_output) interface_obj = ShowInterfaceSummary(device=self.device) parsed_output = interface_obj.parse() self.maxDiff = None self.assertEqual(parsed_output, self.golden_parsed_output) def test_golden_2(self): self.device = Mock(**self.golden_output_2) interface_obj = ShowInterfaceSummary(device=self.device) parsed_output = interface_obj.parse() self.maxDiff = None self.assertEqual(parsed_output, self.golden_parsed_output_2)
class test_show_cdp_neighbors_detail(unittest.TestCase): device = Device(name='aDevice') expected_parsed_output_1 = { 'total_entries_displayed': 3, 'index': { 1: { 'advertisement_ver': 2, 'capabilities': 'Router Switch CVTA phone port', 'device_id': 'R6(9P57K4EJ8CA)', 'duplex_mode': 'full', 'entry_addresses': { '172.16.1.203': {} }, 'hold_time': 133, 'local_interface': 'GigabitEthernet0/0', 'management_addresses': { '172.16.1.203': {} }, 'native_vlan': '', 'platform': 'N9K-9000v', 'port_id': 'mgmt0', 'software_version': 'Cisco Nexus Operating System (NX-OS) Software, Version 9.2(1)', 'vtp_management_domain': '' }, 2: { 'advertisement_ver': 2, 'capabilities': 'Router Switch CVTA phone port', 'device_id': 'R7(9QBDKB58F76)', 'duplex_mode': 'full', 'entry_addresses': { '172.16.1.204': {} }, 'hold_time': 126, 'local_interface': 'GigabitEthernet0/0', 'management_addresses': { '172.16.1.204': {} }, 'native_vlan': '', 'platform': 'N9K-9000v', 'port_id': 'mgmt0', 'software_version': 'Cisco Nexus Operating System (NX-OS) Software, Version 9.2(1)', 'vtp_management_domain': '' }, 3: { 'advertisement_ver': 2, 'capabilities': 'Router Source-Route-Bridge', 'device_id': 'R5.cisco.com', 'duplex_mode': '', 'entry_addresses': { '172.16.1.202': {} }, 'hold_time': 177, 'local_interface': 'GigabitEthernet0/0', 'management_addresses': { '172.16.1.202': {} }, 'native_vlan': '', 'platform': 'Cisco ', 'port_id': 'GigabitEthernet0/0', 'software_version': 'Cisco IOS Software, IOSv Software (VIOS-ADVENTERPRISEK9-M), Version 15.7(3)M3, RELEASE SOFTWARE (fc2)\n' 'Technical Support: http://www.cisco.com/techsupport\n' 'Copyright (c) 1986-2018 by Cisco Systems, Inc.\n' 'Compiled Wed 01-Aug-18 16:45 by prod_rel_team', 'vtp_management_domain': '' }, }, } device_output_1 = { 'execute.return_value': ''' Device# show cdp neighbors detail Device ID: R6(9P57K4EJ8CA) Entry address(es): IP address: 172.16.1.203 Platform: N9K-9000v, Capabilities: Router Switch CVTA phone port Interface: GigabitEthernet0/0, Port ID (outgoing port): mgmt0 Holdtime : 133 sec Version : Cisco Nexus Operating System (NX-OS) Software, Version 9.2(1) advertisement version: 2 Duplex: full Management address(es): IP address: 172.16.1.203 ------------------------- Device ID: R7(9QBDKB58F76) Entry address(es): IP address: 172.16.1.204 Platform: N9K-9000v, Capabilities: Router Switch CVTA phone port Interface: GigabitEthernet0/0, Port ID (outgoing port): mgmt0 Holdtime : 126 sec Version : Cisco Nexus Operating System (NX-OS) Software, Version 9.2(1) advertisement version: 2 Duplex: full Management address(es): IP address: 172.16.1.204 ------------------------- Device ID: R5.cisco.com Entry address(es): IP address: 172.16.1.202 Platform: Cisco , Capabilities: Router Source-Route-Bridge Interface: GigabitEthernet0/0, Port ID (outgoing port): GigabitEthernet0/0 Holdtime : 177 sec Version : Cisco IOS Software, IOSv Software (VIOS-ADVENTERPRISEK9-M), Version 15.7(3)M3, RELEASE SOFTWARE (fc2) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2018 by Cisco Systems, Inc. Compiled Wed 01-Aug-18 16:45 by prod_rel_team advertisement version: 2 Management address(es): IP address: 172.16.1.202 Total cdp entries displayed : 3 ''' } expected_parsed_output_2 = { 'total_entries_displayed': 2, 'index': { 1: { 'advertisement_ver': 2, 'capabilities': 'Router Source-Route-Bridge', 'device_id': 'R8.cisco.com', 'duplex_mode': '', 'entry_addresses': { '172.16.1.205': {} }, 'hold_time': 143, 'local_interface': 'GigabitEthernet0/0', 'management_addresses': { '172.16.1.205': {} }, 'native_vlan': '', 'platform': 'Cisco ', 'port_id': 'GigabitEthernet0/0', 'software_version': 'Cisco IOS Software, IOSv Software (VIOS-ADVENTERPRISEK9-M), Version 15.7(3)M3, RELEASE SOFTWARE (fc2)\n' 'Technical Support: http://www.cisco.com/techsupport\n' 'Copyright (c) 1986-2018 by Cisco Systems, Inc.\n' 'Compiled Wed 01-Aug-18 16:45 by prod_rel_team', 'vtp_management_domain': '' }, 2: { 'advertisement_ver': 2, 'capabilities': 'Router Source-Route-Bridge', 'device_id': 'R9.cisco.com', 'duplex_mode': '', 'entry_addresses': { '172.16.1.206': {} }, 'hold_time': 151, 'local_interface': 'GigabitEthernet0/0', 'management_addresses': { '172.16.1.206': {} }, 'native_vlan': '', 'platform': 'Cisco ', 'port_id': 'GigabitEthernet0/0', 'software_version': 'Cisco IOS Software, IOSv Software (VIOS-ADVENTERPRISEK9-M), Version 15.7(3)M3, RELEASE SOFTWARE (fc2)\n' 'Technical Support: http://www.cisco.com/techsupport\n' 'Copyright (c) 1986-2018 by Cisco Systems, Inc.\n' 'Compiled Wed 01-Aug-18 16:45 by prod_rel_team', 'vtp_management_domain': '' }, }, } device_output_2 = { 'execute.return_value': ''' Device# show cdp neighbors detail Device ID: R8.cisco.com Entry address(es): IP address: 172.16.1.205 Platform: Cisco , Capabilities: Router Source-Route-Bridge Interface: GigabitEthernet0/0, Port ID (outgoing port): GigabitEthernet0/0 Holdtime : 143 sec Version : Cisco IOS Software, IOSv Software (VIOS-ADVENTERPRISEK9-M), Version 15.7(3)M3, RELEASE SOFTWARE (fc2) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2018 by Cisco Systems, Inc. Compiled Wed 01-Aug-18 16:45 by prod_rel_team advertisement version: 2 Management address(es): IP address: 172.16.1.205 ------------------------- Device ID: R9.cisco.com Entry address(es): IP address: 172.16.1.206 Platform: Cisco , Capabilities: Router Source-Route-Bridge Interface: GigabitEthernet0/0, Port ID (outgoing port): GigabitEthernet0/0 Holdtime : 151 sec Version : Cisco IOS Software, IOSv Software (VIOS-ADVENTERPRISEK9-M), Version 15.7(3)M3, RELEASE SOFTWARE (fc2) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2018 by Cisco Systems, Inc. Compiled Wed 01-Aug-18 16:45 by prod_rel_team advertisement version: 2 Management address(es): IP address: 172.16.1.206 Total cdp entries displayed : 2 ''' } expected_parsed_output_3 = { 'total_entries_displayed': 1, 'index': { 1: { 'advertisement_ver': 2, 'capabilities': 'Router', 'device_id': 'device.cisco.com', 'duplex_mode': 'half', 'entry_addresses': { '2001:DB8:1000:8A10::C0A8:BC06': { 'type': 'global unicast' }, 'FE80::203:E3FF:FE6A:BF81': { 'type': 'link-local' }, }, 'hold_time': 160, 'local_interface': 'Ethernet0/1', 'management_addresses': {}, 'native_vlan': '42', 'platform': 'cisco 3640', 'port_id': 'Ethernet0/1', 'software_version': 'Cisco Internetwork Operating System Software IOS (tm) 3600 Software (C3640-A2IS-M), Version 12.2(25)SEB4, RELE)', 'vtp_management_domain': 'Accounting Group' }, } } device_output_3 = { 'execute.return_value': ''' Device# show cdp neighbors detail Device ID: device.cisco.com Entry address(es): IPv6 address: FE80::203:E3FF:FE6A:BF81 (link-local) IPv6 address: 2001:DB8:1000:8A10::C0A8:BC06 (global unicast) Platform: cisco 3640, Capabilities: Router Interface: Ethernet0/1, Port ID (outgoing port): Ethernet0/1 Holdtime : 160 sec Version : Cisco Internetwork Operating System Software IOS (tm) 3600 Software (C3640-A2IS-M), Version 12.2(25)SEB4, RELE) advertisement version: 2 Duplex Mode: half Native VLAN: 42 VTP Management Domain: ‘Accounting Group’ ''' } device_output_4_empty = {'execute.return_value': ''} expected_parsed_output_5 = { 'total_entries_displayed': 2, 'index': { 1: { 'advertisement_ver': 2, 'capabilities': 'Router Switch-6506 IGMP', 'device_id': 'R8.cisco.com', 'duplex_mode': '', 'entry_addresses': { '172.16.1.205': {} }, 'hold_time': 143, 'local_interface': 'GigabitEthernet1/0/3', 'management_addresses': { '172.16.1.205': {} }, 'native_vlan': '', 'platform': 'cisco WS_C6506_E', 'port_id': 'GigabitEthernet1/0/3', 'software_version': 'Cisco IOS Software, IOSv Software (VIOS-ADVENTERPRISEK9-M), Version 15.7(3)M3, RELEASE SOFTWARE (fc2)\n' 'Technical Support: http://www.cisco.com/techsupport\n' 'Copyright (c) 1986-2018 by Cisco Systems, Inc.\n' 'Compiled Wed 01-Aug-18 16:45 by prod_rel_team', 'vtp_management_domain': '' }, 2: { 'advertisement_ver': 2, 'capabilities': 'Router Switch_6506 IGMP', 'device_id': 'R9.cisco.com', 'duplex_mode': '', 'entry_addresses': { '172.16.1.206': {} }, 'hold_time': 151, 'local_interface': 'GigabitEthernet1/2/5', 'management_addresses': { '172.16.1.206': {} }, 'native_vlan': '', 'platform': 'cisco WS-C6506-E', 'port_id': 'GigabitEthernet1/2/5', 'software_version': 'Cisco IOS Software, IOSv Software (VIOS-ADVENTERPRISEK9-M), Version 15.7(3)M3, RELEASE SOFTWARE (fc2)\n' 'Technical Support: http://www.cisco.com/techsupport\n' 'Copyright (c) 1986-2018 by Cisco Systems, Inc.\n' 'Compiled Wed 01-Aug-18 16:45 by prod_rel_team', 'vtp_management_domain': '' }, }, } device_output_5 = { 'execute.return_value': ''' Device# show cdp neighbors detail Device ID: R8.cisco.com Entry address(es): IP address: 172.16.1.205 Platform: cisco WS_C6506_E, Capabilities: Router Switch-6506 IGMP Interface: GigabitEthernet1/0/3, Port ID (outgoing port): GigabitEthernet1/0/3 Holdtime : 143 sec Version : Cisco IOS Software, IOSv Software (VIOS-ADVENTERPRISEK9-M), Version 15.7(3)M3, RELEASE SOFTWARE (fc2) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2018 by Cisco Systems, Inc. Compiled Wed 01-Aug-18 16:45 by prod_rel_team advertisement version: 2 Management address(es): IP address: 172.16.1.205 ------------------------- Device ID: R9.cisco.com Entry address(es): IP address: 172.16.1.206 Platform: cisco WS-C6506-E, Capabilities: Router Switch_6506 IGMP Interface: GigabitEthernet1/2/5, Port ID (outgoing port): GigabitEthernet1/2/5 Holdtime : 151 sec Version : Cisco IOS Software, IOSv Software (VIOS-ADVENTERPRISEK9-M), Version 15.7(3)M3, RELEASE SOFTWARE (fc2) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2018 by Cisco Systems, Inc. Compiled Wed 01-Aug-18 16:45 by prod_rel_team advertisement version: 2 Management address(es): IP address: 172.16.1.206 Total cdp entries displayed : 2 ''' } device_output_6 = { 'execute.return_value': ''' Device# show cdp neighbors detail Device ID: e0553d849f1a Entry address(es): IP address: 10.0.0.7 Platform: Meraki MV21 Cloud Managed Indoor HD Dom Interface: GigabitEthernet3/0/29, Port ID (outgoing port): Port 0 Holdtime : 145 sec Version : 1 advertisement version: 2 Power drawn: 0.000 Watts Power request id: 31314, Power management id: 0 Power request levels are:15400 0 0 0 0 ------------------------- Device ID: System1 Entry address(es): IP address: 10.0.0.8 Platform: cisco ISR4351/K9, Capabilities: Router Switch IGMP Interface: GigabitEthernet1/0/47, Port ID (outgoing port): GigabitEthernet0/0/2 Holdtime : 129 sec Version : Cisco IOS Software [Fuji], ISR Software (X86_64_LINUX_IOSD-UNIVERSALK9-M), Version 16.9.4, RELEASE SOFTWARE (fc2) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2019 by Cisco Systems, Inc. Compiled Thu 22-Aug-19 18:09 by mcpre advertisement version: 2 VTP Management Domain: '' Duplex: full Management address(es): IP address: 10.0.0.8 Total cdp entries displayed : 2 ''' } expected_parsed_output_6 = { 'total_entries_displayed': 2, 'index': { 1: { 'device_id': 'e0553d849f1a', 'duplex_mode': '', 'vtp_management_domain': '', 'native_vlan': '', 'management_addresses': {}, 'entry_addresses': { '10.0.0.7': {} }, 'platform': 'Meraki MV21 Cloud Managed Indoor HD Dom', 'port_id': 'Port 0', 'local_interface': 'GigabitEthernet3/0/29', 'hold_time': 145, 'software_version': '1', 'advertisement_ver': 2 }, 2: { 'device_id': 'System1', 'duplex_mode': 'full', 'vtp_management_domain': ' ', 'native_vlan': '', 'management_addresses': { '10.0.0.8': {} }, 'entry_addresses': { '10.0.0.8': {} }, 'capabilities': 'Router Switch IGMP', 'platform': 'cisco ISR4351/K9', 'port_id': 'GigabitEthernet0/0/2', 'local_interface': 'GigabitEthernet1/0/47', 'hold_time': 129, 'software_version': 'Cisco IOS Software [Fuji], ISR Software (X86_64_LINUX_IOSD-UNIVERSALK9-M), Version 16.9.4, RELEASE SOFTWARE (fc2)\n' 'Technical Support: http://www.cisco.com/techsupport\n' 'Copyright (c) 1986-2019 by Cisco Systems, Inc.\n' 'Compiled Thu 22-Aug-19 18:09 by mcpre', 'advertisement_ver': 2 }, }, } def test_show_cdp_neighbors_detail_1(self): self.maxDiff = None self.device = Mock(**self.device_output_1) obj = ShowCdpNeighborsDetail(device=self.device) parsed_output = obj.parse() self.assertEqual(parsed_output, self.expected_parsed_output_1) def test_show_cdp_neighbors_detail_2(self): self.maxDiff = None self.device = Mock(**self.device_output_2) obj = ShowCdpNeighborsDetail(device=self.device) parsed_output = obj.parse() self.assertEqual(parsed_output, self.expected_parsed_output_2) def test_show_cdp_neighbors_detail_3(self): self.maxDiff = None self.device = Mock(**self.device_output_3) obj = ShowCdpNeighborsDetail(device=self.device) parsed_output = obj.parse() self.assertEqual(parsed_output, self.expected_parsed_output_3) def test_show_cdp_neighbors_detail_empty(self): self.maxDiff = None self.device = Mock(**self.device_output_4_empty) obj = ShowCdpNeighborsDetail(device=self.device) with self.assertRaises(SchemaEmptyParserError): parsed_output = obj.parse() def test_show_cdp_neighbors_detail_4(self): self.maxDiff = None self.device = Mock(**self.device_output_5) obj = ShowCdpNeighborsDetail(device=self.device) parsed_output = obj.parse() self.assertEqual(parsed_output, self.expected_parsed_output_5) def test_show_cdp_neighbors_detail_missing_capabilities(self): self.maxDiff = None self.device = Mock(**self.device_output_6) obj = ShowCdpNeighborsDetail(device=self.device) parsed_output = obj.parse() self.assertEqual(parsed_output, self.expected_parsed_output_6)
class test_show_cdp_neighbors(unittest.TestCase): device = Device(name='aDevice') empty_device_output = { 'execute.return_value': ''' Device# show cdp neighbors Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge S - Switch, H - Host, I - IGMP, r - Repeater Device ID Local Interfce Holdtme Capability Platform '' Port ID ''' } expected_parsed_output_1 = { 'cdp': { 'index': { 1: { 'capability': 'R B', 'device_id': 'R5.cisco.com', 'hold_time': 125, 'local_interface': 'GigabitEthernet0/0', 'platform': '', 'port_id': 'GigabitEthernet0/0' }, 2: { 'capability': 'T S', 'device_id': 'RX-SWV.cisco.com', 'hold_time': 167, 'local_interface': 'FastEthernet0/1', 'platform': 'WS-C3524-X', 'port_id': 'FastEthernet0/13' }, 3: { 'capability': 'S I', 'device_id': 'C2950-1', 'hold_time': 148, 'local_interface': 'FastEthernet0/0', 'platform': 'WS-C2950T-', 'port_id': 'FastEthernet0/15' } } } } device_output_1 = { 'execute.return_value': ''' Device# show cdp neighbors Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge S - Switch, H - Host, I - IGMP, r - Repeater Device ID Local Interfce Holdtme Capability Platform '' Port ID R5.cisco.com Gig 0/0 125 R B Gig 0/0 RX-SWV.cisco.com Fas 0/1 167 T S WS-C3524-XFas 0/13 C2950-1 Fas 0/0 148 S I WS-C2950T-Fas 0/15 ''' } expected_parsed_output_2 = { 'cdp': { 'index': { 1: { 'capability': 'R', 'device_id': 'device2', 'hold_time': 152, 'local_interface': 'Ethernet0', 'platform': 'AS5200', 'port_id': 'Ethernet0' }, 2: { 'capability': 'R', 'device_id': 'device3', 'hold_time': 144, 'local_interface': 'Ethernet0', 'platform': '3640', 'port_id': 'Ethernet0/0' }, 3: { 'capability': '', 'device_id': 'device4', 'hold_time': 141, 'local_interface': 'Ethernet0', 'platform': 'RP1', 'port_id': 'Ethernet0/0' } } } } device_output_2 = { 'execute.return_value': ''' Device# show cdp neighbors Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge S - Switch, H - Host, I - IGMP, r - Repeater Device ID Local Interfce Holdtme Capability Platform '' Port ID device2 Eth 0 152 R AS5200 Eth 0 device3 Eth 0 144 R 3640 Eth0/0 device4 Eth 0 141 RP1 Eth 0/0 ''' } expected_parsed_output_3 = { 'cdp': { 'index': { 1: { 'capability': 'R B', 'device_id': 'R8.cisco.com', 'hold_time': 148, 'local_interface': 'GigabitEthernet0/0', 'platform': '', 'port_id': 'GigabitEthernet0/0' }, 2: { 'capability': 'R B', 'device_id': 'R9.cisco.com', 'hold_time': 156, 'local_interface': 'GigabitEthernet0/0', 'platform': '', 'port_id': 'GigabitEthernet0/0' }, 3: { 'capability': 'R S I', 'device_id': 'device6', 'hold_time': 157, 'local_interface': 'GigabitEthernet0', 'platform': 'C887VA-W-W', 'port_id': 'GigabitEthernet0' } } } } device_output_3 = { 'execute.return_value': ''' Device# show cdp neighbors Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge S - Switch, H - Host, I - IGMP, r - Repeater Device ID Local Interfce Holdtme Capability Platform '' Port ID R8.cisco.com Gig 0/0 148 R B Gig 0/0 R9.cisco.com Gig 0/0 156 R B Gig 0/0 device6 Gig 0 157 R S I C887VA-W-W Gi 0 ''' } expected_parsed_output_4 = { 'cdp': { 'index': { 1: { 'capability': '', 'device_id': 'device4', 'hold_time': 141, 'local_interface': 'Ethernet0', 'platform': 'RP1', 'port_id': 'Ethernet0/0' }, 2: { 'capability': '', 'device_id': 'device5', 'hold_time': 164, 'local_interface': 'Ethernet0', 'platform': '7206', 'port_id': 'Ethernet1/0' } } } } device_output_4 = { 'execute.return_value': ''' Device# show cdp neighbors Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge S - Switch, H - Host, I - IGMP, r - Repeater Device ID Local Interfce Holdtme Capability Platform '' Port ID device4 Eth 0 141 RP1 Eth 0/0 device5 Eth 0 164 7206 Eth 1/0 ''' } expected_parsed_output_5 = { 'cdp': { 'index': { 1: { 'capability': 'R S C', 'device_id': 'Device_With_A_Particularly_Long_Name', 'hold_time': 134, 'local_interface': 'GigabitEthernet1', 'platform': 'N9K-9000v', 'port_id': 'Ethernet0/0' }, 2: { 'capability': 'S I', 'device_id': 'another_device_with_a_long_name', 'hold_time': 141, 'local_interface': 'TwentyFiveGigE1/0/3', 'platform': 'WS-C3850-', 'port_id': 'TenGigabitEthernet1/1/4' } } } } device_output_5 = { 'execute.return_value': ''' Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge S - Switch, H - Host, I - IGMP, r - Repeater, P - Phone, D - Remote, C - CVTA, M - Two-port Mac Relay Device ID Local Intrfce Holdtme Capability Platform Port ID Device_With_A_Particularly_Long_Name Gig 1 134 R S C N9K-9000v Eth 0/0 another_device_with_a_long_name Twe 1/0/3 141 S I WS-C3850- Ten 1/1/4 ''' } def test_show_cdp_neighbors_1(self): self.maxDiff = None self.device = Mock(**self.device_output_1) obj = ShowCdpNeighbors(device=self.device) parsed_output = obj.parse() self.assertEqual(parsed_output, self.expected_parsed_output_1) def test_show_cdp_neighbors_2(self): self.maxDiff = None self.device = Mock(**self.device_output_2) obj = ShowCdpNeighbors(device=self.device) parsed_output = obj.parse() self.assertEqual(parsed_output, self.expected_parsed_output_2) def test_show_cdp_neighbors_3(self): self.maxDiff = None self.device = Mock(**self.device_output_3) obj = ShowCdpNeighbors(device=self.device) parsed_output = obj.parse() self.assertEqual(parsed_output, self.expected_parsed_output_3) def test_show_cdp_neighbors_4(self): self.maxDiff = None self.device = Mock(**self.device_output_4) obj = ShowCdpNeighbors(device=self.device) parsed_output = obj.parse() self.assertEqual(parsed_output, self.expected_parsed_output_4) def test_show_cdp_neighbors_5(self): self.maxDiff = None self.device = Mock(**self.device_output_5) obj = ShowCdpNeighbors(device=self.device) parsed_output = obj.parse() self.assertEqual(parsed_output, self.expected_parsed_output_5) def test_show_cdp_neighbors_empty_output(self): self.maxDiff = None self.device = Mock(**self.empty_device_output) obj = ShowCdpNeighbors(device=self.device) with self.assertRaises(SchemaEmptyParserError): parsed_output = obj.parse()
class TestShowRunPolicyMap(unittest.TestCase): device = Device(name='aDevice') empty_output = {'execute.return_value': ''} golden_parsed_output = { "policy_map": { "L3VPN-0_in": { "class": { "HEY_in": { "police": { "cir_bps": "365", "pir_bps": "235", "conformed": "transmit", "exceeded": "drop" } }, "OSPF": { "police": { "cir_bps": "543", "pir_bps": "876", "conformed": "transmit", "exceeded": "drop" } }, "class-default": { "police": { "cir_bps": "2565", "cir_bc_bytes": "4234", "conformed": "transmit", "exceeded": "drop" }, "service_policy": "child" } } } } } golden_output = { 'execute.return_value': '''\ show run policy-map L3VPN-0_in Building configuration... Current configuration : 56 bytes ! policy-map L3VPN-0_in class HEY_in police cir 365 pir 235 conform-action transmit exceed-action drop class OSPF police cir 543 pir 876 conform-action transmit exceed-action drop class class-default police cir 2565 bc 4234 conform-action transmit exceed-action drop service-policy child ! end ''' } def test_empty(self): self.device1 = Mock(**self.empty_output) obj = ShowRunPolicyMap(device=self.device1) with self.assertRaises(SchemaEmptyParserError): parsed_output = obj.parse(name='L3VPN-0_in') def test_golden(self): self.device1 = Mock(**self.golden_output) obj = ShowRunPolicyMap(device=self.device1) parsed_output = obj.parse(name='L3VPN-0_in') self.assertEqual(parsed_output, self.golden_parsed_output)
def setUp(self): self.device = Device(name='aDevice') self.device.os = 'iosxr' self.device.mapping = {} self.device.mapping['cli'] = 'cli' self.device.connectionmgr.connections['cli'] = self.device
class TestShowRunInterface(unittest.TestCase): maxDiff = None device = Device(name='aDevice') empty_output = {'execute.return_value': ''} golden_parsed_output = { 'interfaces': { 'GigabitEthernet1/0/13': { 'authentication_control_direction': 'in', 'authentication_event_fail_action': 'next-method', 'authentication_fallback': 'dot1x', 'authentication_host_mode': 'multi-auth', 'authentication_order': 'dot1x mab', 'authentication_periodic': True, 'authentication_port_control': 'auto', 'authentication_priority': 'dot1x mab', 'authentication_timer_inactivity': '65535', 'authentication_timer_reauthenticate_server': True, 'authentication_violation': 'restrict', 'description': 'ISE Controlled Port', 'dot1x_pae_authenticator': True, 'dot1x_timeout_quiet_period': '5', 'dot1x_timeout_server_timeout': '10', 'dot1x_timeout_tx_period': '5', 'ip_arp_inspection_limit_rate': '1024', 'ip_dhcp_snooping_limit_rate': '100', 'load_interval': '30', 'mab': True, 'snmp_trap_link_status': False, 'snmp_trap_mac_notification_change_added': True, 'snmp_trap_mac_notification_change_removed': True, 'spanning_tree_bpduguard': 'enable', 'spanning_tree_portfast': True, 'switchport_access_vlan': '70', 'switchport_mode': 'access', 'switchport_nonegotiate': 'nonegotiate', }, }, } golden_output = { 'execute.return_value': '''\ #show running-config interface Gi1/0/13 Building configuration... Current configuration : 914 bytes ! interface GigabitEthernet1/0/13 description ISE Controlled Port switchport access vlan 70 switchport mode access switchport nonegotiate ip arp inspection limit rate 1024 load-interval 30 authentication control-direction in authentication event fail action next-method authentication host-mode multi-auth authentication order dot1x mab authentication priority dot1x mab authentication port-control auto authentication periodic authentication timer reauthenticate server authentication timer inactivity 65535 authentication violation restrict authentication fallback dot1x mab snmp trap mac-notification change added snmp trap mac-notification change removed no snmp trap link-status dot1x pae authenticator dot1x timeout quiet-period 5 dot1x timeout server-timeout 10 dot1x timeout tx-period 5 spanning-tree portfast spanning-tree bpduguard enable ip dhcp snooping limit rate 100 end ''' } golden_parsed_output1 = { 'interfaces': { 'GigabitEthernet0': { 'description': '"Boot lan interface"', 'ipv4': { 'ip': '10.1.21.249', 'netmask': '255.255.255.0', }, 'negotiation_auto': True, 'vrf': 'Mgmt-intf', }, }, } golden_output1 = { 'execute.return_value': '''\ #show running-config interface GigabitEthernet0 Building configuration... Current configuration : 150 bytes ! interface GigabitEthernet0 description "Boot lan interface" vrf forwarding Mgmt-intf ip address 10.1.21.249 255.255.255.0 negotiation auto end ''' } golden_parsed_output2 = { 'interfaces': { 'Port-channel1.100': { 'encapsulation_dot1q': '201', 'ipv4': { 'ip': '202.0.0.1', 'netmask': '255.255.255.0', }, 'ipv6': ['2002::1/112'], 'ipv6_ospf': { '1': { 'area': '0', }, }, }, }, } golden_output2 = { 'execute.return_value': '''\ interface Port-channel1.100 encapsulation dot1Q 201 ip address 202.0.0.1 255.255.255.0 ipv6 address 2002::1/112 ipv6 ospf 1 area 0 end ''' } golden_parsed_output3 = { 'interfaces': { 'GigabitEthernet0/0/3': { 'ip_ospf': { '2': { 'area': '0', }, }, 'ipv4': { 'ip': '99.99.110.1', 'netmask': '255.255.255.0', }, 'ipv6': ['2003::1/112'], 'ipv6_ospf': { '1': { 'area': '0', }, }, 'negotiation_auto': True, }, }, } golden_output3 = { 'execute.return_value': '''\ interface GigabitEthernet0/0/3 ip address 99.99.110.1 255.255.255.0 ip ospf 2 area 0 negotiation auto ipv6 address 2003::1/112 ipv6 ospf 1 area 0 end ''' } golden_parsed_output4 = { 'interfaces': { 'GigabitEthernet0/0/0.101': { 'encapsulation_dot1q': '101', 'ipv4': { 'ip': '201.0.0.1', 'netmask': '255.255.255.0', }, 'ipv6': ['2001::1/112'], 'ipv6_enable': True, 'ipv6_ospfv3': { '1': { 'area': '0', }, }, 'vrf': 'VRF1', }, }, } golden_output4 = { 'execute.return_value': '''\ interface GigabitEthernet0/0/0.101 encapsulation dot1Q 101 vrf forwarding VRF1 ip address 201.0.0.1 255.255.255.0 ipv6 address 2001::1/112 ipv6 enable ospfv3 1 ipv6 area 0 end ''' } golden_parsed_output5 = { 'interfaces': { 'Loopback1': { 'ipv4': { 'ip': '200.1.0.2', 'netmask': '255.255.255.0', }, 'ipv6': ['1:1:1::1/64', '2000:1::2/112'], 'vrf': 'VRF1', }, }, } golden_output5 = { 'execute.return_value': '''\ interface Loopback1 vrf forwarding VRF1 ip address 200.1.0.2 255.255.255.0 ipv6 address 1:1:1::1/64 ipv6 address 2000:1::2/112 end ''' } golden_parsed_output6 = { 'interfaces': { 'GigabitEthernet0/0/0': { 'carrier_delay': ['up 60', 'down 60'], 'ipv6': ['1::1/112'], 'negotiation_auto': True, }, }, } golden_output6 = { 'execute.return_value': '''\ interface GigabitEthernet0/0/0 no ip address carrier-delay up 60 carrier-delay down 60 negotiation auto ipv6 address 1::1/112 end ''' } def test_empty(self): self.device1 = Mock(**self.empty_output) obj = ShowRunInterface(device=self.device1) with self.assertRaises(SchemaEmptyParserError): parsed_output = obj.parse(interface='GigabitEthernet0/0/0') def test_golden(self): self.device1 = Mock(**self.golden_output) obj = ShowRunInterface(device=self.device1) parsed_output = obj.parse(interface='Gi1/0/13') self.assertEqual(parsed_output, self.golden_parsed_output) def test_golden1(self): self.device1 = Mock(**self.golden_output1) obj = ShowRunInterface(device=self.device1) parsed_output = obj.parse(interface='GigabitEthernet0') self.assertEqual(parsed_output, self.golden_parsed_output1) def test_golden2(self): self.device1 = Mock(**self.golden_output2) obj = ShowRunInterface(device=self.device1) parsed_output = obj.parse(interface='Port-channel1.100') self.assertEqual(parsed_output, self.golden_parsed_output2) def test_golden3(self): self.device1 = Mock(**self.golden_output3) obj = ShowRunInterface(device=self.device1) parsed_output = obj.parse(interface='GigabitEthernet0/0/3') self.assertEqual(parsed_output, self.golden_parsed_output3) def test_golden4(self): self.device1 = Mock(**self.golden_output4) obj = ShowRunInterface(device=self.device1) parsed_output = obj.parse(interface='GigabitEthernet0/0/0.101') self.assertEqual(parsed_output, self.golden_parsed_output4) def test_golden5(self): self.device1 = Mock(**self.golden_output5) obj = ShowRunInterface(device=self.device1) parsed_output = obj.parse(interface='Loopback1') self.assertEqual(parsed_output, self.golden_parsed_output5) def test_golden6(self): self.device1 = Mock(**self.golden_output6) obj = ShowRunInterface(device=self.device1) parsed_output = obj.parse(interface='GigabitEthernet0/0/0') self.assertEqual(parsed_output, self.golden_parsed_output6)
class test_show_ntp_config(unittest.TestCase): device = Device(name='aDevice') empty_output = {'execute.return_value': ''} golden_parsed_output_1 = { 'vrf': { 'VRF1': { 'address': { '10.64.4.4': { 'isconfigured': { 'True': { 'address': '10.64.4.4', 'isconfigured': True} }, 'type': { 'server': { 'address': '10.64.4.4', 'type': 'server', 'vrf': 'VRF1'} } } } }, 'default': { 'address': { '10.4.1.1': { 'isconfigured': { 'True': { 'address': '10.4.1.1', 'isconfigured': True} }, 'type': { 'server': { 'address': '10.4.1.1', 'type': 'server', 'vrf': 'default'} } }, '10.16.2.2': { 'isconfigured': { 'True': { 'address': '10.16.2.2', 'isconfigured': True} }, 'type': { 'server': { 'address': '10.16.2.2', 'type': 'server', 'vrf': 'default'} } } } } } } golden_output_1 = {'execute.return_value': '''\ R1#show ntp config ntp server 10.4.1.1 ntp server 10.16.2.2 ntp server vrf VRF1 10.64.4.4 ''' } def test_empty(self): self.device = Mock(**self.empty_output) obj = ShowNtpConfig(device=self.device) with self.assertRaises(SchemaEmptyParserError): parsed_output = obj.parse() def test_golden_1(self): self.device = Mock(**self.golden_output_1) obj = ShowNtpConfig(device=self.device) parsed_output = obj.parse() self.assertEqual(parsed_output,self.golden_parsed_output_1)
class test_show_lldp_entry(unittest.TestCase): dev1 = Device(name='empty') dev_c3850 = Device(name='c3850') empty_output = {'execute.return_value': ' '} golden_parsed_output = { 'interfaces': { 'GigabitEthernet2/0/15': { 'if_name': 'GigabitEthernet2/0/15', 'port_id': { 'GigabitEthernet1/0/4': { 'neighbors': { 'R5': { 'neighbor_id': 'R5', 'chassis_id': '843d.c638.b980', 'port_id': 'GigabitEthernet1/0/4', 'port_description': 'GigabitEthernet1/0/4', 'system_description': 'Cisco IOS Software, C3750E Software (C3750E-UNIVERSALK9-M), Version 12.2(58)SE2, RELEASE SOFTWARE (fc1)\nTechnical Support: http://www.cisco.com/techsupport\nCopyright (c) 1986-2011 by Cisco Systems, Inc.\nCompiled Thu 21-Jul-11 01:23 by prod_rel_team', 'system_name': 'R5', 'time_remaining': 112, 'capabilities': { 'mac_bridge': { 'name': 'mac_bridge', 'system': True, 'enabled': True, }, 'router': { 'name': 'router', 'system': True, 'enabled': True, }, }, 'management_address': '10.9.1.1', 'auto_negotiation': 'supported, enabled', 'physical_media_capabilities': [ '1000baseT(FD)', '100base-TX(FD)', '100base-TX(HD)', '10base-T(FD)', '10base-T(HD)' ], 'unit_type': 30, 'vlan_id': 1, }, }, }, }, }, 'GigabitEthernet1/0/16': { 'if_name': 'GigabitEthernet1/0/16', 'port_id': { 'GigabitEthernet1/0/2': { 'neighbors': { 'R5': { 'neighbor_id': 'R5', 'chassis_id': '843d.c638.b980', 'port_id': 'GigabitEthernet1/0/2', 'port_description': 'GigabitEthernet1/0/2', 'system_name': 'R5', 'system_description': 'Cisco IOS Software, C3750E Software (C3750E-UNIVERSALK9-M), Version 12.2(58)SE2, RELEASE SOFTWARE (fc1)\nTechnical Support: http://www.cisco.com/techsupport\nCopyright (c) 1986-2011 by Cisco Systems, Inc.\nCompiled Thu 21-Jul-11 01:23 by prod_rel_team', 'time_remaining': 111, 'capabilities': { 'mac_bridge': { 'name': 'mac_bridge', 'system': True, 'enabled': True, }, 'router': { 'name': 'router', 'system': True, 'enabled': True, }, }, 'management_address': '10.9.1.1', 'auto_negotiation': 'supported, enabled', 'physical_media_capabilities': [ '1000baseT(FD)', '100base-TX(FD)', '100base-TX(HD)', '10base-T(FD)', '10base-T(HD)' ], 'unit_type': 30, 'vlan_id': 1, }, }, }, }, }, 'GigabitEthernet1/0/17': { 'if_name': 'GigabitEthernet1/0/17', 'port_id': { 'GigabitEthernet1/0/3': { 'neighbors': { 'R5': { 'neighbor_id': 'R5', 'chassis_id': '843d.c638.b980', 'port_id': 'GigabitEthernet1/0/3', 'port_description': 'GigabitEthernet1/0/3', 'system_description': 'Cisco IOS Software, C3750E Software (C3750E-UNIVERSALK9-M), Version 12.2(58)SE2, RELEASE SOFTWARE (fc1)\nTechnical Support: http://www.cisco.com/techsupport\nCopyright (c) 1986-2011 by Cisco Systems, Inc.\nCompiled Thu 21-Jul-11 01:23 by prod_rel_team', 'system_name': 'R5', 'time_remaining': 108, 'capabilities': { 'mac_bridge': { 'name': 'mac_bridge', 'system': True, 'enabled': True, }, 'router': { 'name': 'router', 'system': True, 'enabled': True, }, }, 'management_address': '10.9.1.1', 'auto_negotiation': 'supported, enabled', 'physical_media_capabilities': [ '1000baseT(FD)', '100base-TX(FD)', '100base-TX(HD)', '10base-T(FD)', '10base-T(HD)' ], 'unit_type': 30, 'vlan_id': 1, }, }, }, }, }, 'GigabitEthernet1/0/15': { 'if_name': 'GigabitEthernet1/0/15', 'port_id': { 'GigabitEthernet1/0/1': { 'neighbors': { 'R5': { 'neighbor_id': 'R5', 'system_description': 'Cisco IOS Software, C3750E Software (C3750E-UNIVERSALK9-M), Version 12.2(58)SE2, RELEASE SOFTWARE (fc1)\nTechnical Support: http://www.cisco.com/techsupport\nCopyright (c) 1986-2011 by Cisco Systems, Inc.\nCompiled Thu 21-Jul-11 01:23 by prod_rel_team', 'chassis_id': '843d.c638.b980', 'port_id': 'GigabitEthernet1/0/1', 'port_description': 'GigabitEthernet1/0/1', 'system_name': 'R5', 'time_remaining': 108, 'capabilities': { 'mac_bridge': { 'name': 'mac_bridge', 'system': True, 'enabled': True, }, 'router': { 'name': 'router', 'system': True, 'enabled': True, }, }, 'management_address': '10.9.1.1', 'auto_negotiation': 'supported, enabled', 'physical_media_capabilities': [ '1000baseT(FD)', '100base-TX(FD)', '100base-TX(HD)', '10base-T(FD)', '10base-T(HD)' ], 'unit_type': 30, 'vlan_id': 1, }, }, }, }, }, }, 'total_entries': 4, } golden_output = { 'execute.return_value': '''\ Capability codes: (R) Router, (B) Bridge, (T) Telephone, (C) DOCSIS Cable Device (W) WLAN Access Point, (P) Repeater, (S) Station, (O) Other ------------------------------------------------ Local Intf: Gi2/0/15 Chassis id: 843d.c638.b980 Port id: Gi1/0/4 Port Description: GigabitEthernet1/0/4 System Name: R5 System Description: Cisco IOS Software, C3750E Software (C3750E-UNIVERSALK9-M), Version 12.2(58)SE2, RELEASE SOFTWARE (fc1) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2011 by Cisco Systems, Inc. Compiled Thu 21-Jul-11 01:23 by prod_rel_team Time remaining: 112 seconds System Capabilities: B,R Enabled Capabilities: B,R Management Addresses: IP: 10.9.1.1 Auto Negotiation - supported, enabled Physical media capabilities: 1000baseT(FD) 100base-TX(FD) 100base-TX(HD) 10base-T(FD) 10base-T(HD) Media Attachment Unit type: 30 Vlan ID: 1 ------------------------------------------------ Local Intf: Gi1/0/16 Chassis id: 843d.c638.b980 Port id: Gi1/0/2 Port Description: GigabitEthernet1/0/2 System Name: R5 System Description: Cisco IOS Software, C3750E Software (C3750E-UNIVERSALK9-M), Version 12.2(58)SE2, RELEASE SOFTWARE (fc1) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2011 by Cisco Systems, Inc. Compiled Thu 21-Jul-11 01:23 by prod_rel_team Time remaining: 111 seconds System Capabilities: B,R Enabled Capabilities: B,R Management Addresses: IP: 10.9.1.1 Auto Negotiation - supported, enabled Physical media capabilities: 1000baseT(FD) 100base-TX(FD) 100base-TX(HD) 10base-T(FD) 10base-T(HD) Media Attachment Unit type: 30 Vlan ID: 1 ------------------------------------------------ Local Intf: Gi1/0/17 Chassis id: 843d.c638.b980 Port id: Gi1/0/3 Port Description: GigabitEthernet1/0/3 System Name: R5 System Description: Cisco IOS Software, C3750E Software (C3750E-UNIVERSALK9-M), Version 12.2(58)SE2, RELEASE SOFTWARE (fc1) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2011 by Cisco Systems, Inc. Compiled Thu 21-Jul-11 01:23 by prod_rel_team Time remaining: 108 seconds System Capabilities: B,R Enabled Capabilities: B,R Management Addresses: IP: 10.9.1.1 Auto Negotiation - supported, enabled Physical media capabilities: 1000baseT(FD) 100base-TX(FD) 100base-TX(HD) 10base-T(FD) 10base-T(HD) Media Attachment Unit type: 30 Vlan ID: 1 ------------------------------------------------ Local Intf: Gi1/0/15 Chassis id: 843d.c638.b980 Port id: Gi1/0/1 Port Description: GigabitEthernet1/0/1 System Name: R5 System Description: Cisco IOS Software, C3750E Software (C3750E-UNIVERSALK9-M), Version 12.2(58)SE2, RELEASE SOFTWARE (fc1) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2011 by Cisco Systems, Inc. Compiled Thu 21-Jul-11 01:23 by prod_rel_team Time remaining: 108 seconds System Capabilities: B,R Enabled Capabilities: B,R Management Addresses: IP: 10.9.1.1 Auto Negotiation - supported, enabled Physical media capabilities: 1000baseT(FD) 100base-TX(FD) 100base-TX(HD) 10base-T(FD) 10base-T(HD) Media Attachment Unit type: 30 Vlan ID: 1 Total entries displayed: 4 ''' } golden_output_1 = { 'execute.return_value': '''\ show lldp entry * Capability codes: (R) Router, (B) Bridge, (T) Telephone, (C) DOCSIS Cable Device (W) WLAN Access Point, (P) Repeater, (S) Station, (O) Other ------------------------------------------------ Local Intf: Gi1/0/13 Chassis id: 00fe.4fe1.7834e Port id: Gi0/0 Port Description: GigabitEthernet0/0 System Name: C9300-genie-3 System Description: Cisco IOS Software [Fuji], Catalyst L3 Switch Software (CAT9K_IOSXE), Version 16.9.3s, RELEASE SOFTWARE (fc3) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2019 by Cisco Systems, Inc. Compiled Sun 02-Jun-19 06:34 by mcpre Time remaining: 93 seconds System Capabilities: B,R Enabled Capabilities: B,R Management Addresses: IP: 10.1.2.203 Auto Negotiation - not supported Physical media capabilities - not advertised Media Attachment Unit type - not advertised Vlan ID: - not advertised ------------------------------------------------ Local Intf: Gi1/0/11 Chassis id: 4500.1ede.8800 Port id: Gi0/0 Port Description: GigabitEthernet0/0 System Name: C9300-genie.lab System Description: Cisco IOS Software [Fuji], Catalyst L3 Switch Software (CAT9K_IOSXE), Version 16.9.3, RELEASE SOFTWARE (fc2) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2019 by Cisco Systems, Inc. Compiled Wed 20-Mar-19 08:02 by mcpre Time remaining: 101 seconds System Capabilities: B,R Enabled Capabilities: B,R Management Addresses: IP: 10.1.23.23 Auto Negotiation - not supported Physical media capabilities - not advertised Media Attachment Unit type - not advertised Vlan ID: - not advertised ------------------------------------------------ Local Intf: Te1/1/3 Chassis id: 5a3e.7069.ed49 Port id: 5169.53ae.51ac Port Description - not advertised System Name - not advertised System Description - not advertised Time remaining: 97 seconds System Capabilities - not advertised Enabled Capabilities - not advertised Management Addresses - not advertised Auto Negotiation - not supported Physical media capabilities - not advertised Media Attachment Unit type - not advertised Vlan ID: - not advertised ------------------------------------------------ Local Intf: Gi1/0/10 Chassis id: 8dc3.4100.2988 Port id: Gi0/0 Port Description: GigabitEthernet0/0 System Name: C9300-Edge.genie System Description: Cisco IOS Software [Fuji], Catalyst L3 Switch Software (CAT9K_IOSXE), Version 16.9.3s, RELEASE SOFTWARE (fc3) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2019 by Cisco Systems, Inc. Compiled Sun 02-Jun-19 06:34 by mcpre Time remaining: 92 seconds System Capabilities: B,R Enabled Capabilities: B,R Management Addresses: IP: 10.1.23.102 Auto Negotiation - not supported Physical media capabilities - not advertised Media Attachment Unit type - not advertised Vlan ID: - not advertised Total entries displayed: 4 ''' } golden_parsed_output_1 = { 'interfaces': { 'GigabitEthernet1/0/10': { 'if_name': 'GigabitEthernet1/0/10', 'port_id': { 'GigabitEthernet0/0': { 'neighbors': { 'C9300-Edge.genie': { 'auto_negotiation': 'not supported', 'capabilities': { 'mac_bridge': { 'enabled': True, 'name': 'mac_bridge', 'system': True }, 'router': { 'enabled': True, 'name': 'router', 'system': True } }, 'chassis_id': '8dc3.4100.2988', 'management_address': '10.1.23.102', 'neighbor_id': 'C9300-Edge.genie', 'port_description': 'GigabitEthernet0/0', 'port_id': 'GigabitEthernet0/0', 'system_description': 'Cisco IOS Software [Fuji], Catalyst L3 Switch Software (CAT9K_IOSXE), Version 16.9.3s, RELEASE SOFTWARE (fc3)\nTechnical Support: http://www.cisco.com/techsupport\nCopyright (c) 1986-2019 by Cisco Systems, Inc.\nCompiled Sun 02-Jun-19 06:34 by mcpre', 'system_name': 'C9300-Edge.genie', 'time_remaining': 92 } } } }, }, 'GigabitEthernet1/0/11': { 'if_name': 'GigabitEthernet1/0/11', 'port_id': { 'GigabitEthernet0/0': { 'neighbors': { 'C9300-genie.lab': { 'auto_negotiation': 'not supported', 'capabilities': { 'mac_bridge': { 'enabled': True, 'name': 'mac_bridge', 'system': True }, 'router': { 'enabled': True, 'name': 'router', 'system': True } }, 'chassis_id': '4500.1ede.8800', 'management_address': '10.1.23.23', 'neighbor_id': 'C9300-genie.lab', 'port_description': 'GigabitEthernet0/0', 'port_id': 'GigabitEthernet0/0', 'system_description': 'Cisco IOS Software [Fuji], Catalyst L3 Switch Software (CAT9K_IOSXE), Version ' '16.9.3, RELEASE SOFTWARE (fc2)\nTechnical Support: http://www.cisco.com/techsupport\n' 'Copyright (c) 1986-2019 by Cisco Systems, Inc.\nCompiled Wed 20-Mar-19 08:02 by mcpre', 'system_name': 'C9300-genie.lab', 'time_remaining': 101 }, }, }, }, }, 'GigabitEthernet1/0/13': { 'if_name': 'GigabitEthernet1/0/13', 'port_id': { 'GigabitEthernet0/0': { 'neighbors': { 'C9300-genie-3': { 'auto_negotiation': 'not supported', 'capabilities': { 'mac_bridge': { 'enabled': True, 'name': 'mac_bridge', 'system': True }, 'router': { 'enabled': True, 'name': 'router', 'system': True } }, 'chassis_id': '00fe.4fe1.7834e', 'management_address': '10.1.2.203', 'neighbor_id': 'C9300-genie-3', 'port_description': 'GigabitEthernet0/0', 'port_id': 'GigabitEthernet0/0', 'system_description': 'Cisco IOS Software [Fuji], Catalyst L3 Switch Software (CAT9K_IOSXE), Version ' '16.9.3s, RELEASE SOFTWARE (fc3)\nTechnical Support: http://www.cisco.com/techsupport\n' 'Copyright (c) 1986-2019 by Cisco Systems, Inc.\n' 'Compiled Sun 02-Jun-19 06:34 by mcpre', 'system_name': 'C9300-genie-3', 'time_remaining': 93 }, }, }, }, }, 'TenGigabitEthernet1/1/3': { 'if_name': 'TenGigabitEthernet1/1/3', 'port_id': { '5169.53ae.51ac': { 'neighbors': { 'not advertised': { 'auto_negotiation': 'not supported', 'chassis_id': '5a3e.7069.ed49', 'neighbor_id': 'not advertised', 'port_id': '5169.53ae.51ac', 'system_name': 'not advertised', 'time_remaining': 97 }, }, }, }, }, }, 'total_entries': 4 } def test_empty(self): self.dev1 = Mock(**self.empty_output) obj = ShowLldpEntry(device=self.dev1) with self.assertRaises(SchemaEmptyParserError): parsed_output = obj.parse(entry='GigabitEthernet1/0/19') def test_golden(self): self.maxDiff = None self.dev_c3850 = Mock(**self.golden_output) obj = ShowLldpEntry(device=self.dev_c3850) parsed_output = obj.parse(entry='*') self.assertEqual(parsed_output, self.golden_parsed_output) def test_golden_1(self): self.maxDiff = None self.dev_c3850 = Mock(**self.golden_output_1) obj = ShowLldpEntry(device=self.dev_c3850) parsed_output = obj.parse(entry='*') self.assertEqual(parsed_output, self.golden_parsed_output_1)
class test_show_ntp_associations(unittest.TestCase): device = Device(name='aDevice') empty_output = {'execute.return_value': ''} golden_parsed_output_1 = { 'clock_state': {'system_status': {'associations_address': '127.127.1.1', 'associations_local_mode': 'client', 'clock_offset': 0.0, 'clock_refid': '.LOCL.', 'clock_state': 'synchronized', 'clock_stratum': 0, 'root_delay': 0.0} }, 'peer': {'10.4.1.1': {'local_mode': {'client': {'delay': 0.0, 'jitter': 15937.0, 'mode': 'unsynchronized', 'offset': 0.0, 'poll': 1024, 'reach': 0, 'receive_time': '-', 'refid': '.INIT.', 'remote': '10.4.1.1', 'stratum': 16, 'configured': True, 'local_mode': 'client'} } }, '127.127.1.1': {'local_mode': {'client': {'delay': 0.0, 'jitter': 1.204, 'mode': 'synchronized', 'offset': 0.0, 'poll': 16, 'reach': 377, 'receive_time': 6, 'refid': '.LOCL.', 'remote': '127.127.1.1', 'stratum': 0, 'configured': True, 'local_mode': 'client'} } }, '10.16.2.2': {'local_mode': {'client': {'delay': 0.0, 'jitter': 15937.0, 'mode': 'unsynchronized', 'offset': 0.0, 'poll': 1024, 'reach': 0, 'receive_time': '-', 'refid': '.INIT.', 'remote': '10.16.2.2', 'stratum': 16, 'configured': True, 'local_mode': 'client'} } } } } golden_output_1 = {'execute.return_value': ''' R1#show ntp associations address ref clock st when poll reach delay offset disp *~127.127.1.1 .LOCL. 0 6 16 377 0.000 0.000 1.204 ~10.4.1.1 .INIT. 16 - 1024 0 0.000 0.000 15937. ~10.4.1.1 .INIT. 16 - 1024 0 0.000 0.000 15937. ~10.16.2.2 .INIT. 16 - 1024 0 0.000 0.000 15937. ~10.16.2.2 .INIT. 16 - 1024 0 0.000 0.000 15937. * sys.peer, # selected, + candidate, - outlyer, x falseticker, ~ configured ''' } def test_empty(self): self.device = Mock(**self.empty_output) obj = ShowNtpAssociations(device=self.device) with self.assertRaises(SchemaEmptyParserError): parsed_output = obj.parse() def test_golden_1(self): self.maxDiff = None self.device = Mock(**self.golden_output_1) obj = ShowNtpAssociations(device=self.device) parsed_output = obj.parse() self.assertEqual(parsed_output, self.golden_parsed_output_1)
class TestShowVersion(unittest.TestCase): dev1 = Device(name='empty') dev_c9500 = Device(name='c9500') empty_output = {'execute.return_value': ''} golden_parsed_output_c9500 = { "version": { "version_short": "2019-10-31_17.49_makale", "os": "IOS-XE", "code_name": "Amsterdam", "platform": "Catalyst L3 Switch", "image_id": "CAT9K_IOSXE", "version": "17.2.20191101:003833", "compiled_date": "Thu 31-Oct-19 17:43", "compiled_by": "makale", "rom": "IOS-XE ROMMON", "bootldr_version": "System Bootstrap, Version 17.1.1[FC2], RELEASE SOFTWARE (P)", "hostname": "SF2", "uptime": "1 day, 18 hours, 48 minutes", "returned_to_rom_by": "Reload Command", "system_image": "bootflash:/ecr.bin", "last_reload_reason": "Reload Command", "license_level": "AIR DNA Advantage", "next_reload_license_level": "AIR DNA Advantage", "smart_licensing_status": "UNREGISTERED/EVAL EXPIRED", "chassis": "C9500-32QC", "processor_type": "X86", "main_mem": "1863083", "processor_board_id": "CAT2242L6CG", 'uptime_this_cp': '1 day, 18 hours, 49 minutes', "number_of_intfs": { "virtual_ethernet_interfaces": "44", "forty_gigabit_ethernet_interfaces": "32", "hundred_gigabit_ethernet_interfaces": "16" }, "mem_size": { "non_volatile_memory": "32768", "physical_memory": "16002848" }, "disks": { "bootflash:": { "disk_size": "11161600" }, "crashinfo:": { "disk_size": "1638400" } }, "mac_address": "70:b3:17:ff:65:60", "mb_assembly_num": "47A7", "mb_sn": "CAT2242L6CG", "model_rev_num": "V02", "mb_rev_num": "4", "model_num": "C9500-32QC", "system_sn": "CAT2242L6CG", "curr_config_register": "0x102" } } golden_output_c9500 = { 'execute.return_value': '''\ show version Cisco IOS XE Software, Version 2019-10-31_17.49_makale Cisco IOS Software [Amsterdam], Catalyst L3 Switch Software (CAT9K_IOSXE), Experimental Version 17.2.20191101:003833 [HEAD-/nobackup/makale/puntject2/polaris 106] Copyright (c) 1986-2019 by Cisco Systems, Inc. Compiled Thu 31-Oct-19 17:43 by makale Cisco IOS-XE software, Copyright (c) 2005-2019 by cisco Systems, Inc. All rights reserved. Certain components of Cisco IOS-XE software are licensed under the GNU General Public License ("GPL") Version 2.0. The software code licensed under GPL Version 2.0 is free software that comes with ABSOLUTELY NO WARRANTY. You can redistribute and/or modify such GPL code under the terms of GPL Version 2.0. For more details, see the documentation or "License Notice" file accompanying the IOS-XE software, or the applicable URL provided on the flyer accompanying the IOS-XE software. ROM: IOS-XE ROMMON BOOTLDR: System Bootstrap, Version 17.1.1[FC2], RELEASE SOFTWARE (P) SF2 uptime is 1 day, 18 hours, 48 minutes Uptime for this control processor is 1 day, 18 hours, 49 minutes System returned to ROM by Reload Command System image file is "bootflash:/ecr.bin" Last reload reason: Reload Command This product contains cryptographic features and is subject to United States and local country laws governing import, export, transfer and use. Delivery of Cisco cryptographic products does not imply third-party authority to import, export, distribute or use encryption. Importers, exporters, distributors and users are responsible for compliance with U.S. and local country laws. By using this product you agree to comply with applicable laws and regulations. If you are unable to comply with U.S. and local laws, return this product immediately. A summary of U.S. laws governing Cisco cryptographic products may be found at: http://www.cisco.com/wwl/export/crypto/tool/stqrg.html If you require further assistance please contact us by sending email to [email protected]. Technology Package License Information: ------------------------------------------------------------------------------ Technology-package Technology-package Current Type Next reboot ------------------------------------------------------------------------------ network-advantage Smart License network-advantage dna-advantage Subscription Smart License dna-advantage AIR License Level: AIR DNA Advantage Next reload AIR license Level: AIR DNA Advantage Smart Licensing Status: UNREGISTERED/EVAL EXPIRED cisco C9500-32QC (X86) processor with 1863083K/6147K bytes of memory. Processor board ID CAT2242L6CG 44 Virtual Ethernet interfaces 32 Forty Gigabit Ethernet interfaces 16 Hundred Gigabit Ethernet interfaces 32768K bytes of non-volatile configuration memory. 16002848K bytes of physical memory. 11161600K bytes of Bootflash at bootflash:. 1638400K bytes of Crash Files at crashinfo:. Base Ethernet MAC Address : 70:b3:17:ff:65:60 Motherboard Assembly Number : 47A7 Motherboard Serial Number : CAT2242L6CG Model Revision Number : V02 Motherboard Revision Number : 4 Model Number : C9500-32QC System Serial Number : CAT2242L6CG Configuration register is 0x102 ''' } def test_empty(self): self.dev1 = Mock(**self.empty_output) version_obj = ShowVersion(device=self.dev1) with self.assertRaises(SchemaEmptyParserError): parsered_output = version_obj.parse() def test_golden_c9500(self): self.maxDiff = None self.dev_c9500 = Mock(**self.golden_output_c9500) version_obj = ShowVersion(device=self.dev_c9500) parsed_output = version_obj.parse() self.assertEqual(parsed_output, self.golden_parsed_output_c9500)
class test_show_ntp_associations_detail(unittest.TestCase): device = Device(name='aDevice') empty_output = {'execute.return_value': ''} golden_parsed_output = { 'vrf': { 'default': { 'associations': { 'address': { '192.168.255.254': { 'local_mode': { 'client': { 'isconfigured': { 'True': { 'ip_type': 'ipv4', 'selected': False, 'unsynced': False, 'address': '192.168.255.254', 'isconfigured': True, 'authenticated': True, 'sane': False, 'valid': False, 'master': False, 'stratum': 3, 'refid': '172.16.255.254', 'input_time': 'DBAB02D6.9E354130 (16:08:06.618 EST Fri Oct 14 2016)', 'peer_interface': '172.16.255.254', 'poll': '512', 'vrf': 'default', 'local_mode': 'client', 'peer': { '172.16.255.254': { 'local_mode': { 'server': { 'poll': 512, 'local_mode': 'server', }, }, }, }, 'root_delay_msec': '0.00', 'root_disp': '14.52', 'reach': '377', 'sync_dist': '28.40', 'delay_msec': '0.00', 'offset_msec': '0.0000', 'dispersion': '7.23', 'jitter_msec': '0.97', 'precision': '2**10', 'version': 4, 'assoc_name': '192.168.255.254', 'assoc_id': 62758, 'ntp_statistics': { 'packet_received': 27, 'packet_sent': 27, 'packet_dropped': 0, }, 'originate_time': '00000000.00000000 (09:00:00.000 EST Mon Jan 1 1900)', 'receive_time': 'DBAB046D.A8B43B28 (16:14:53.659 EST Fri Oct 14 2016)', 'transmit_time': 'DBAB046D.A8B43B28 (16:14:53.659 EST Fri Oct 14 2016)', 'filtdelay': '0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.00', 'filtoffset': '0.00 0.50 0.00 1.00 1.00 1.00 1.00 1.00', 'filterror': '1.95 5.89 9.88 13.89 15.84 17.79 19.74 21.76', 'minpoll': 6, 'maxpoll': 10, }, }, }, }, }, '172.16.255.254': { 'local_mode': { 'client': { 'isconfigured': { 'True': { 'ip_type': 'ipv4', 'selected': False, 'unsynced': False, 'address': '172.16.255.254', 'isconfigured': True, 'authenticated': True, 'sane': True, 'valid': True, 'master': True, 'stratum': 2, 'refid': '127.127.1.1', 'input_time': 'DBAB05B9.753F7E30 (16:20:25.458 EST Fri Oct 14 2016)', 'peer_interface': '127.127.1.1', 'poll': '512', 'vrf': 'default', 'local_mode': 'client', 'peer': { '127.127.1.1': { 'local_mode': { 'server': { 'poll': 512, 'local_mode': 'server', }, }, }, }, 'root_delay_msec': '0.00', 'root_disp': '2.18', 'reach': '177', 'sync_dist': '9.47', 'delay_msec': '0.00', 'offset_msec': '-1.0000', 'dispersion': '5.64', 'jitter_msec': '0.97', 'precision': '2**10', 'version': 4, 'assoc_name': '172.16.255.254', 'assoc_id': 62756, 'ntp_statistics': { 'packet_received': 38, 'packet_sent': 50, 'packet_dropped': 0, }, 'originate_time': '00000000.00000000 (09:00:00.000 EST Mon Jan 1 1900)', 'receive_time': 'DBAB05BA.A8B43B28 (16:20:26.659 EST Fri Oct 14 2016)', 'transmit_time': 'DBAB05BA.A8B43B28 (16:20:26.659 EST Fri Oct 14 2016)', 'filtdelay': '1.00 1.00 1.00 1.00 0.00 1.00 1.00 0.00', 'filtoffset': '-0.50 -0.50 -0.50 -0.50 -1.00 -0.50 -0.50 -1.00', 'filterror': '1.95 2.88 3.81 4.74 5.08 5.11 7.53 8.46', 'minpoll': 6, 'maxpoll': 10, }, }, }, }, }, }, }, }, }, } golden_output = {'execute.return_value': ''' Router#show ntp associations detail Load for five secs: 1%/0%; one minute: 3%; five minutes: 4% Time source is NTP, 16:21:12.433 EST Fri Oct 14 2016 192.168.255.254 configured, ipv4, authenticated (' ' reject), insane, invalid, stratum 3 ref ID 172.16.255.254, time DBAB02D6.9E354130 (16:08:06.618 EST Fri Oct 14 2016) our mode client, peer mode server, our poll intvl 512, peer poll intvl 512 root delay 0.00 msec, root disp 14.52, reach 377, sync dist 28.40 delay 0.00 msec, offset 0.0000 msec, dispersion 7.23, jitter 0.97 msec precision 2**10, version 4 assoc id 62758, assoc name 192.168.255.254 assoc in packets 27, assoc out packets 27, assoc error packets 0 org time 00000000.00000000 (09:00:00.000 EST Mon Jan 1 1900) rec time DBAB046D.A8B43B28 (16:14:53.659 EST Fri Oct 14 2016) xmt time DBAB046D.A8B43B28 (16:14:53.659 EST Fri Oct 14 2016) filtdelay = 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.00 filtoffset = 0.00 0.50 0.00 1.00 1.00 1.00 1.00 1.00 filterror = 1.95 5.89 9.88 13.89 15.84 17.79 19.74 21.76 minpoll = 6, maxpoll = 10 172.16.255.254 configured, ipv4, authenticated, our_master, sane, valid, stratum 2 ref ID 127.127.1.1 , time DBAB05B9.753F7E30 (16:20:25.458 EST Fri Oct 14 2016) our mode client, peer mode server, our poll intvl 512, peer poll intvl 512 root delay 0.00 msec, root disp 2.18, reach 177, sync dist 9.47 delay 0.00 msec, offset -1.0000 msec, dispersion 5.64, jitter 0.97 msec precision 2**10, version 4 assoc id 62756, assoc name 172.16.255.254 assoc in packets 38, assoc out packets 50, assoc error packets 0 org time 00000000.00000000 (09:00:00.000 EST Mon Jan 1 1900) rec time DBAB05BA.A8B43B28 (16:20:26.659 EST Fri Oct 14 2016) xmt time DBAB05BA.A8B43B28 (16:20:26.659 EST Fri Oct 14 2016) filtdelay = 1.00 1.00 1.00 1.00 0.00 1.00 1.00 0.00 filtoffset = -0.50 -0.50 -0.50 -0.50 -1.00 -0.50 -0.50 -1.00 filterror = 1.95 2.88 3.81 4.74 5.08 5.11 7.53 8.46 minpoll = 6, maxpoll = 10 ''' } def test_empty(self): self.device = Mock(**self.empty_output) obj = ShowNtpAssociationsDetail(device=self.device) with self.assertRaises(SchemaEmptyParserError): parsed_output = obj.parse() def test_golden(self): self.maxDiff = None self.device = Mock(**self.golden_output) obj = ShowNtpAssociationsDetail(device=self.device) parsed_output = obj.parse() self.assertEqual(parsed_output, self.golden_parsed_output)
class TestShowInventory(unittest.TestCase): device = Device(name='aDevice') empty_output = {'execute.return_value': ''} golden_parsed_output_c9500 = { "index": { 1: { "name": "Chassis", "descr": "Cisco Catalyst 9500 Series Chassis", "pid": "C9500-32QC", "vid": "V01", "sn": "CAT2242L6CG" }, 2: { "name": "Power Supply Module 0", "descr": "Cisco Catalyst 9500 Series 650W AC Power Supply", "pid": "C9K-PWR-650WAC-R", "vid": "V01", "sn": "ART2216F3XV" }, 3: { "name": "Fan Tray 0", "descr": "Cisco Catalyst 9500 Series Fan Tray", "pid": "C9K-T1-FANTRAY" }, 4: { "name": "Fan Tray 1", "descr": "Cisco Catalyst 9500 Series Fan Tray", "pid": "C9K-T1-FANTRAY" }, 5: { "name": "Slot 1 Supervisor", "descr": "Cisco Catalyst 9500 Series Router", "pid": "C9500-32QC", "vid": "V01", "sn": "CAT2242L6CG" }, 6: { "name": "FortyGigabitEthernet1/0/4", "descr": "QSFP 40GE CU3M", "pid": "QSFP-H40G-CU3M", "vid": "V03", "sn": "TED2122K3A4-B" }, 7: { "name": "FortyGigabitEthernet1/0/8", "descr": "QSFP 40GE AOC3M", "pid": "QSFP-H40G-AOC3M", "vid": "V02", "sn": "FIW231301C6-B" }, 8: { "name": "FortyGigabitEthernet1/0/14", "descr": "QSFP 40GE AOC3M", "pid": "QSFP-H40G-AOC3M", "vid": "V02", "sn": "FIW231301BQ-B" }, 9: { "name": "FortyGigabitEthernet1/0/16", "descr": "QSFP 40GE AOC3M", "pid": "QSFP-H40G-AOC3M", "vid": "V02", "sn": "FIW2311023W-A" }, 10: { "name": "FortyGigabitEthernet1/0/20", "descr": "QSFP 40GE AOC3M", "pid": "QSFP-H40G-AOC3M", "vid": "V02", "sn": "FIW231301CF-B" }, 11: { "name": "HundredGigE1/0/33", "descr": "QSFP 100GE SR", "pid": "QSFP-100G-SR4-S", "vid": "V03", "sn": "INL23092488" }, 12: { "name": "HundredGigE1/0/35", "descr": "QSFP 100GE SR", "pid": "QSFP-100G-SR4-S", "vid": "V03", "sn": "AVF2243S0ZT" }, 13: { "name": "HundredGigE1/0/37", "descr": "QSFP 100GE SR", "pid": "QSFP-100G-SR4-S", "vid": "V03", "sn": "INL23092508" }, 14: { "name": "HundredGigE1/0/38", "descr": "QSFP 100GE AOC3M", "pid": "QSFP-100G-AOC3M", "vid": "V02", "sn": "FIW231000BV-A" }, 15: { "name": "HundredGigE1/0/41", "descr": "QSFP 100GE AOC1M", "pid": "QSFP-100G-AOC1M", "vid": "V03", "sn": "INL23100481-B" }, 16: { "name": "HundredGigE1/0/43", "descr": "QSFP 100GE CU2M", "pid": "QSFP-100G-CU2M", "sn": "APF23030058-B" }, 17: { "name": "HundredGigE1/0/44", "descr": "QSFP 100GE AOC3M", "pid": "QSFP-100G-AOC3M", "vid": "V02", "sn": "FIW23080391-B" }, 18: { "name": "HundredGigE1/0/45", "descr": "QSFP 100GE CU5M", "pid": "QSFP-100G-CU5M", "sn": "LCC2229G2JT-A" }, 19: { "name": "HundredGigE1/0/46", "descr": "QSFP 100GE AOC3M", "pid": "QSFP-100G-AOC3M", "vid": "V02", "sn": "FIW230802M4-B" }, 20: { "name": "HundredGigE1/0/47", "descr": "QSFP 100GE CU2M", "pid": "QSFP-100G-CU2M", "sn": "LCC2250H9M1-B" }, 21: { "name": "HundredGigE1/0/48", "descr": "QSFP 100GE SR", "pid": "QSFP-100G-SR4-S", "vid": "V03", "sn": "AVF2243S10A" } } } golden_output_c9500 = { 'execute.return_value': ''' show inventory NAME: "Chassis", DESCR: "Cisco Catalyst 9500 Series Chassis" PID: C9500-32QC , VID: V01 , SN: CAT2242L6CG NAME: "Power Supply Module 0", DESCR: "Cisco Catalyst 9500 Series 650W AC Power Supply" PID: C9K-PWR-650WAC-R , VID: V01 , SN: ART2216F3XV NAME: "Fan Tray 0", DESCR: "Cisco Catalyst 9500 Series Fan Tray" PID: C9K-T1-FANTRAY , VID: , SN: NAME: "Fan Tray 1", DESCR: "Cisco Catalyst 9500 Series Fan Tray" PID: C9K-T1-FANTRAY , VID: , SN: NAME: "Slot 1 Supervisor", DESCR: "Cisco Catalyst 9500 Series Router" PID: C9500-32QC , VID: V01 , SN: CAT2242L6CG NAME: "FortyGigabitEthernet1/0/4", DESCR: "QSFP 40GE CU3M" PID: QSFP-H40G-CU3M , VID: V03 , SN: TED2122K3A4-B NAME: "FortyGigabitEthernet1/0/8", DESCR: "QSFP 40GE AOC3M" PID: QSFP-H40G-AOC3M , VID: V02 , SN: FIW231301C6-B NAME: "FortyGigabitEthernet1/0/14", DESCR: "QSFP 40GE AOC3M" PID: QSFP-H40G-AOC3M , VID: V02 , SN: FIW231301BQ-B NAME: "FortyGigabitEthernet1/0/16", DESCR: "QSFP 40GE AOC3M" PID: QSFP-H40G-AOC3M , VID: V02 , SN: FIW2311023W-A NAME: "FortyGigabitEthernet1/0/20", DESCR: "QSFP 40GE AOC3M" PID: QSFP-H40G-AOC3M , VID: V02 , SN: FIW231301CF-B NAME: "HundredGigE1/0/33", DESCR: "QSFP 100GE SR" PID: QSFP-100G-SR4-S , VID: V03 , SN: INL23092488 NAME: "HundredGigE1/0/35", DESCR: "QSFP 100GE SR" PID: QSFP-100G-SR4-S , VID: V03 , SN: AVF2243S0ZT NAME: "HundredGigE1/0/37", DESCR: "QSFP 100GE SR" PID: QSFP-100G-SR4-S , VID: V03 , SN: INL23092508 NAME: "HundredGigE1/0/38", DESCR: "QSFP 100GE AOC3M" PID: QSFP-100G-AOC3M , VID: V02 , SN: FIW231000BV-A NAME: "HundredGigE1/0/41", DESCR: "QSFP 100GE AOC1M" PID: QSFP-100G-AOC1M , VID: V03 , SN: INL23100481-B NAME: "HundredGigE1/0/43", DESCR: "QSFP 100GE CU2M" PID: QSFP-100G-CU2M , VID: , SN: APF23030058-B NAME: "HundredGigE1/0/44", DESCR: "QSFP 100GE AOC3M" PID: QSFP-100G-AOC3M , VID: V02 , SN: FIW23080391-B NAME: "HundredGigE1/0/45", DESCR: "QSFP 100GE CU5M" PID: QSFP-100G-CU5M , VID: , SN: LCC2229G2JT-A NAME: "HundredGigE1/0/46", DESCR: "QSFP 100GE AOC3M" PID: QSFP-100G-AOC3M , VID: V02 , SN: FIW230802M4-B NAME: "HundredGigE1/0/47", DESCR: "QSFP 100GE CU2M" PID: QSFP-100G-CU2M , VID: , SN: LCC2250H9M1-B NAME: "HundredGigE1/0/48", DESCR: "QSFP 100GE SR" PID: QSFP-100G-SR4-S , VID: V03 , SN: AVF2243S10A ''' } def test_show_inventory_empty(self): self.maxDiff = None self.device = Mock(**self.empty_output) inventory_obj = ShowInventory(device=self.device) with self.assertRaises(SchemaEmptyParserError): parsed_output = inventory_obj.parse() def test_show_inventory_golden_c9500(self): self.maxDiff = None self.device = Mock(**self.golden_output_c9500) inventory_obj = ShowInventory(device=self.device) parsed_output = inventory_obj.parse() self.assertEqual(parsed_output, self.golden_parsed_output_c9500)
class TestShowMPLSLSPNameDetail(unittest.TestCase): device = Device(name='aDevice') maxDiff = None empty_output = {'execute.return_value': ''} golden_output_1 = { 'execute.return_value': """Ingress LSP: 0 sessions Total 0 displayed, Up 0, Down 0 Egress LSP: 0 sessions Total 0 displayed, Up 0, Down 0 Transit LSP: 30 sessions 10.49.194.125 From: 10.49.194.127, LSPstate: Up, ActiveRoute: 0 LSPname: test_lsp_01, LSPpath: Primary Suggested label received: -, Suggested label sent: - Recovery label received: -, Recovery label sent: 44 Resv style: 1 FF, Label in: 46, Label out: 44 Time left: 138, Since: Tue Jun 30 07:22:02 2020 Tspec: rate 0bps size 0bps peak Infbps m 20 M 1500 Port number: sender 1 receiver 50088 protocol 0 PATH rcvfrom: 10.169.14.157 (ge-0/0/0.0) 1 pkts Adspec: received MTU 1500 sent MTU 1500 PATH sentto: 192.168.145.218 (ge-0/0/1.1) 1 pkts RESV rcvfrom: 192.168.145.218 (ge-0/0/1.1) 1 pkts, Entropy label: Yes Explct route: 192.168.145.218 10.49.194.65 10.49.194.66 10.49.194.123 Record route: 10.49.194.2 10.169.14.157 <self> 192.168.145.218 10.49.194.66 10.49.194.12 255.255.255.255 10.4.1.1 10.1.8.8 10.64.64.64 Total 1 displayed, Up 1, Down 0""" } golden_parsed_output_1 = { 'mpls-lsp-information': { 'rsvp-session-data': [{ 'session-type': 'Ingress', 'count': '0', 'display-count': '0', 'up-count': '0', 'down-count': '0' }, { 'session-type': 'Egress', 'count': '0', 'display-count': '0', 'up-count': '0', 'down-count': '0' }, { 'session-type': 'Transit', 'count': '30', 'rsvp-session': { 'destination-address': '10.49.194.125', 'source-address': '10.49.194.127', 'lsp-state': 'Up', 'route-count': '0', 'name': 'test_lsp_01', 'lsp-path-type': 'Primary', 'suggested-label-in': '-', 'suggested-label-out': '-', 'recovery-label-in': '-', 'recovery-label-out': '44', 'rsb-count': '1', 'resv-style': 'FF', 'label-in': '46', 'label-out': '44', 'psb-lifetime': '138', 'psb-creation-time': 'Tue Jun 30 07:22:02 2020', 'sender-tspec': 'rate 0bps size 0bps peak Infbps m 20 M 1500', 'lsp-id': '1', 'tunnel-id': '50088', 'proto-id': '0', 'packet-information': [{ 'heading': 'PATH', 'previous-hop': '10.169.14.157', 'interface-name': '(ge-0/0/0.0)', 'count': '1' }, { 'heading': 'PATH', 'next-hop': '192.168.145.218', 'interface-name': '(ge-0/0/1.1)', 'count': '1' }, { 'heading': 'RESV', 'previous-hop': '192.168.145.218', 'interface-name': '(ge-0/0/1.1)', 'count': '1', 'entropy-label': 'Yes' }], 'adspec': 'received MTU 1500 sent MTU 1500', 'explicit-route': { 'explicit-route-element': [{ 'address': '192.168.145.218' }, { 'address': '10.49.194.65' }, { 'address': '10.49.194.66' }, { 'address': '10.49.194.123' }] }, 'record-route': { 'record-route-element': [{ 'address': '10.49.194.2' }, { 'address': '10.169.14.157' }, { 'address': '<self>' }, { 'address': '192.168.145.218' }, { 'address': '10.49.194.66' }, { 'address': '10.49.194.12' }, { 'address': '255.255.255.255' }, { 'address': '10.4.1.1' }, { 'address': '10.1.8.8' }, { 'address': '10.64.64.64' }] } }, 'display-count': '1', 'up-count': '1', 'down-count': '0' }] } } def test_empty(self): self.device = Mock(**self.empty_output) obj = ShowMPLSLSPNameDetail(device=self.device) with self.assertRaises(SchemaEmptyParserError): parsed_output = obj.parse(name='test_lsp_01') def test_golden_1(self): self.device = Mock(**self.golden_output_1) obj = ShowMPLSLSPNameDetail(device=self.device) parsed_output = obj.parse(name='test_lsp_01') self.assertEqual(parsed_output, self.golden_parsed_output_1)
class TestShowSystemNtpAll(unittest.TestCase): maxDiff = None dev = Device(name='device') empty_output = {'execute.return_value': ''} sample_output = {'execute.return_value': ''' A:admin@GENIE01XR1# show system ntp all =============================================================================== NTP Status =============================================================================== Configured : Yes Stratum : 3 Admin Status : up Oper Status : up Server Enabled : No Server Authenticate : No Clock Source : 192.168.132.170 Auth Check : No Current Date & Time: 2020/01/17 17:24:12 UTC =============================================================================== =============================================================================== NTP Active Associations =============================================================================== State Reference ID St Type A Poll Reach Offset(ms) Router Remote ------------------------------------------------------------------------------- reject STEP - srvr - 64 ........ 0.000 Base 172.16.189.64 reject STEP - srvr - 64 ........ 0.000 Base 172.16.189.74 candidate 172.16.25.201 4 srvr - 64 YYYYYYYY -0.541 Base 172.16.25.140 candidate 172.16.25.201 4 srvr - 64 YYYYYYYY -0.335 Base 172.16.25.141 reject STEP - srvr - 64 ........ 0.000 Base 172.16.186.22 reject STEP - srvr - 64 ........ 0.000 Base 172.24.107.142 chosen 172.16.85.97 2 srvr - 64 YYYYYYYY 0.259 Base 192.168.132.170 =============================================================================== =============================================================================== NTP Clients =============================================================================== vRouter Time Last Request Rx Address ------------------------------------------------------------------------------- =============================================================================== '''} sample_parsed_output = { 'clock_state': { 'system_status': { 'admin_status': 'up', 'auth_check': 'No', 'clock_source': '192.168.132.170', 'configured': 'Yes', 'current_date_time': '2020/01/17 17:24:12 UTC', 'oper_status': 'up', 'server_authenticate': 'No', 'server_enabled': 'No', 'stratum': 3, }, }, 'peer': { '172.16.189.64': { 'local_mode': { 'client': { 'a': '-', 'offset': 0.0, 'poll': 64, 'reach': '........', 'refid': 'STEP', 'remote': '172.16.189.64', 'router': 'Base', 'state': 'reject', 'stratum': '-', 'type': 'srvr', }, }, }, '172.16.189.74': { 'local_mode': { 'client': { 'a': '-', 'offset': 0.0, 'poll': 64, 'reach': '........', 'refid': 'STEP', 'remote': '172.16.189.74', 'router': 'Base', 'state': 'reject', 'stratum': '-', 'type': 'srvr', }, }, }, '172.16.25.140': { 'local_mode': { 'client': { 'a': '-', 'offset': -0.541, 'poll': 64, 'reach': 'YYYYYYYY', 'refid': '172.16.25.201', 'remote': '172.16.25.140', 'router': 'Base', 'state': 'candidate', 'stratum': '4', 'type': 'srvr', }, }, }, '172.16.25.141': { 'local_mode': { 'client': { 'a': '-', 'offset': -0.335, 'poll': 64, 'reach': 'YYYYYYYY', 'refid': '172.16.25.201', 'remote': '172.16.25.141', 'router': 'Base', 'state': 'candidate', 'stratum': '4', 'type': 'srvr', }, }, }, '172.16.186.22': { 'local_mode': { 'client': { 'a': '-', 'offset': 0.0, 'poll': 64, 'reach': '........', 'refid': 'STEP', 'remote': '172.16.186.22', 'router': 'Base', 'state': 'reject', 'stratum': '-', 'type': 'srvr', }, }, }, '172.24.107.142': { 'local_mode': { 'client': { 'a': '-', 'offset': 0.0, 'poll': 64, 'reach': '........', 'refid': 'STEP', 'remote': '172.24.107.142', 'router': 'Base', 'state': 'reject', 'stratum': '-', 'type': 'srvr', }, }, }, '192.168.132.170': { 'local_mode': { 'client': { 'a': '-', 'offset': 0.259, 'poll': 64, 'reach': 'YYYYYYYY', 'refid': '172.16.85.97', 'remote': '192.168.132.170', 'router': 'Base', 'state': 'chosen', 'stratum': '2', 'type': 'srvr', }, }, }, }, } def test_empty(self): self.dev = Mock(**self.empty_output) obj = ShowSystemNtpAll(device=self.dev) with self.assertRaises(SchemaEmptyParserError): parsed_output = obj.parse() def test_golden(self): self.dev = Mock(**self.sample_output) obj = ShowSystemNtpAll(device=self.dev) parsed_output = obj.parse() self.assertEqual(parsed_output,self.sample_parsed_output)
class test_show_crypto_pki_certificate(unittest.TestCase): device = Device(name='aDevice') empty_output = {'execute.return_value': ''} golden_parsed_output_c3850 = { "trustpoints": { "CISCO_IDEVID_SUDI": { "associated_trustpoints":{ "certificate": { "status": "Available", "serial_number_in_hex": "793B572700000003750B", "subject": { "name": "WS-C3850-24P-0057D21BC800", "pid": "WS-C3850-24P", "cn": "WS-C3850-24P-0057D21BC800", "serial_number": "FCW1947C0GF" }, "issuer": { "cn": "Cisco Manufacturing CA SHA2", "o": "Cisco" }, "crl_distribution_points": "http://www.cisco.com/security/pki/crl/cmca2.crl", "usage": "General Purpose", "validity_date": { "start_date": "00:34:52 UTC Nov 20 2015", "end_date": "00:44:52 UTC Nov 20 2025" } }, "ca_certificate": { "status": "Available", "serial_number_in_hex": "02", "subject": { "cn": "Cisco Manufacturing CA SHA2", "o": "Cisco" }, "issuer": { "cn": "Cisco Root CA M2", "o": "Cisco" }, "crl_distribution_points": "http://www.cisco.com/security/pki/crl/crcam2.crl", "usage": "Signature", "validity_date": { "start_date": "13:50:58 UTC Nov 12 2012", "end_date": "13:00:17 UTC Nov 12 2037" } } } } } } golden_output_c3850 = {'execute.return_value': ''' Certificate Status: Available Certificate Serial Number (hex): 793B572700000003750B Certificate Usage: General Purpose Issuer: cn=Cisco Manufacturing CA SHA2 o=Cisco Subject: Name: WS-C3850-24P-0057D21BC800 Serial Number: PID:WS-C3850-24P SN:FCW1947C0GF cn=WS-C3850-24P-0057D21BC800 serialNumber=PID:WS-C3850-24P SN:FCW1947C0GF CRL Distribution Points: http://www.cisco.com/security/pki/crl/cmca2.crl Validity Date: start date: 00:34:52 UTC Nov 20 2015 end date: 00:44:52 UTC Nov 20 2025 Associated Trustpoints: CISCO_IDEVID_SUDI CA Certificate Status: Available Certificate Serial Number (hex): 02 Certificate Usage: Signature Issuer: cn=Cisco Root CA M2 o=Cisco Subject: cn=Cisco Manufacturing CA SHA2 o=Cisco CRL Distribution Points: http://www.cisco.com/security/pki/crl/crcam2.crl Validity Date: start date: 13:50:58 UTC Nov 12 2012 end date: 13:00:17 UTC Nov 12 2037 Associated Trustpoints: CISCO_IDEVID_SUDI Trustpool '''} golden_parsed_output_csr1000 = { 'trustpoints': {'TP-self-signed-4146203551': {'associated_trustpoints': {'router_self_signed_certificate': {'issuer': {'cn': 'IOS-Self-Signed-Certificate-4146203551'}, 'serial_number_in_hex': '01', 'status': 'Available', 'storage': 'nvram:IOS-Self-Sig#1.cer', 'subject': {'cn': 'IOS-Self-Signed-Certificate-4146203551', 'name': 'IOS-Self-Signed-Certificate-4146203551'}, 'usage': 'General Purpose', 'validity_date': {'end_date': '00:00:00 UTC Jan 1 2020', 'start_date': '21:37:27 UTC Apr 23 2018'}}}}}} golden_output_csr1000 = {'execute.return_value': ''' Router Self-Signed Certificate Status: Available Certificate Serial Number (hex): 01 Certificate Usage: General Purpose Issuer: cn=IOS-Self-Signed-Certificate-4146203551 Subject: Name: IOS-Self-Signed-Certificate-4146203551 cn=IOS-Self-Signed-Certificate-4146203551 Validity Date: start date: 21:37:27 UTC Apr 23 2018 end date: 00:00:00 UTC Jan 1 2020 Associated Trustpoints: TP-self-signed-4146203551 Storage: nvram:IOS-Self-Sig#1.cer '''} def test_empty(self): self.device = Mock(**self.empty_output) obj = ShowCryptoPkiCertificates(device=self.device) with self.assertRaises(SchemaEmptyParserError): parsed_output = obj.parse() def test_c3850(self): self.maxDiff = None self.device = Mock(**self.golden_output_c3850) obj = ShowCryptoPkiCertificates(device=self.device) parsed_output = obj.parse(trustpoint_name='CISCO_IDEVID_SUDI') self.assertEqual(parsed_output, self.golden_parsed_output_c3850) def test_csr1000(self): self.maxDiff = None self.device = Mock(**self.golden_output_csr1000) obj = ShowCryptoPkiCertificates(device=self.device) parsed_output = obj.parse(trustpoint_name='TP-self-signed-4146203551') self.assertEqual(parsed_output, self.golden_parsed_output_csr1000)
class TestShowRedundancy(unittest.TestCase): dev1 = Device(name='empty') dev_iosv = Device(name='c7600') empty_output = {'execute.return_value': ''} output_c7600 = {'execute.return_value': ''' Redundant System Information : ------------------------------ Available system uptime = 24 weeks, 6 days, 23 hours, 14 minutes Switchovers system experienced = 0 Standby failures = 0 Last switchover reason = none Hardware Mode = Duplex Configured Redundancy Mode = sso Operating Redundancy Mode = sso Maintenance Mode = Disabled Communications = Up Current Processor Information : ------------------------------- Active Location = slot 6 Current Software state = ACTIVE Uptime in current state = 24 weeks, 6 days, 23 hours, 13 minutes Image Version = Cisco IOS Software, s72033_rp Software (s72033_rp-ADVENTERPRISEK9_DBG-M), Version 15.4(0.10)S, EARLY DEPLOYMENT ENGINEERING WEEKLY BUILD, synced to BLD_DARLING_122S_040709_1301 Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2013 by Cisco Systems, Inc. Compiled Wed 26-Jun-13 02:21 by alnguyen BOOT = disk0:s72033-adventerprisek9_dbg-mz.154-0.10.S-ipcore-ssr-uut2,12; CONFIG_FILE = BOOTLDR = Configuration register = 0x2 Peer Processor Information : ---------------------------- Standby Location = slot 5 Current Software state = STANDBY HOT Uptime in current state = 4 weeks, 1 day, 22 hours, 47 minutes Image Version = Cisco IOS Software, s72033_rp Software (s72033_rp-ADVENTERPRISEK9_DBG-M), Version 15.4(0.10)S, EARLY DEPLOYMENT ENGINEERING WEEKLY BUILD, synced to BLD_DARLING_122S_040709_1301 Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2013 by Cisco Systems, Inc. Compiled Wed 26-Jun-13 02:21 by alnguyen BOOT = disk0:s72033-adventerprisek9_dbg-mz.154-0.10.S-ipcore-ssr-uut2,12; CONFIG_FILE = BOOTLDR = Configuration register = 0x2 '''} parsed_output = { 'red_sys_info': { 'available_system_uptime': '24 weeks, 6 days, 23 hours, 14 minutes', 'communications': 'Up', 'conf_red_mode': 'sso', 'hw_mode': 'Duplex', 'last_switchover_reason': 'none', 'maint_mode': 'Disabled', 'oper_red_mode': 'sso', 'standby_failures': '0', 'switchovers_system_experienced': '0', }, 'slot': { 'slot 5': { 'boot': 'disk0:s72033-adventerprisek9_dbg-mz.154-0.10.S-ipcore-ssr-uut2,12;', 'compiled_by': 'alnguyen', 'compiled_date': 'Wed 26-Jun-13 02:21', 'config_register': '0x2', 'curr_sw_state': 'STANDBY HOT', 'image_ver': 'Cisco IOS Software, s72033_rp Software (s72033_rp-ADVENTERPRISEK9_DBG-M), Version 15.4(0.10)S, EARLY DEPLOYMENT ENGINEERING WEEKLY BUILD, synced to BLD_DARLING_122S_040709_1301', 'uptime_in_curr_state': '4 weeks, 1 day, 22 hours, 47 minutes', }, 'slot 6': { 'boot': 'disk0:s72033-adventerprisek9_dbg-mz.154-0.10.S-ipcore-ssr-uut2,12;', 'compiled_by': 'alnguyen', 'compiled_date': 'Wed 26-Jun-13 02:21', 'config_register': '0x2', 'curr_sw_state': 'ACTIVE', 'image_ver': 'Cisco IOS Software, s72033_rp Software (s72033_rp-ADVENTERPRISEK9_DBG-M), Version 15.4(0.10)S, EARLY DEPLOYMENT ENGINEERING WEEKLY BUILD, synced to BLD_DARLING_122S_040709_1301', 'uptime_in_curr_state': '24 weeks, 6 days, 23 hours, 13 minutes', }, }, } def test_empty(self): self.dev1 = Mock(**self.empty_output) version_obj = ShowRedundancy(device=self.dev1) with self.assertRaises(SchemaEmptyParserError): empty_parsed_output = version_obj.parse() def test_c7600(self): self.maxDiff = None self.device = Mock(**self.output_c7600) obj = ShowRedundancy(device=self.device) parsed_output = obj.parse() self.assertEqual(parsed_output, self.parsed_output)
def setUp(self): self.device = Device(name='aDevice') self.device.os = 'ios' self.device.custom['abstraction'] = {'order': ['os']} self.device.mapping = {}
class TestShowModule(unittest.TestCase): dev1 = Device(name='empty') dev_iosv = Device(name='c7600') empty_output = {'execute.return_value': ''} output_c7600 = {'execute.return_value': ''' Mod Ports Card Type Model Serial No. --- ----- -------------------------------------- ------------------ ----------- 1 48 CEF720 48 port 10/100/1000mb Ethernet WS-X6748-GE-TX SAL1209HMW3 2 0 2 port adapter Enhanced FlexWAN WS-X6582-2PA JAE0939LYNQ 5 2 Supervisor Engine 720 (Hot) WS-SUP720-3BXL SAD09020BF8 6 2 Supervisor Engine 720 (Active) WS-SUP720-3BXL SAL15129MRC Mod MAC addresses Hw Fw Sw Status --- ---------------------------------- ----- ------------- ------------ ------- 1 001e.4a79.7510 to 001e.4a79.753f 2.7 12.2(14r)S 15.4(0.10) Ok 2 0015.2bc3.25c0 to 0015.2bc3.25ff 2.1 15.4(0.10)S 15.4(0.10)S Ok 5 0011.21b5.8e64 to 0011.21b5.8e67 4.1 8.1(3 15.4(0.10) Ok 6 0022.559e.64fc to 0022.559e.64ff 5.12 8.5(4 15.4(0.10) Ok Mod Sub-Module Model Serial Hw Status ---- --------------------------- ------------------ ----------- ------- ------- 1 Centralized Forwarding Card WS-F6700-CFC SAL1207G5V1 4.0 Ok 5 Policy Feature Card 3 WS-F6K-PFC3BXL SAD090301K6 1.4 Ok 5 MSFC3 Daughterboard WS-SUP720 SAD090105M6 2.2 Ok 6 Policy Feature Card 3 WS-F6K-PFC3BXL SAL15129KW4 1.11 Ok 6 MSFC3 Daughterboard WS-SUP720 SAL15045PYS 5.1 Ok Mod Online Diag Status ---- ------------------- 1 Pass 2 Pass 5 Pass 6 Pass '''} parsed_output = { 'slot': { '1': { 'lc': { 'card_type': 'CEF720 48 port 10/100/1000mb Ethernet', 'fw_ver': '12.2(14r)S', 'hw_ver': '2.7', 'mac_address_from': '001e.4a79.7510', 'mac_address_to': '001e.4a79.753f', 'model': 'WS-X6748-GE-TX', 'online_diag_status': 'Pass', 'ports': 48, 'serial_number': 'SAL1209HMW3', 'status': 'Ok', 'subslot': { 'WS-F6700-CFC': { 'hw_ver': '4.0', 'model': 'WS-F6700-CFC', 'serial_number': 'SAL1207G5V1', 'status': 'Ok', }, }, 'sw_ver': '15.4(0.10)', }, }, '2': { 'lc': { 'card_type': '2 port adapter Enhanced FlexWAN', 'fw_ver': '15.4(0.10)S', 'hw_ver': '2.1', 'mac_address_from': '0015.2bc3.25c0', 'mac_address_to': '0015.2bc3.25ff', 'model': 'WS-X6582-2PA', 'online_diag_status': 'Pass', 'ports': 0, 'serial_number': 'JAE0939LYNQ', 'status': 'Ok', 'sw_ver': '15.4(0.10)S', }, }, '5': { 'rp': { 'card_type': 'Supervisor Engine 720 (Hot)', 'fw_ver': '8.1(3', 'hw_ver': '4.1', 'mac_address_from': '0011.21b5.8e64', 'mac_address_to': '0011.21b5.8e67', 'model': 'WS-SUP720-3BXL', 'online_diag_status': 'Pass', 'ports': 2, 'serial_number': 'SAD09020BF8', 'status': 'Ok', 'subslot': { 'WS-F6K-PFC3BXL': { 'hw_ver': '1.4', 'model': 'WS-F6K-PFC3BXL', 'serial_number': 'SAD090301K6', 'status': 'Ok', }, 'WS-SUP720': { 'hw_ver': '2.2', 'model': 'WS-SUP720', 'serial_number': 'SAD090105M6', 'status': 'Ok', }, }, 'sw_ver': '15.4(0.10)', }, }, '6': { 'rp': { 'card_type': 'Supervisor Engine 720 (Active)', 'fw_ver': '8.5(4', 'hw_ver': '5.12', 'mac_address_from': '0022.559e.64fc', 'mac_address_to': '0022.559e.64ff', 'model': 'WS-SUP720-3BXL', 'online_diag_status': 'Pass', 'ports': 2, 'serial_number': 'SAL15129MRC', 'status': 'Ok', 'subslot': { 'WS-F6K-PFC3BXL': { 'hw_ver': '1.11', 'model': 'WS-F6K-PFC3BXL', 'serial_number': 'SAL15129KW4', 'status': 'Ok', }, 'WS-SUP720': { 'hw_ver': '5.1', 'model': 'WS-SUP720', 'serial_number': 'SAL15045PYS', 'status': 'Ok', }, }, 'sw_ver': '15.4(0.10)', }, }, }, } def test_empty(self): self.dev1 = Mock(**self.empty_output) version_obj = ShowModule(device=self.dev1) with self.assertRaises(SchemaEmptyParserError): empty_parsed_output = version_obj.parse() def test_c7600(self): self.maxDiff = None self.device = Mock(**self.output_c7600) obj = ShowModule(device=self.device) parsed_output = obj.parse() self.assertEqual(parsed_output, self.parsed_output)
class test_show_traffic_stats(unittest.TestCase): """unit test for show service-group traffic-stats""" device = Device(name='aDevice') empty_output = {'execute.return_value': ''} golden_output = { 'execute.return_value': ''' Router# show service-group traffic-stats Traffic Statistics of service groups: Group Pks In Bytes In Pkts Out Bytes Out 1 1 22 3 62 2 0 0 0 0 3 0 0 0 0 10 0 0 0 0 20 0 0 0 0 ''' } golden_parsed_output = { "group": { 1: { "pkts_in": 1, "bytes_in": 22, "pkts_out": 3, "bytes_out": 62 }, 2: { "pkts_in": 0, "bytes_in": 0, "pkts_out": 0, "bytes_out": 0 }, 3: { "pkts_in": 0, "bytes_in": 0, "pkts_out": 0, "bytes_out": 0 }, 10: { "pkts_in": 0, "bytes_in": 0, "pkts_out": 0, "bytes_out": 0 }, 20: { "pkts_in": 0, "bytes_in": 0, "pkts_out": 0, "bytes_out": 0 } } } golden_output_group = { 'execute.return_value': ''' Router# show service-group traffic-stats group 1 Traffic Statistics of service groups: Group Pkts In Bytes In Pkts Out Bytes Out 1 78 10548 172 18606 ''' } golden_parsed_output_group = { "group": { 1: { "pkts_in": 78, "bytes_in": 10548, "pkts_out": 172, "bytes_out": 18606 } } } def test_empty(self): self.device = Mock(**self.empty_output) obj = ShowServiceGroupTrafficStats(device=self.device) with self.assertRaises(SchemaEmptyParserError): parsed_output = obj.parse() def test_golden(self): self.maxDiff = None self.device = Mock(**self.golden_output) obj = ShowServiceGroupTrafficStats(device=self.device) parsed_output = obj.parse() self.assertEqual(parsed_output, self.golden_parsed_output) def test_show_group(self): self.maxDiff = None self.device = Mock(**self.golden_output_group) obj = ShowServiceGroupTrafficStats(device=self.device) parsed_output = obj.parse(group="group 1") self.assertEqual(parsed_output, self.golden_parsed_output_group)