def test_del_route(self): tap = "tap" + str(uuid.uuid4())[:11] retcode = futils.CommandOutput("", "") type = futils.IPV4 ip = "1.2.3.4" with mock.patch('calico.felix.futils.check_call', return_value=retcode): devices.del_route(type, ip, tap) futils.check_call.assert_any_call(['arp', '-d', ip, '-i', tap]) futils.check_call.assert_called_with(["ip", "route", "del", ip, "dev", tap]) type = futils.IPV6 ip = "2001::" with mock.patch('calico.felix.futils.check_call', return_value=retcode): devices.del_route(type, ip, tap) futils.check_call.assert_called_once_with(["ip", "-6", "route", "del", ip, "dev", tap])
def test_del_route(self): tap = "tap" + str(uuid.uuid4())[:11] retcode = futils.CommandOutput("", "") type = futils.IPV4 ip = "1.2.3.4" with mock.patch('calico.felix.futils.check_call', return_value=retcode): devices.del_route(type, ip, tap) futils.check_call.assert_any_call(['arp', '-d', ip, '-i', tap]) futils.check_call.assert_called_with(["ip", "route", "del", ip, "dev", tap]) type = futils.IPV6 ip = "2001::" with mock.patch('calico.felix.futils.check_call', return_value=retcode): devices.del_route(type, ip, tap) futils.check_call.assert_called_once_with(["ip", "-6", "route", "del", ip, "dev", tap])
def remove(self, iptables_state): """ Delete a programmed endpoint. Remove the routes, then the rules. """ if devices.interface_exists(self.interface): for type in (futils.IPV4, futils.IPV6): try: ips = devices.list_interface_ips(type, self.interface) for ip in ips: devices.del_route(type, ip, self.interface) except futils.FailedSystemCall: # There is a window where the interface gets deleted under # our feet. If it has gone now, ignore the error, otherwise # rethrow it. if devices.interface_exists(self.interface): raise break frules.del_rules(iptables_state, self.suffix, futils.IPV4) frules.del_rules(iptables_state, self.suffix, futils.IPV6)
def remove_routes(routes, type): for route in routes: log.info( "Remove extra %s route to address %s for interface %s", type, route, self.interface) devices.del_route(type, route, self.interface)
def remove_routes(routes, type): for route in routes: log.info("Remove extra %s route to address %s for tap %s" % (type, route, self.tap)) devices.del_route(type, route, self.tap)