Search for macaddresses more stringently (#40901)

* Search for macaddresses more stringently

Fixes #40829

(cherry picked from commit e7afd3d378)
pull/40981/head
Nathaniel Case 7 years ago committed by Matt Clay
parent ca3c0dfaea
commit cad351328d

@ -379,7 +379,7 @@ class Interfaces(FactsBase):
return match.group(1)
def parse_macaddress(self, data):
match = re.search(r'address is (\S+)', data)
match = re.search(r'Hardware is (?:.*), address is (\S+)', data)
if match:
return match.group(1)

@ -0,0 +1,61 @@
GigabitEthernet0/0 is up, line protocol is up
Hardware is iGbE, address is 5e00.0003.0000 (bia 5e00.0003.0000)
Description: OOB Management
Internet address is 10.8.38.66/24
MTU 1500 bytes, BW 1000000 Kbit/sec, DLY 10 usec,
reliability 253/255, txload 1/255, rxload 1/255
Encapsulation ARPA, loopback not set
Keepalive set (10 sec)
Full Duplex, Auto Speed, link type is auto, media type is RJ45
output flow-control is unsupported, input flow-control is unsupported
ARP type: ARPA, ARP Timeout 04:00:00
Last input 00:00:00, output 00:00:00, output hang never
Last clearing of "show interface" counters never
Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0
Queueing strategy: fifo
Output queue: 0/40 (size/max)
5 minute input rate 3000 bits/sec, 2 packets/sec
5 minute output rate 2000 bits/sec, 2 packets/sec
2226666 packets input, 398288440 bytes, 0 no buffer
Received 156442 broadcasts (0 IP multicasts)
25440 runts, 0 giants, 0 throttles
25440 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored
0 watchdog, 0 multicast, 0 pause input
1304895 packets output, 119337031 bytes, 0 underruns
0 output errors, 0 collisions, 3 interface resets
1083697 unknown protocol drops
0 babbles, 0 late collision, 0 deferred
1 lost carrier, 0 no carrier, 0 pause output
0 output buffer failures, 0 output buffers swapped out
GigabitEthernet1 is up, line protocol is up
Hardware is CSR vNIC, address is 5e00.0006.0000 (bia 5e00.0006.0000)
Description: OOB Management
Internet address is 10.8.38.67/24
MTU 1500 bytes, BW 1000000 Kbit/sec, DLY 10 usec,
reliability 255/255, txload 1/255, rxload 1/255
Encapsulation ARPA, loopback not set
Keepalive set (10 sec)
Full Duplex, 1000Mbps, link type is auto, media type is RJ45
output flow-control is unsupported, input flow-control is unsupported
ARP type: ARPA, ARP Timeout 04:00:00
Last input 00:00:01, output 00:00:07, output hang never
Last clearing of "show interface" counters never
Input queue: 0/375/0/0 (size/max/drops/flushes); Total output drops: 0
Queueing strategy: fifo
Output queue: 0/40 (size/max)
5 minute input rate 3000 bits/sec, 3 packets/sec
5 minute output rate 3000 bits/sec, 3 packets/sec
8463791 packets input, 1445150230 bytes, 0 no buffer
Received 0 broadcasts (0 IP multicasts)
0 runts, 0 giants, 0 throttles
0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored
0 watchdog, 0 multicast, 0 pause input
3521571 packets output, 348781823 bytes, 0 underruns
0 output errors, 0 collisions, 1 interface resets
4150764 unknown protocol drops
0 babbles, 0 late collision, 0 deferred
0 lost carrier, 0 no carrier, 0 pause output
0 output buffer failures, 0 output buffers swapped out
Tunnel1110 is up, line protocol is up
Hardware is Tunnel
Internet address is 10.10.10.2/30

@ -64,3 +64,16 @@ class TestIosFactsModule(TestIosModule):
self.assertEqual(
result['ansible_facts']['ansible_net_stacked_serialnums'], ['CAT0726R0ZU', 'CAT0726R10A', 'CAT0732R0M4']
)
def test_ios_facts_tunnel_address(self):
set_module_args(dict(gather_subset='interfaces'))
result = self.execute_module()
self.assertEqual(
result['ansible_facts']['ansible_net_interfaces']['GigabitEthernet0/0']['macaddress'], '5e00.0003.0000'
)
self.assertEqual(
result['ansible_facts']['ansible_net_interfaces']['GigabitEthernet1']['macaddress'], '5e00.0006.0000'
)
self.assertIsNone(
result['ansible_facts']['ansible_net_interfaces']['Tunnel1110']['macaddress']
)

Loading…
Cancel
Save