@log.log
def del_arp_table_entry(self, network, ip):
- del self._arp_tbl[network][ip]
+ if network not in self._arp_tbl:
+ LOG.debug("removal of unknown network %s", network)
+ return
+ if self._arp_tbl[network].pop(ip, None) is None:
+ LOG.debug("removal of unknown ip %s", ip)
+ return
if not self._arp_tbl[network]:
del self._arp_tbl[network]
import collections
import contextlib
+import copy
import mock
self.arplib.del_arp_table_entry(self.nets[0].net, self.nets[0].ip)
self.assertEqual(self.arplib._arp_tbl, {})
+ def test_del_arp_table_entry_unknown_network(self):
+ self.arplib._arp_tbl = {
+ 100: {"192.0.2.1": "fa:16:3e:e2:37:37"},
+ }
+ orig = copy.deepcopy(self.arplib._arp_tbl)
+ self.arplib.del_arp_table_entry(200, "192.0.2.1")
+ self.assertEqual(orig, self.arplib._arp_tbl)
+
+ def test_del_arp_table_entry_unknown_ip(self):
+ self.arplib._arp_tbl = {
+ 100: {"192.0.2.1": "fa:16:3e:e2:37:37"},
+ }
+ orig = copy.deepcopy(self.arplib._arp_tbl)
+ self.arplib.del_arp_table_entry(100, "192.0.2.9")
+ self.assertEqual(orig, self.arplib._arp_tbl)
+
def test_del_arp_table_entry_multiple_net(self):
self.arplib._arp_tbl = {
self.nets[0].net: {self.nets[0].ip: self.nets[0].mac},