Beispiel #1
0
 def _subscribe(self, afi, safi, rt=None):
     try:
         subobj = engine.Subscription(afi, safi, rt, self)
         LOG.info("Subscribe: %s ", subobj)
         self.rtm.enqueue(subobj)
     except engine.UnsupportedRT as e:
         LOG.debug("unsupported RT, ignoring (%s)", e.rt)
Beispiel #2
0
    def _worker_cleanup(self, worker):
        '''Cleanup the subscriptions and routes advertised by a worker

        Consider all routes announced by this worker as withdrawn.
        Consider this worker unsubscribed from all of its current
        subscriptions.
        '''
        assert isinstance(worker, worker_m.Worker)
        # synthesize withdraw events for all routes from this worker
        LOG.info("  Preparing to withdraw %d routes that were advertised "
                 "by worker", len(worker._rtm_route_entries))
        for entry in worker._rtm_route_entries:
            LOG.info("  Enqueue event to Withdraw route %s", entry)
            self.enqueue(engine.RouteEvent(engine.RouteEvent.WITHDRAW, entry))

        # remove worker from all of its subscriptions
        for match in worker._rtm_matches:
            wa = self._match_2_workers_entries[match]
            if wa.del_worker(worker):
                self.callback_last_local_subscriber(
                    engine.Subscription(match.afi, match.safi,
                                        match.route_target, worker))
            self._check_match_2_workers_and_entries_cleanup(match)

        worker._rtm_matches.clear()
Beispiel #3
0
 def _worker_subscriptions(self,
                           worker,
                           rts,
                           afi=exa.AFI(exa.AFI.ipv4),
                           safi=exa.SAFI(exa.SAFI.mpls_vpn)):
     for rt in rts:
         subscribe = engine.Subscription(afi, safi, rt, worker)
         self.rtm._on_event(subscribe)
Beispiel #4
0
    def test1(self):
        subscription = engine.Subscription(engine.Subscription.ANY_AFI,
                                           engine.Subscription.ANY_SAFI,
                                           engine.Subscription.ANY_RT)

        route_entry = self.bgp_manager._subscription_2_rtc_route_entry(
            subscription)

        self.assertEqual(route_entry.safi, exa.SAFI.rtc, "wrong RTC route")
    def _worker_subscriptions(self,
                              worker,
                              rts,
                              wait=True,
                              afi=exa.AFI(exa.AFI.ipv4),
                              safi=exa.SAFI(exa.SAFI.mpls_vpn)):
        for rt in rts:
            subscribe = engine.Subscription(afi, safi, rt, worker)
            self.rtm.enqueue(subscribe)

        if wait:
            self._wait()
Beispiel #6
0
    def test_f1_test_empty_rt(self):
        # worker advertises a route with no RT

        w1 = self._new_worker("Worker1", worker.Worker)

        subscribe = engine.Subscription(exa.AFI(exa.AFI.ipv4),
                                        exa.SAFI(exa.SAFI.mpls_vpn), None, w1)
        self.rtm.enqueue(subscribe)

        w2 = self._new_worker("Worker2", worker.Worker)

        route_event = engine.RouteEvent(
            engine.RouteEvent.ADVERTISE,
            engine.RouteEntry(t.NLRI1, None, exa.Attributes()), w2)

        self.rtm.enqueue(route_event)

        self._wait()

        self.assertEqual(
            1, w1.enqueue.call_count,
            "1 route advertised should be synthesized to Worker1")
Beispiel #7
0
 def _subscribe(self, afi, safi, rt=None):
     subobj = engine.Subscription(afi, safi, rt, self)
     LOG.info("Subscribe: %s ", subobj)
     self.rtm.enqueue(subobj)