コード例 #1
0
ファイル: test_devices.py プロジェクト: kasisnu/calico
    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])
コード例 #2
0
    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])
コード例 #3
0
ファイル: endpoint.py プロジェクト: fasaxc/felix
    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)
コード例 #4
0
ファイル: endpoint.py プロジェクト: fasaxc/felix
 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)
コード例 #5
0
 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)