diff --git a/README.md b/README.md index 2e76438..31add6b 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ [![PyPI](https://img.shields.io/pypi/v/napalm-ios.svg)](https://pypi.python.org/pypi/napalm-ios) -[![PyPI](https://img.shields.io/pypi/dm/napalm-ios.svg)](https://pypi.python.org/pypi/napalm-ios) [![Build Status](https://travis-ci.org/napalm-automation/napalm-ios.svg?branch=master)](https://travis-ci.org/napalm-automation/napalm-ios) [![Coverage Status](https://coveralls.io/repos/github/napalm-automation/napalm-ios/badge.svg?branch=master)](https://coveralls.io/github/napalm-automation/napalm-ios) diff --git a/napalm_ios/ios.py b/napalm_ios/ios.py index 051df5a..caa45e7 100644 --- a/napalm_ios/ios.py +++ b/napalm_ios/ios.py @@ -363,7 +363,10 @@ def compare_config(self): # merge cmd = 'show archive config incremental-diffs {} ignorecase'.format(new_file_full) diff = self.device.send_command_expect(cmd) - if '% Invalid' not in diff: + if 'error code 5' in diff or 'returned error 5' in diff: + diff = "You have encountered the obscure 'error 5' message. This generally " \ + "means you need to add an 'end' statement to the end of your merge changes." + elif '% Invalid' not in diff: diff = self._normalize_merge_diff_incr(diff) else: cmd = 'more {}'.format(new_file_full) @@ -374,17 +377,13 @@ def compare_config(self): def _commit_hostname_handler(self, cmd): """Special handler for hostname change on commit operation.""" - try: - current_prompt = self.device.find_prompt() - # Wait 12 seconds for output to come back (.2 * 60) - output = self.device.send_command_expect(cmd, delay_factor=.2, max_loops=60) - except IOError: - # Check if hostname change - if current_prompt == self.device.find_prompt(): - raise - else: - self.device.set_base_prompt() - output = '' + current_prompt = self.device.find_prompt().strip() + terminating_char = current_prompt[-1] + pattern = r"[>#{}]\s*$".format(terminating_char) + # Look exclusively for trailing pattern that includes '#' and '>' + output = self.device.send_command_expect(cmd, expect_string=pattern) + # Reset base prompt in case hostname changed + self.device.set_base_prompt() return output def commit_config(self): @@ -407,9 +406,9 @@ def commit_config(self): else: cmd = 'configure replace {} force'.format(cfg_file) output = self._commit_hostname_handler(cmd) - if ('Failed to apply command' in output) or \ - ('original configuration has been successfully restored' in output) or \ - ('Error' in output): + if ('original configuration has been successfully restored' in output) or \ + ('error' in output.lower()) or \ + ('failed' in output.lower()): msg = "Candidate config could not be applied\n{}".format(output) raise ReplaceConfigException(msg) elif '%Please turn config archive on' in output: @@ -861,7 +860,7 @@ def get_facts(self): # default values. vendor = u'Cisco' uptime = -1 - serial_number, fqdn, os_version, hostname = (u'Unknown', u'Unknown', u'Unknown', u'Unknown') + serial_number, fqdn, os_version, hostname, domain_name = ('Unknown',) * 5 # obtain output from device show_ver = self._send_command('show version') @@ -965,18 +964,26 @@ def get_interfaces(self): interface_dict = {} for line in output.splitlines(): - interface_regex = r"^(\S+?)\s+is\s+(.+?),\s+line\s+protocol\s+is\s+(\S+)" - if re.search(interface_regex, line): - interface_match = re.search(interface_regex, line) - interface = interface_match.groups()[0] - status = interface_match.groups()[1] - protocol = interface_match.groups()[2] - - if 'admin' in status: - is_enabled = False - else: - is_enabled = True - is_up = bool('up' in protocol) + interface_regex_1 = r"^(\S+?)\s+is\s+(.+?),\s+line\s+protocol\s+is\s+(\S+)" + interface_regex_2 = r"^(\S+)\s+is\s+(up|down)" + for pattern in (interface_regex_1, interface_regex_2): + interface_match = re.search(pattern, line) + if interface_match: + interface = interface_match.group(1) + status = interface_match.group(2) + try: + protocol = interface_match.group(3) + except IndexError: + protocol = '' + if 'admin' in status.lower(): + is_enabled = False + else: + is_enabled = True + if protocol: + is_up = bool('up' in protocol) + else: + is_up = bool('up' in status) + break mac_addr_regex = r"^\s+Hardware.+address\s+is\s+({})".format(MAC_REGEX) if re.search(mac_addr_regex, line): @@ -1028,7 +1035,7 @@ def get_interfaces_ip(self): 'ipv6': { u'1::1': { 'prefix_length': 64}, u'2001:DB8:1::1': { 'prefix_length': 64}, u'2::': { 'prefix_length': 64}, - u'FE80::3': { 'prefix_length': u'N/A'}}}, + u'FE80::3': { 'prefix_length': 10}}}, u'Tunnel0': { 'ipv4': { u'10.63.100.9': { 'prefix_length': 24}}}, u'Tunnel1': { 'ipv4': { u'10.63.101.9': { 'prefix_length': 24}}}, u'Vlan100': { 'ipv4': { u'10.40.0.1': { 'prefix_length': 24}, @@ -1038,86 +1045,50 @@ def get_interfaces_ip(self): """ interfaces = {} - command = 'show ip interface brief' - output = self._send_command(command) - for line in output.splitlines(): - if 'Interface' in line and 'Status' in line: - continue - fields = line.split() - if len(fields) >= 3: - interface = fields[0] - else: - raise ValueError("Unexpected response from the router") - interfaces.update({interface: {}}) - - # Parse IP Address and Subnet Mask from Interfaces - for interface in interfaces: - show_command = "show run interface {0}".format(interface) - interface_output = self._send_command(show_command) - for line in interface_output.splitlines(): - if 'ip address ' in line and 'no ip address' not in line: - fields = line.split() - if len(fields) == 3: - # Check for 'ip address dhcp', convert to ip address and mask - if fields[2] == 'dhcp': - cmd = "show interface {} | in Internet address is".format(interface) - show_int = self._send_command(cmd) - if not show_int: - continue - int_fields = show_int.split() - ip_address, subnet = int_fields[3].split(r'/') - interfaces[interface]['ipv4'] = {ip_address: {}} - try: - val = {'prefix_length': int(subnet)} - except ValueError: - val = {'prefix_length': u'N/A'} - interfaces[interface]['ipv4'][ip_address] = val - elif len(fields) in [4, 5]: - # Check for 'ip address 10.10.10.1 255.255.255.0' - # Check for 'ip address 10.10.11.1 255.255.255.0 secondary' - if 'ipv4' not in interfaces[interface].keys(): - interfaces[interface].update({'ipv4': {}}) - ip_address = fields[2] - - try: - subnet = sum([bin(int(x)).count('1') for x in fields[3].split('.')]) - except ValueError: - subnet = u'N/A' - - ip_dict = {'prefix_length': subnet} - interfaces[interface]['ipv4'].update({ip_address: {}}) - interfaces[interface]['ipv4'][ip_address].update(ip_dict) - else: - raise ValueError(u"Unexpected Response from the device") - - # Check IPv6 - if 'ipv6 address ' in line: - fields = line.split() - ip_address = fields[2] - if 'ipv6' not in interfaces[interface].keys(): - interfaces[interface].update({'ipv6': {}}) - - try: - if r'/' in ip_address: - # check for 'ipv6 address 1::1/64' - ip_address, subnet = ip_address.split(r'/') - interfaces[interface]['ipv6'].update({ip_address: {}}) - ip_dict = {'prefix_length': int(subnet)} - else: - # check for 'ipv6 address FE80::3 link-local' - interfaces[interface]['ipv6'].update({ip_address: {}}) - ip_dict = {'prefix_length': u'N/A'} + command = 'show ip interface' + show_ip_interface = self._send_command(command) + command = 'show ipv6 interface' + show_ipv6_interface = self._send_command(command) - interfaces[interface]['ipv6'][ip_address].update(ip_dict) - except AttributeError: - raise ValueError(u"Unexpected Response from the device") + INTERNET_ADDRESS = r'\s+(?:Internet address is|Secondary address)' + INTERNET_ADDRESS += r' (?P{})/(?P\d+)'.format(IPV4_ADDR_REGEX) + LINK_LOCAL_ADDRESS = r'\s+IPv6 is enabled, link-local address is (?P[a-fA-F0-9:]+)' + GLOBAL_ADDRESS = r'\s+(?P[a-fA-F0-9:]+), subnet is (?:[a-fA-F0-9:]+)/(?P\d+)' - # remove keys with no data - new_interfaces = {} - for k, val in interfaces.items(): - if val: - new_interfaces[k] = val - return new_interfaces + interfaces = {} + for line in show_ip_interface.splitlines(): + if(len(line.strip()) == 0): + continue + if(line[0] != ' '): + ipv4 = {} + interface_name = line.split()[0] + m = re.match(INTERNET_ADDRESS, line) + if m: + ip, prefix = m.groups() + ipv4.update({ip: {"prefix_length": int(prefix)}}) + interfaces[interface_name] = {'ipv4': ipv4} + + for line in show_ipv6_interface.splitlines(): + if(len(line.strip()) == 0): + continue + if(line[0] != ' '): + ifname = line.split()[0] + ipv6 = {} + if ifname not in interfaces: + interfaces[ifname] = {'ipv6': ipv6} + else: + interfaces[ifname].update({'ipv6': ipv6}) + m = re.match(LINK_LOCAL_ADDRESS, line) + if m: + ip = m.group(1) + ipv6.update({ip: {"prefix_length": 10}}) + m = re.match(GLOBAL_ADDRESS, line) + if m: + ip, prefix = m.groups() + ipv6.update({ip: {"prefix_length": int(prefix)}}) + + # Interface without ipv6 doesn't appears in show ipv6 interface + return interfaces @staticmethod def bgp_time_conversion(bgp_uptime): @@ -1554,13 +1525,14 @@ def get_environment(self): """ Get environment facts. - power, fan, temperature are currently not implemented + power and fan are currently not implemented cpu is using 1-minute average cpu hard-coded to cpu0 (i.e. only a single CPU) """ environment = {} cpu_cmd = 'show proc cpu' mem_cmd = 'show memory statistics' + temp_cmd = 'show env temperature status' output = self._send_command(cpu_cmd) environment.setdefault('cpu', {}) @@ -1586,14 +1558,30 @@ def get_environment(self): environment['memory']['used_ram'] = used_mem environment['memory']['available_ram'] = free_mem - # Initialize 'power', 'fan', and 'temperature' to default values (not implemented) + environment.setdefault('temperature', {}) + # The 'show env temperature status' is not ubiquitous in Cisco IOS + output = self._send_command(temp_cmd) + if '% Invalid' not in output: + for line in output.splitlines(): + if 'System Temperature Value' in line: + system_temp = float(line.split(':')[1].split()[0]) + elif 'Yellow Threshold' in line: + system_temp_alert = float(line.split(':')[1].split()[0]) + elif 'Red Threshold' in line: + system_temp_crit = float(line.split(':')[1].split()[0]) + env_value = {'is_alert': system_temp >= system_temp_alert, + 'is_critical': system_temp >= system_temp_crit, 'temperature': system_temp} + environment['temperature']['system'] = env_value + else: + env_value = {'is_alert': False, 'is_critical': False, 'temperature': -1.0} + environment['temperature']['invalid'] = env_value + + # Initialize 'power' and 'fan' to default values (not implemented) environment.setdefault('power', {}) environment['power']['invalid'] = {'status': True, 'output': -1.0, 'capacity': -1.0} environment.setdefault('fans', {}) environment['fans']['invalid'] = {'status': True} - environment.setdefault('temperature', {}) - env_value = {'is_alert': False, 'is_critical': False, 'temperature': -1.0} - environment['temperature']['invalid'] = env_value + return environment def get_arp_table(self): diff --git a/requirements.txt b/requirements.txt index bcdb5aa..c361a7f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ napalm_base>=0.25.0 -netmiko>=1.4.2 +netmiko>=1.4.3 diff --git a/setup.py b/setup.py index 888b57f..f332637 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ setup( name="napalm-ios", - version="0.8.0", + version="0.8.1", packages=find_packages(), author="Kirk Byers", author_email="ktbyers@twb-tech.com", diff --git a/test/unit/mocked_data/test_get_environment/normal/expected_result.json b/test/unit/mocked_data/test_get_environment/normal/expected_result.json index 53dfc79..9eec34f 100644 --- a/test/unit/mocked_data/test_get_environment/normal/expected_result.json +++ b/test/unit/mocked_data/test_get_environment/normal/expected_result.json @@ -5,9 +5,9 @@ } }, "temperature": { - "invalid": { + "system": { "is_alert": false, - "temperature": -1.0, + "temperature": 42, "is_critical": false } }, diff --git a/test/unit/mocked_data/test_get_environment/normal/show_env_temperature_status.txt b/test/unit/mocked_data/test_get_environment/normal/show_env_temperature_status.txt new file mode 100644 index 0000000..29e9950 --- /dev/null +++ b/test/unit/mocked_data/test_get_environment/normal/show_env_temperature_status.txt @@ -0,0 +1,4 @@ +System Temperature Value: 42 Degree Celsius +System Temperature State: GREEN +Yellow Threshold : 88 Degree Celsius +Red Threshold : 93 Degree Celsius \ No newline at end of file diff --git a/test/unit/mocked_data/test_get_environment/temp_cmd_fail/expected_result.json b/test/unit/mocked_data/test_get_environment/temp_cmd_fail/expected_result.json new file mode 100644 index 0000000..53dfc79 --- /dev/null +++ b/test/unit/mocked_data/test_get_environment/temp_cmd_fail/expected_result.json @@ -0,0 +1,30 @@ +{ + "fans": { + "invalid": { + "status": true + } + }, + "temperature": { + "invalid": { + "is_alert": false, + "temperature": -1.0, + "is_critical": false + } + }, + "cpu": { + "0": { + "%usage": 6.0 + } + }, + "power": { + "invalid": { + "status": true, + "output": -1.0, + "capacity": -1.0 + } + }, + "memory": { + "available_ram": 4826256, + "used_ram": 20873476 + } +} diff --git a/test/unit/mocked_data/test_get_environment/temp_cmd_fail/show_env_temperature_status.txt b/test/unit/mocked_data/test_get_environment/temp_cmd_fail/show_env_temperature_status.txt new file mode 100644 index 0000000..d965dc6 --- /dev/null +++ b/test/unit/mocked_data/test_get_environment/temp_cmd_fail/show_env_temperature_status.txt @@ -0,0 +1,3 @@ + ^ +% Invalid input detected at '^' marker. + diff --git a/test/unit/mocked_data/test_get_environment/temp_cmd_fail/show_memory_statistics.txt b/test/unit/mocked_data/test_get_environment/temp_cmd_fail/show_memory_statistics.txt new file mode 100644 index 0000000..e081aaf --- /dev/null +++ b/test/unit/mocked_data/test_get_environment/temp_cmd_fail/show_memory_statistics.txt @@ -0,0 +1,4 @@ +Head Total(b) Used(b) Free(b) Lowest(b) Largest(b) +Processor 277B88C 21505428 18498044 3007384 2136352 2061756 +I/O 2C00000 4194304 2375432 1818872 1581372 1817552 +Driver te 18C0000 1048576 44 1048532 1048532 1048532 diff --git a/test/unit/mocked_data/test_get_environment/temp_cmd_fail/show_proc_cpu.txt b/test/unit/mocked_data/test_get_environment/temp_cmd_fail/show_proc_cpu.txt new file mode 100644 index 0000000..e67e6c5 --- /dev/null +++ b/test/unit/mocked_data/test_get_environment/temp_cmd_fail/show_proc_cpu.txt @@ -0,0 +1,300 @@ +CPU utilization for five seconds: 5%/0%; one minute: 6%; five minutes: 6% + PID Runtime(ms) Invoked uSecs 5Sec 1Min 5Min TTY Process + 1 9 193 46 0.00% 0.00% 0.00% 0 Chunk Manager + 2 5032 3335727 1 0.00% 0.00% 0.00% 0 Load Meter + 3 0 1 0 0.00% 0.00% 0.00% 0 Connection Mgr + 4 134047004 7159038 18724 0.00% 0.71% 0.74% 0 Check heaps + 5 333 277978 1 0.00% 0.00% 0.00% 0 Pool Manager + 6 0 1 0 0.00% 0.00% 0.00% 0 DiscardQ Backgro + 7 0 2 0 0.00% 0.00% 0.00% 0 Timers + 8 17 1565 10 0.00% 0.00% 0.00% 0 WATCH_AFS + 9 3304 273 12102 0.00% 0.00% 0.00% 0 crypto sw pk pro + 10 0 1 0 0.00% 0.00% 0.00% 0 Crash writer + 11 0 1 0 0.00% 0.00% 0.00% 0 Exception contro + 12 356620 1375208 259 0.00% 0.00% 0.00% 0 ARP Input + 13 11309 17323327 0 0.00% 0.00% 0.00% 0 ARP Background + 14 0 13113 0 0.00% 0.00% 0.00% 0 AAA_SERVER_DEADT + 15 0 1 0 0.00% 0.00% 0.00% 0 Policy Manager + 16 16 19 842 0.00% 0.00% 0.00% 0 Entity MIB API + 17 0 1 0 0.00% 0.00% 0.00% 0 IFS Agent Manage + 18 311 3330342 0 0.00% 0.00% 0.00% 0 IPC Event Notifi + 19 5811 16204770 0 0.00% 0.00% 0.00% 0 IPC Mcast Pendin + 20 92 277960 0 0.00% 0.00% 0.00% 0 IPC Dynamic Cach + 21 0 1 0 0.00% 0.00% 0.00% 0 IPC Session Serv + 22 0 1 0 0.00% 0.00% 0.00% 0 IPC Zone Manager + 23 6656 16204770 0 0.00% 0.00% 0.00% 0 IPC Periodic Tim + 24 6517 16204770 0 0.00% 0.00% 0.00% 0 IPC Deferred Por + 25 0 1 0 0.00% 0.00% 0.00% 0 IPC Process leve + 26 0 1 0 0.00% 0.00% 0.00% 0 IPC Seat Manager + 27 107 952671 0 0.00% 0.00% 0.00% 0 IPC Check Queue + 28 0 1 0 0.00% 0.00% 0.00% 0 IPC Seat RX Cont + 29 0 1 0 0.00% 0.00% 0.00% 0 IPC Seat TX Cont + 30 760 1667867 0 0.00% 0.00% 0.00% 0 IPC Keep Alive M + 31 723 3330345 0 0.00% 0.00% 0.00% 0 IPC Loadometer + 32 116 7 16571 0.00% 0.00% 0.00% 0 PrstVbl + 33 0 2 0 0.00% 0.00% 0.00% 0 XML Proxy Client + 34 1641 16564383 0 0.00% 0.00% 0.00% 0 Dynamic ARP Insp + 35 0 1 0 0.00% 0.00% 0.00% 0 ARP Snoop + 36 0 2 0 0.00% 0.00% 0.00% 0 SMART + 37 8633 16678628 0 0.00% 0.00% 0.00% 0 GraphIt + 38 0 1 0 0.00% 0.00% 0.00% 0 Critical Bkgnd + 39 682024 2001479 340 0.00% 0.00% 0.00% 0 Net Background + 40 0 1 0 0.00% 0.00% 0.00% 0 IDB Work + 41 121 47135 2 0.00% 0.00% 0.00% 0 Logger + 42 1658 16564357 0 0.00% 0.00% 0.00% 0 TTY Background + 43 9 7 1285 0.00% 0.00% 0.00% 0 IF-MGR control p + 44 0 8261 0 0.00% 0.00% 0.00% 0 IF-MGR event pro + 45 57198 993179 57 0.00% 0.00% 0.00% 0 Net Input + 46 23197 3335729 6 0.00% 0.00% 0.00% 0 Compute load avg + 47 6996691 556361 12575 0.00% 0.02% 0.00% 0 Per-minute Jobs + 48 50567 16678656 3 0.00% 0.00% 0.00% 0 Per-Second Jobs + 49 0 1 0 0.00% 0.00% 0.00% 0 AggMgr Process + 50 0 111 0 0.00% 0.00% 0.00% 0 Transport Port A + 51 29202 4993423 5 0.00% 0.00% 0.00% 0 HC Counter Timer + 52 0 1 0 0.00% 0.00% 0.00% 0 SFF8472 + 53 31825 330492090 0 0.00% 0.00% 0.00% 0 DownWhenLooped + 54 0 1 0 0.00% 0.00% 0.00% 0 HULC ACL Tcam Me + 55 0 1 0 0.00% 0.00% 0.00% 0 HRPC lpip reques + 56 0 2 0 0.00% 0.00% 0.00% 0 HLPIP Sync Proce + 57 0 1 0 0.00% 0.00% 0.00% 0 HRPC EnergyWise + 58 0 1 0 0.00% 0.00% 0.00% 0 HRPC actual powe + 59 345 555839 0 0.00% 0.00% 0.00% 0 PSP Timer + 60 0 1 0 0.00% 0.00% 0.00% 0 HULC QM Tcam Mem + 61 24520370 219209 111858 0.00% 0.01% 0.09% 0 Authenticate Pro + 62 0 1 0 0.00% 0.00% 0.00% 0 HULC PBR Tcam Me + 63 17 17023 0 0.00% 0.00% 0.00% 0 EEM ED ND + 64 0 18 0 0.00% 0.00% 0.00% 0 EEM ED Identity + 65 9 35 257 0.00% 0.00% 0.00% 0 EEM ED MAT + 66 0 5 0 0.00% 0.00% 0.00% 0 HL2MCM + 67 9 5 1800 0.00% 0.00% 0.00% 0 HL2MCM + 68 0 1 0 0.00% 0.00% 0.00% 0 HRPC asic-stats + 69 0 1 0 0.00% 0.00% 0.00% 0 HRPC hsm request + 70 0 7 0 0.00% 0.00% 0.00% 0 Stack Mgr + 71 67 7 9571 0.00% 0.00% 0.00% 0 Stack Mgr Notifi + 72 1146328 885749250 1 0.00% 0.00% 0.00% 0 Fifo Error Detec + 73 16 9 1777 0.00% 0.00% 0.00% 0 Adjust Regions + 74 12126 8317697 1 0.00% 0.00% 0.00% 0 hrpc -> response + 75 0 19 0 0.00% 0.00% 0.00% 0 hrpc -> request + 76 3012 2776764 1 0.00% 0.00% 0.00% 0 hrpc <- response + 77 0 1 0 0.00% 0.00% 0.00% 0 HRPC hcomp reque + 78 8 3 2666 0.00% 0.00% 0.00% 0 HULC Device Mana + 79 0 3 0 0.00% 0.00% 0.00% 0 HRPC hdm non blo + 80 0 2 0 0.00% 0.00% 0.00% 0 HRPC hdm blockin + 81 555 3330338 0 0.00% 0.00% 0.00% 0 HIPC bkgrd proce + 82 2914 16720 174 0.00% 0.00% 0.00% 0 Hulc Port-Securi + 83 0 1 0 0.00% 0.00% 0.00% 0 HRPC hpsecure re + 84 0 1 0 0.00% 0.00% 0.00% 0 HRPC hlfm reques + 85 393285 494966923 0 0.00% 0.00% 0.00% 0 HLFM address lea + 86 1831 16564362 0 0.00% 0.00% 0.00% 0 HLFM aging proce + 87 338212 495218973 0 0.00% 0.00% 0.00% 0 HLFM address ret + 88 0 1 0 0.00% 0.00% 0.00% 0 HRPC hulc misc r + 89 1392348 1666770 835 0.15% 0.01% 0.00% 0 HULC Tcam Memory + 90 5930 5553243 1 0.00% 0.00% 0.00% 0 HVLAN main bkgrd + 91 0 2 0 0.00% 0.00% 0.00% 0 HVLAN Mapped Vla + 92 0 2 0 0.00% 0.00% 0.00% 0 Vlan shutdown Pr + 93 0 3 0 0.00% 0.00% 0.00% 0 HRPC vlan reques + 94 0 1 0 0.00% 0.00% 0.00% 0 HULC VLAN REF Ba + 95 0 1 0 0.00% 0.00% 0.00% 0 HRPC ilp request + 96 0 1 0 0.00% 0.00% 0.00% 0 HULC PM Vector P + 97 0 1 0 0.00% 0.00% 0.00% 0 HPM Msg Retry Pr + 98 1410 4302 327 0.00% 0.00% 0.00% 0 SpanTree Helper + 99 172886 33130161 5 0.00% 0.00% 0.00% 0 hpm main process + 100 41 17040 2 0.00% 0.00% 0.00% 0 HPM Stack Sync P + 101 0 1 0 0.00% 0.00% 0.00% 0 HRPC pm request + 102 179346 16678629 10 0.00% 0.00% 0.00% 0 hpm counter proc + 103 0 1 0 0.00% 0.00% 0.00% 0 HRPC pm-counters + 104 0 1 0 0.00% 0.00% 0.00% 0 hpm vp events ca + 105 0 1 0 0.00% 0.00% 0.00% 0 HRPC hcmp reques + 106 0 1 0 0.00% 0.00% 0.00% 0 HACL Queue Proce + 107 0 1 0 0.00% 0.00% 0.00% 0 HRPC acl request + 108 9 107 84 0.00% 0.00% 0.00% 0 HACL Acl Manager + 109 0 1 0 0.00% 0.00% 0.00% 0 HRPC backup inte + 110 2185 281 7775 0.00% 0.08% 0.31% 1 SSH Process + 111 0 1 0 0.00% 0.00% 0.00% 0 HRPC cdp request + 112 0 1 0 0.00% 0.00% 0.00% 0 HULC CISP Proces + 113 0 1 0 0.00% 0.00% 0.00% 0 HRPC lldp reques + 114 0 1 0 0.00% 0.00% 0.00% 0 HRPC dot1x reque + 115 0 3 0 0.00% 0.00% 0.00% 0 HULC DOT1X Proce + 116 0 1 0 0.00% 0.00% 0.00% 0 HRPC system mtu + 117 0 1 0 0.00% 0.00% 0.00% 0 SMI MSG Retry Pr + 118 0 1 0 0.00% 0.00% 0.00% 0 HRPC Smart Insta + 119 0 1 0 0.00% 0.00% 0.00% 0 HRPC sdm request + 120 58881 82734029 0 0.00% 0.00% 0.00% 0 Hulc Storm Contr + 121 0 2 0 0.00% 0.00% 0.00% 0 HSTP Sync Proces + 122 0 1 0 0.00% 0.00% 0.00% 0 HRPC stp_cli req + 123 0 1 0 0.00% 0.00% 0.00% 0 HRPC stp_state_s + 124 0 2 0 0.00% 0.00% 0.00% 0 S/W Bridge Proce + 125 0 1 0 0.00% 0.00% 0.00% 0 HRPC hudld reque + 126 0 1 0 0.00% 0.00% 0.00% 0 HRPC vqpc reques + 127 0 1 0 0.00% 0.00% 0.00% 0 HRPC aim request + 128 366 7951 46 0.00% 0.00% 0.00% 0 HCEF ADJ Refresh + 129 0 1 0 0.00% 0.00% 0.00% 0 HRPC hled reques + 130 1451588 416433725 3 0.00% 0.00% 0.00% 0 Hulc LED Process + 131 140072 12201333 11 0.00% 0.00% 0.00% 0 HL3U bkgrd proce + 132 0 1 0 0.00% 0.00% 0.00% 0 HRPC hl3u reques + 133 21578 3808338 5 0.00% 0.00% 0.00% 0 HIPV6 bkgrd proc + 134 0 1 0 0.00% 0.00% 0.00% 0 HRPC IPv6 Unicas + 135 3376 3808616 0 0.00% 0.00% 0.00% 0 HL3U PBR bkgrd p + 136 145 138981 1 0.00% 0.00% 0.00% 0 HL3U PBR n-h res + 137 0 1 0 0.00% 0.00% 0.00% 0 HRPC dtp request + 138 0 1 0 0.00% 0.00% 0.00% 0 HRPC show_forwar + 139 0 1 0 0.00% 0.00% 0.00% 0 HRPC snmp reques + 140 0 1 0 0.00% 0.00% 0.00% 0 HULC SNMP Proces + 141 14659 3330353 4 0.00% 0.00% 0.00% 0 HQM Stack Proces + 142 101856 6660687 15 0.00% 0.00% 0.00% 0 HRPC qos request + 143 0 1 0 0.00% 0.00% 0.00% 0 HRPC span reques + 144 0 1 0 0.00% 0.00% 0.00% 0 HRPC system post + 145 0 1 0 0.00% 0.00% 0.00% 0 Hulc Reload Mana + 146 0 1 0 0.00% 0.00% 0.00% 0 HRPC hrcli-event + 147 0 2 0 0.00% 0.00% 0.00% 0 image mgr + 148 895 277979 3 0.00% 0.00% 0.00% 0 HULC Pilsner The + 149 58605 16564360 3 0.00% 0.00% 0.00% 0 PI MATM Aging Pr + 150 0 2 0 0.00% 0.00% 0.00% 0 Switch Backup In + 151 182 277959 0 0.00% 0.00% 0.00% 0 MMN bkgrd proces + 152 20949 16250853 1 0.00% 0.00% 0.00% 0 Auth Manager + 153 0 1 0 0.00% 0.00% 0.00% 0 AUTH POLICY Fram + 154 0 2 0 0.00% 0.00% 0.00% 0 Dot1x Mgr Proces + 155 142268 12544 11341 0.00% 0.00% 0.00% 0 802.1x switch + 156 0 1 0 0.00% 0.00% 0.00% 0 802.1x Webauth F + 157 6464 1667546 3 0.00% 0.00% 0.00% 0 DTP Protocol + 158 0 1 0 0.00% 0.00% 0.00% 0 EAP Framework + 159 0 1 0 0.00% 0.00% 0.00% 0 EAP Test + 160 0 1 0 0.00% 0.00% 0.00% 0 HRPC IPv6 Host r + 161 0 2 0 0.00% 0.00% 0.00% 0 IPv6 Platform Ho + 162 0 1 0 0.00% 0.00% 0.00% 0 HRPC dai request + 163 2060989 7151117 288 0.00% 0.00% 0.00% 0 HULC DAI Process + 164 0 1 0 0.00% 0.00% 0.00% 0 HRPC ip device t + 165 0 1 0 0.00% 0.00% 0.00% 0 HRPC ip source g + 166 0 1 0 0.00% 0.00% 0.00% 0 HULC IP Source g + 167 37411 166652517 0 0.00% 0.00% 0.00% 0 UDLD + 168 341 555955 0 0.00% 0.00% 0.00% 0 Port-Security + 169 3941 8361 471 0.00% 0.00% 0.00% 0 IP Host Track Pr + 170 0 1 0 0.00% 0.00% 0.00% 0 Link State Group + 171 1673 6271 266 0.00% 0.00% 0.00% 0 VMATM Callback + 172 0 2 0 0.00% 0.00% 0.00% 0 CMD HANDLER + 173 0 2 0 0.00% 0.00% 0.00% 0 CEF switching ba + 174 0 1 0 0.00% 0.00% 0.00% 0 ADJ NSF process + 175 0 1 0 0.00% 0.00% 0.00% 0 HRPC sisf reques + 176 0 2 0 0.00% 0.00% 0.00% 0 HULC SISF Proces + 177 0 1 0 0.00% 0.00% 0.00% 0 HULC SISF Source + 178 0 171 0 0.00% 0.00% 0.00% 0 AAA Server + 179 8286 32674 253 0.00% 0.00% 0.00% 0 AAA ACCT Proc + 180 0 1 0 0.00% 0.00% 0.00% 0 ACCT Periodic Pr + 181 0 1 0 0.00% 0.00% 0.00% 0 AAA System Acct + 182 0 1 0 0.00% 0.00% 0.00% 0 Auth-proxy AAA B + 183 74 55596 1 0.00% 0.00% 0.00% 0 IP Admin SM Proc + 184 45733 2643616 17 0.00% 0.00% 0.00% 0 CDP Protocol + 185 719 2095 343 0.00% 0.00% 0.00% 0 SpanTree Flush + 186 0 13113 0 0.00% 0.00% 0.00% 0 Critical Auth + 187 0 2 0 0.00% 0.00% 0.00% 0 AAA Dictionary R + 188 184 138989 1 0.00% 0.00% 0.00% 0 DHCP Snooping + 189 0 1 0 0.00% 0.00% 0.00% 0 DHCP Snooping db + 190 17 249 68 0.00% 0.00% 0.00% 0 IP ARP Adjacency + 191 301220 494966993 0 0.00% 0.00% 0.00% 0 IP ARP Retry Age + 192 2140263 8161932 262 0.00% 0.01% 0.02% 0 IP Input + 193 0 1 0 0.00% 0.00% 0.00% 0 ICMP event handl + 194 12564 32182298 0 0.00% 0.00% 0.00% 0 IP ARP Track + 195 0 1 0 0.00% 0.00% 0.00% 0 IPv6 ping proces + 196 32067 15112649 2 0.00% 0.00% 0.00% 0 NTP + 197 0 13 0 0.00% 0.00% 0.00% 0 SMI Director DB + 198 0 244 0 0.00% 0.00% 0.00% 0 SMI CDP Update H + 199 0 1 0 0.00% 0.00% 0.00% 0 SMI Backup Proce + 200 0 2 0 0.00% 0.00% 0.00% 0 SMI IBC server p + 201 0 1 0 0.00% 0.00% 0.00% 0 SMI IBC client p + 202 0 2 0 0.00% 0.00% 0.00% 0 SMI IBC Download + 203 2851721 57269407 49 0.00% 0.00% 0.00% 0 Spanning Tree + 204 82 277963 0 0.00% 0.00% 0.00% 0 Spanning Tree St + 205 1090 1666774 0 0.00% 0.00% 0.00% 0 Ethchnl + 206 235 4846 48 0.15% 0.01% 0.00% 0 TCP Timer + 207 25 108 231 0.00% 0.00% 0.00% 0 TCP Protocols + 208 0 1 0 0.00% 0.00% 0.00% 0 Socket Timers + 209 118 55605 2 0.00% 0.00% 0.00% 0 HTTP CORE + 210 132 208479 0 0.00% 0.00% 0.00% 0 Cluster L2 + 211 1309 1666772 0 0.00% 0.00% 0.00% 0 Cluster RARP + 212 1979 2084109 0 0.00% 0.00% 0.00% 0 Cluster Base + 213 790 338380 2 0.00% 0.00% 0.00% 0 CEF background p + 214 0 1 0 0.00% 0.00% 0.00% 0 fib_fib_bfd_sb e + 215 0 1 0 0.00% 0.00% 0.00% 0 IP IRDP + 216 0 3 0 0.00% 0.00% 0.00% 0 RARP Input + 217 0 2 0 0.00% 0.00% 0.00% 0 Dot1x Supplicant + 218 0 2 0 0.00% 0.00% 0.00% 0 Dot1x Supplicant + 219 0 2 0 0.00% 0.00% 0.00% 0 Dot1x Supplicant + 220 0 1 0 0.00% 0.00% 0.00% 0 MAB Framework + 221 0 1 0 0.00% 0.00% 0.00% 0 HRPC dhcp snoopi + 222 0 4 0 0.00% 0.00% 0.00% 0 HULC DHCP Snoopi + 223 1053 8884 118 0.00% 0.00% 0.00% 0 IGMPSN L2MCM + 224 0 1 0 0.00% 0.00% 0.00% 0 IGMPSN MRD + 225 110843 271956 407 0.00% 0.00% 0.00% 0 IGMPSN + 226 0 1 0 0.00% 0.00% 0.00% 0 IGMPQR + 227 8 3 2666 0.00% 0.00% 0.00% 0 L2TRACE SERVER + 228 1322 8881 148 0.00% 0.00% 0.00% 0 MLDSN L2MCM + 229 0 1 0 0.00% 0.00% 0.00% 0 MRD + 230 0 1 0 0.00% 0.00% 0.00% 0 MLD_SNOOP + 231 0 2 0 0.00% 0.00% 0.00% 0 Routing Topology + 232 75632 25899567 2 0.00% 0.00% 0.00% 0 CEF: IPv4 proces + 233 0 2 0 0.00% 0.00% 0.00% 0 ADJ background + 234 0 3 0 0.00% 0.00% 0.00% 0 ADJ resolve proc + 235 26 7 3714 0.00% 0.00% 0.00% 0 IP RIB Update + 236 0 7 0 0.00% 0.00% 0.00% 0 Collection proce + 237 323 9268 34 0.00% 0.00% 0.00% 0 NIST rng proc + 238 0 6 0 0.00% 0.00% 0.00% 0 static + 239 0 1 0 0.00% 0.00% 0.00% 0 IPv6 RIB Event H + 240 3504 1666772 2 0.00% 0.00% 0.00% 0 QoS stats proces + 241 0 14 0 0.00% 0.00% 0.00% 0 SNMP Timers + 242 0 2 0 0.00% 0.00% 0.00% 0 TPLUS + 243 35 92660 0 0.00% 0.00% 0.00% 0 HCMP sync proces + 244 0 1 0 0.00% 0.00% 0.00% 0 EPM MAIN PROCESS + 245 0 2 0 0.00% 0.00% 0.00% 0 AAA Cached Serve + 246 168 987 170 0.00% 0.00% 0.00% 0 LOCAL AAA + 247 0 2 0 0.00% 0.00% 0.00% 0 ENABLE AAA + 248 0 2 0 0.00% 0.00% 0.00% 0 LINE AAA + 249 0 3 0 0.00% 0.00% 0.00% 0 LDAP process + 250 2225160 7746493 287 0.00% 0.00% 0.00% 0 IP SNMP + 251 0 1 0 0.00% 0.00% 0.00% 0 HRPC hl2mcm igmp + 252 0 1 0 0.00% 0.00% 0.00% 0 HRPC hl2mcm mlds + 253 0 1 0 0.00% 0.00% 0.00% 0 HRPC x_setup req + 254 0 2 0 0.00% 0.00% 0.00% 0 crypto engine pr + 255 0 1 0 0.00% 0.00% 0.00% 0 encrypt proc + 256 226 4 56500 0.00% 0.00% 0.00% 0 Crypto CA + 257 0 1 0 0.00% 0.00% 0.00% 0 Crypto PKI-CRL + 258 0 84 0 0.00% 0.00% 0.00% 0 VTP Trap Process + 259 324 27686 11 0.00% 0.00% 0.00% 0 ASP Process Crea + 260 0 2 0 0.00% 0.00% 0.00% 0 DHCP Security He + 261 0 1 0 0.00% 0.00% 0.00% 0 HCD Process + 262 0 1 0 0.00% 0.00% 0.00% 0 HRPC cable diagn + 263 539444 3871826 139 0.00% 0.00% 0.00% 0 PDU DISPATCHER + 264 20304 17313372 1 0.00% 0.00% 0.00% 0 PM Callback + 265 329 1333536 0 0.00% 0.00% 0.00% 0 dhcp snooping sw + 266 0 2 0 0.00% 0.00% 0.00% 0 DiagCard1/-1 + 267 1542 29621 52 0.00% 0.00% 0.00% 0 AAA SEND STOP EV + 268 0 1 0 0.00% 0.00% 0.00% 0 Test AAA Client + 269 0 1 0 0.00% 0.00% 0.00% 0 Syslog Traps + 270 862 277959 3 0.00% 0.00% 0.00% 0 RADIUS IO STATS + 271 0 1 0 0.00% 0.00% 0.00% 0 Online Diag EEM + 272 17 29 586 0.00% 0.00% 0.00% 0 EEM Server + 273 0 2 0 0.00% 0.00% 0.00% 0 EEM Policy Direc + 274 6622343 3871987 1710 0.00% 0.00% 0.04% 0 SNMP ENGINE + 275 0 2 0 0.00% 0.00% 0.00% 0 EEM ED OIR + 276 519 434771 1 0.00% 0.00% 0.00% 0 EEM ED Timer + 277 169 26358 6 0.00% 0.00% 0.00% 0 Syslog + 278 0 2 0 0.00% 0.00% 0.00% 0 STP FAST TRANSIT + 279 0 2 0 0.00% 0.00% 0.00% 0 CSRT RAPID TRANS + 280 16 2 8000 0.00% 0.00% 0.00% 0 Call Home proces + 281 0 2 0 0.00% 0.00% 0.00% 0 EEM ED Test + 282 0 3 0 0.00% 0.00% 0.00% 0 EEM ED Config + 283 0 3 0 0.00% 0.00% 0.00% 0 EEM ED Env + 284 0 3 0 0.00% 0.00% 0.00% 0 EM ED GOLD + 285 25 29 862 0.00% 0.00% 0.00% 0 VLAN Manager + 286 236 277959 0 0.00% 0.00% 0.00% 0 Call Home Timer + 287 8 4635 1 0.00% 0.00% 0.00% 0 SSH Event handle + 288 8 1 8000 0.00% 0.00% 0.00% 0 IP SNMPV6 + 289 0 1 0 0.00% 0.00% 0.00% 0 SNMP ConfCopyPro + 290 17 2843 5 0.00% 0.00% 0.00% 0 SNMP Traps + 291 1107 200 5535 0.00% 0.30% 0.24% 2 SSH Process + 294 0 3 0 0.00% 0.00% 0.00% 0 RADIUS POD SERVE + 295 340 286318 1 0.00% 0.00% 0.00% 0 IP Background + 296 52 12500 4 0.00% 0.00% 0.00% 0 IP Connected Rou + 297 0 2 0 0.00% 0.00% 0.00% 0 Dot1x Authentica + 298 0 2 0 0.00% 0.00% 0.00% 0 Dot1x Authentica + 300 23889 3909607 6 0.00% 0.00% 0.00% 0 LLDP Protocol + 302 12657 195517 64 0.00% 0.00% 0.00% 0 RADIUS diff --git a/test/unit/mocked_data/test_get_facts/empty_show_hosts/expected_result.json b/test/unit/mocked_data/test_get_facts/empty_show_hosts/expected_result.json new file mode 100644 index 0000000..bb9a0a2 --- /dev/null +++ b/test/unit/mocked_data/test_get_facts/empty_show_hosts/expected_result.json @@ -0,0 +1,10 @@ +{ + "os_version": "C2960 Software (C2960-LANBASEK9-M), Version 15.0(2)SE4, RELEASE SOFTWARE (fc1)", + "uptime": 16676160, + "interface_list": ["Vlan1", "Vlan20", "Vlan40", "Vlan41", "GigabitEthernet0/1", "GigabitEthernet0/2", "GigabitEthernet0/3", "GigabitEthernet0/4", "GigabitEthernet0/5", "GigabitEthernet0/6", "GigabitEthernet0/7", "GigabitEthernet0/8", "Port-channel1"], + "vendor": "Cisco", + "serial_number": "FOC1308V5NB", + "model": "WS-C2960G-8TC-L", + "hostname": "NS2903-ASW-01", + "fqdn": "Unknown" +} diff --git a/test/unit/mocked_data/test_get_facts/empty_show_hosts/show_hosts.txt b/test/unit/mocked_data/test_get_facts/empty_show_hosts/show_hosts.txt new file mode 100644 index 0000000..e69de29 diff --git a/test/unit/mocked_data/test_get_facts/empty_show_hosts/show_ip_interface_brief.txt b/test/unit/mocked_data/test_get_facts/empty_show_hosts/show_ip_interface_brief.txt new file mode 100644 index 0000000..124222b --- /dev/null +++ b/test/unit/mocked_data/test_get_facts/empty_show_hosts/show_ip_interface_brief.txt @@ -0,0 +1,14 @@ +Interface IP-Address OK? Method Status Protocol +Vlan1 unassigned YES NVRAM administratively down down +Vlan20 172.29.50.3 YES NVRAM up up +Vlan40 unassigned YES unset up up +Vlan41 172.29.52.34 YES NVRAM up up +GigabitEthernet0/1 unassigned YES unset up up +GigabitEthernet0/2 unassigned YES unset up up +GigabitEthernet0/3 unassigned YES unset up up +GigabitEthernet0/4 unassigned YES unset down down +GigabitEthernet0/5 unassigned YES unset up up +GigabitEthernet0/6 unassigned YES unset up up +GigabitEthernet0/7 unassigned YES unset up up +GigabitEthernet0/8 unassigned YES unset up up +Port-channel1 unassigned YES unset administratively down down diff --git a/test/unit/mocked_data/test_get_facts/empty_show_hosts/show_version.txt b/test/unit/mocked_data/test_get_facts/empty_show_hosts/show_version.txt new file mode 100644 index 0000000..bc64acd --- /dev/null +++ b/test/unit/mocked_data/test_get_facts/empty_show_hosts/show_version.txt @@ -0,0 +1,59 @@ +Cisco IOS Software, C2960 Software (C2960-LANBASEK9-M), Version 15.0(2)SE4, RELEASE SOFTWARE (fc1) +Technical Support: http://www.cisco.com/techsupport +Copyright (c) 1986-2013 by Cisco Systems, Inc. +Compiled Wed 26-Jun-13 02:49 by prod_rel_team + +ROM: Bootstrap program is C2960 boot loader +BOOTLDR: C2960 Boot Loader (C2960-HBOOT-M) Version 12.2(35r)SE2, RELEASE SOFTWARE (fc1) + +NS2903-ASW-01 uptime is 27 weeks, 4 days, 16 minutes +System returned to ROM by power-on +System restarted at 15:46:58 UTC Sun May 22 2016 +System image file is "flash:/c2960-lanbasek9-mz.150-2.SE4.bin" + + +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 +export@cisco.com. + +cisco WS-C2960G-8TC-L (PowerPC405) processor (revision A0) with 65536K bytes of memory. +Processor board ID FOC1308V5NB +Last reset from power-on +4 Virtual Ethernet interfaces +8 Gigabit Ethernet interfaces +The password-recovery mechanism is enabled. + +64K bytes of flash-simulated non-volatile configuration memory. +Base ethernet MAC Address : 00:24:F7:DD:77:00 +Motherboard assembly number : 73-10613-08 +Power supply part number : 341-0208-01 +Motherboard serial number : FOC13083EGE +Power supply serial number : LIT1250099N +Model revision number : A0 +Motherboard revision number : B0 +Model number : WS-C2960G-8TC-L +System serial number : FOC1308V5NB +Top Assembly Part Number : 800-28133-01 +Top Assembly Revision Number : E0 +Version ID : V01 +CLEI Code Number : COM7S00ARA +Hardware Board Revision Number : 0x01 + + +Switch Ports Model SW Version SW Image +------ ----- ----- ---------- ---------- +* 1 8 WS-C2960G-8TC-L 15.0(2)SE4 C2960-LANBASEK9-M + + +Configuration register is 0xF diff --git a/test/unit/mocked_data/test_get_interfaces/pseudowire/expected_result.json b/test/unit/mocked_data/test_get_interfaces/pseudowire/expected_result.json new file mode 100644 index 0000000..8e83a00 --- /dev/null +++ b/test/unit/mocked_data/test_get_interfaces/pseudowire/expected_result.json @@ -0,0 +1,10 @@ +{ + "pseudowire100006": { + "speed": 10000, + "mac_address": "", + "is_up": true, + "last_flapped": -1.0, + "description": "", + "is_enabled": true + } +} diff --git a/test/unit/mocked_data/test_get_interfaces/pseudowire/show_interfaces.txt b/test/unit/mocked_data/test_get_interfaces/pseudowire/show_interfaces.txt new file mode 100644 index 0000000..d4315f2 --- /dev/null +++ b/test/unit/mocked_data/test_get_interfaces/pseudowire/show_interfaces.txt @@ -0,0 +1,8 @@ +pseudowire100006 is up + MTU 1500 bytes, BW 10000000 Kbit + Encapsulation mpls + Peer IP x.x.x.x, VC ID xx + RX + 34216908 packets 6774108588 bytes 0 drops + TX + 79234824 packets 23633885654 bytes 0 drops diff --git a/test/unit/mocked_data/test_get_interfaces_ip/normal/expected_result.json b/test/unit/mocked_data/test_get_interfaces_ip/normal/expected_result.json index cbc1e60..b1cf7cc 100644 --- a/test/unit/mocked_data/test_get_interfaces_ip/normal/expected_result.json +++ b/test/unit/mocked_data/test_get_interfaces_ip/normal/expected_result.json @@ -4,6 +4,14 @@ "172.29.50.3": { "prefix_length": 27 } + }, + "ipv6": { + "FE80::C009:24FF:FEAC:0": { + "prefix_length": 10 + }, + "2002::1": { + "prefix_length": 64 + } } }, "Vlan41": { @@ -15,5 +23,12 @@ "prefix_length": 24 } } + }, + "Loopback0": { + "ipv6": { + "FE80::C009:24FF:FEAC:0": {"prefix_length": 10}, + "2001::1": {"prefix_length": 128}, + "2001::2": {"prefix_length": 128} + } } } diff --git a/test/unit/mocked_data/test_get_interfaces_ip/normal/show_ip_interface.txt b/test/unit/mocked_data/test_get_interfaces_ip/normal/show_ip_interface.txt new file mode 100644 index 0000000..afcc8b6 --- /dev/null +++ b/test/unit/mocked_data/test_get_interfaces_ip/normal/show_ip_interface.txt @@ -0,0 +1,87 @@ +Vlan20 is up, line protocol is up + Internet address is 172.29.50.3/27 + Broadcast address is 255.255.255.255 + Address determined by non-volatile memory + MTU is 1500 bytes + Helper addresses are 172.16.0.1 + 192.168.1.1 + Directed broadcast forwarding is enabled + Multicast reserved groups joined: 224.0.0.102 224.0.0.5 224.0.0.6 + Outgoing access list is not set + Inbound access list is not set + Proxy ARP is disabled + Local Proxy ARP is disabled + Security level is default + Split horizon is enabled + ICMP redirects are never sent + ICMP unreachables are never sent + ICMP mask replies are never sent + IP fast switching is enabled + IP Flow switching is disabled + IP CEF switching is enabled + IP CEF switching turbo vector + IP Null turbo vector + Associated unicast routing topologies: + Topology "base", operation state is UP + IP multicast fast switching is enabled + IP multicast distributed fast switching is disabled + IP route-cache flags are Fast, CEF + Router Discovery is disabled + IP output packet accounting is disabled + IP access violation accounting is disabled + TCP/IP header compression is disabled + RTP/IP header compression is disabled + Probe proxy name replies are disabled + Policy routing is disabled + Network address translation is disabled + BGP Policy Mapping is disabled + Input features: MCI Check + Output features: IP Post Routing Processing, HW Shortcut Installation + Post encapsulation features: MTU Processing, IP Protocol Output Counter, IP Sendself Check, HW Shortcut Installation + Sampled Netflow is disabled + IP Routed Flow creation is disabled in netflow table + IP Bridged Flow creation is disabled in netflow table + IPv4 WCCP Redirect outbound is disabled + IPv4 WCCP Redirect inbound is disabled + IPv4 WCCP Redirect exclude is disabled + IP multicast multilayer switching is disabled +GigabitEthernet1/1 is down, line protocol is down +GigabitEthernet1/2 is down, line protocol is down +GigabitEthernet1/3 is administratively down, line protocol is down + Internet protocol processing disabled +Vlan41 is up, line protocol is up + Internet address is 172.29.52.34/27 + Broadcast address is 255.255.255.255 + Address determined by non-volatile memory + MTU is 1514 bytes + Helper address is not set + Directed broadcast forwarding is disabled + Secondary address 192.168.81.34/24 + Outgoing access list is not set + Inbound access list is not set + Proxy ARP is enabled + Local Proxy ARP is disabled + Security level is default + Split horizon is enabled + ICMP redirects are always sent + ICMP unreachables are always sent + ICMP mask replies are never sent + IP fast switching is enabled + IP fast switching on the same interface is disabled + IP Flow switching is disabled + IP CEF switching is enabled + IP CEF Fast switching turbo vector + IP multicast fast switching is enabled + IP multicast distributed fast switching is disabled + IP route-cache flags are Fast, CEF + Router Discovery is disabled + IP output packet accounting is disabled + IP access violation accounting is disabled + TCP/IP header compression is disabled + RTP/IP header compression is disabled + Policy routing is disabled + Network address translation is disabled + BGP Policy Mapping is disabled + WCCP Redirect outbound is disabled + WCCP Redirect inbound is disabled + WCCP Redirect exclude is disabled diff --git a/test/unit/mocked_data/test_get_interfaces_ip/normal/show_ip_interface_brief.txt b/test/unit/mocked_data/test_get_interfaces_ip/normal/show_ip_interface_brief.txt deleted file mode 100644 index 804c8db..0000000 --- a/test/unit/mocked_data/test_get_interfaces_ip/normal/show_ip_interface_brief.txt +++ /dev/null @@ -1,6 +0,0 @@ -Interface IP-Address OK? Method Status Protocol -Vlan20 172.29.50.3 YES NVRAM up up -Vlan40 unassigned YES unset up up -Vlan41 172.29.52.34 YES NVRAM up up -GigabitEthernet0/5 unassigned YES unset up up -Port-channel1 unassigned YES unset administratively down down diff --git a/test/unit/mocked_data/test_get_interfaces_ip/normal/show_ipv6_interface.txt b/test/unit/mocked_data/test_get_interfaces_ip/normal/show_ipv6_interface.txt new file mode 100644 index 0000000..9a88352 --- /dev/null +++ b/test/unit/mocked_data/test_get_interfaces_ip/normal/show_ipv6_interface.txt @@ -0,0 +1,30 @@ +Vlan20 is administratively down, line protocol is down + IPv6 is enabled, link-local address is FE80::C009:24FF:FEAC:0 [TEN] + Global unicast address(es): + 2002::1, subnet is 2002::/64 [TEN] + Joined group address(es): + FF02::1 + FF02::1:FF00:1 + FF02::1:FFAC:0 + MTU is 1500 bytes + ICMP error messages limited to one every 100 milliseconds + ICMP redirects are enabled + ND DAD is enabled, number of DAD attempts: 1 + ND reachable time is 30000 milliseconds +Loopback0 is up, line protocol is up + IPv6 is enabled, link-local address is FE80::C009:24FF:FEAC:0 + Global unicast address(es): + 2001::1, subnet is 2001::1/128 + 2001::2, subnet is 2001::2/128 + Joined group address(es): + FF02::1 + FF02::2 + FF02::1:FF00:1 + FF02::1:FF00:2 + FF02::1:FFAC:0 + MTU is 1514 bytes + ICMP error messages limited to one every 100 milliseconds + ICMP redirects are enabled + ND DAD is not supported + ND reachable time is 30000 milliseconds + diff --git a/test/unit/mocked_data/test_get_interfaces_ip/normal/show_run_interface_GigabitEthernet0_5.txt b/test/unit/mocked_data/test_get_interfaces_ip/normal/show_run_interface_GigabitEthernet0_5.txt deleted file mode 100644 index 99c588d..0000000 --- a/test/unit/mocked_data/test_get_interfaces_ip/normal/show_run_interface_GigabitEthernet0_5.txt +++ /dev/null @@ -1,8 +0,0 @@ -Building configuration... - -Current configuration : 87 bytes -! -interface GigabitEthernet0/5 - switchport access vlan 41 - switchport mode access -end diff --git a/test/unit/mocked_data/test_get_interfaces_ip/normal/show_run_interface_Port_channel1.txt b/test/unit/mocked_data/test_get_interfaces_ip/normal/show_run_interface_Port_channel1.txt deleted file mode 100644 index 5fbb78a..0000000 --- a/test/unit/mocked_data/test_get_interfaces_ip/normal/show_run_interface_Port_channel1.txt +++ /dev/null @@ -1,7 +0,0 @@ -Building configuration... - -Current configuration : 41 bytes -! -interface Port-channel1 - shutdown -end diff --git a/test/unit/mocked_data/test_get_interfaces_ip/normal/show_run_interface_Vlan20.txt b/test/unit/mocked_data/test_get_interfaces_ip/normal/show_run_interface_Vlan20.txt deleted file mode 100644 index 27e1039..0000000 --- a/test/unit/mocked_data/test_get_interfaces_ip/normal/show_run_interface_Vlan20.txt +++ /dev/null @@ -1,7 +0,0 @@ -Building configuration... - -Current configuration : 64 bytes -! -interface Vlan20 - ip address 172.29.50.3 255.255.255.224 -end diff --git a/test/unit/mocked_data/test_get_interfaces_ip/normal/show_run_interface_Vlan40.txt b/test/unit/mocked_data/test_get_interfaces_ip/normal/show_run_interface_Vlan40.txt deleted file mode 100644 index e4abaed..0000000 --- a/test/unit/mocked_data/test_get_interfaces_ip/normal/show_run_interface_Vlan40.txt +++ /dev/null @@ -1,7 +0,0 @@ -Building configuration... - -Current configuration : 39 bytes -! -interface Vlan40 - no ip address -end diff --git a/test/unit/mocked_data/test_get_interfaces_ip/normal/show_run_interface_Vlan41.txt b/test/unit/mocked_data/test_get_interfaces_ip/normal/show_run_interface_Vlan41.txt deleted file mode 100644 index 10868c6..0000000 --- a/test/unit/mocked_data/test_get_interfaces_ip/normal/show_run_interface_Vlan41.txt +++ /dev/null @@ -1,8 +0,0 @@ -Building configuration... - -Current configuration : 115 bytes -! -interface Vlan41 - ip address 192.168.81.34 255.255.255.0 secondary - ip address 172.29.52.34 255.255.255.224 -end