コード例 #1
0
ファイル: l3_proactive_app.py プロジェクト: rski/dragonflow
    def _get_gateway_port_by_ip(self, router, ip):
        for port in router.get_ports():
            network = netaddr.IPNetwork(port.get_network())
            if netaddr.IPAddress(ip) in network:
                return port

        raise exceptions.DBStoreRecordNotFound(
            record='RouterPort(router=%s, ip=%s)' % (router.get_name(), ip))
コード例 #2
0
    def _get_gateway_port_by_ip(self, router, ip):
        for port in router.ports:
            if ip in port.network:
                return port

        # Code is not expected to hit here as neutron will prevent from adding
        # unreachable route.
        raise exceptions.DBStoreRecordNotFound(
            record='RouterPort(router=%s, ip=%s)' % (router.name, ip))
コード例 #3
0
ファイル: l3_base.py プロジェクト: snapiri/dragonflow
    def _get_gateway_port_by_ip(self, router, ip):
        """
        Return the router port that has the given IP. Raise an exception if
        no such router port exists
        :param router:  The router
        :type router:   LogicalRouter
        :param ip:      The IP to search
        :type ip:       netaddr.IPAddress (or representation thereof)
        :return:        LogicalPort or None
        :raises:        exceptions.DBStoreRecordNotFound
        """
        for port in router.ports:
            if ip in port.network:
                return port

        # Code is not expected to hit here as neutron will prevent from adding
        # unreachable route.
        raise exceptions.DBStoreRecordNotFound(
            record='RouterPort(router=%s, ip=%s)' % (router.name, ip))