Ejemplo n.º 1
0
    def __init__(self, re, keepAttributes=None):
        if keepAttributes is None:
            keepAttributes = keepAttributes_default

        attributes = Attributes()
        for (attributeId, attribute) in re.attributes.iteritems():
            if attributeId in keepAttributes:
                attributes.add(attribute)

        RouteEntry.__init__(self, re.afi, re.safi, re.routeTargets, re.nlri,
                            attributes, None)
Ejemplo n.º 2
0
    def _newRouteEvent(self, eventType, nlri, rts, source, nh, lp=0,
                       replacedRouteEntry=None,
                       afi=AFI(AFI.ipv4), safi=SAFI(SAFI.mpls_vpn)):
        attributes = Attributes()
        attributes.add(NextHop(nh))
        attributes.add(LocalPreference(lp))
        routeEvent = RouteEvent(eventType, RouteEntry(
            afi, safi, rts, nlri, attributes, source), source)
        routeEvent.setReplacedRoute(replacedRouteEntry)

        self.eventTargetWorker.enqueue(routeEvent)

        log.info("Emitting event to %s: %s",
                 self.eventTargetWorker, routeEvent)

        self._wait()

        return routeEvent
    def testF1_testEmptyRT(self):
        # worker advertises a route with no RT

        w1 = self._newworker("Worker1", Worker)

        subscribe = Subscription(AFI(AFI.ipv4), SAFI(SAFI.mpls_vpn), None, w1)
        self.routeTableManager.enqueue(subscribe)

        w2 = self._newworker("Worker2", Worker)

        routeEvent = RouteEvent(
            RouteEvent.ADVERTISE,
            RouteEntry(AFI(AFI.ipv4), SAFI(SAFI.mpls_vpn), None, NLRI1,
                       Attributes(), w2), w2)

        self.routeTableManager.enqueue(routeEvent)

        self._wait()

        self.assertEqual(
            1, w1.enqueue.call_count,
            "1 route advertised should be synthesized to Worker1")
Ejemplo n.º 4
0
    def setUp(self):
        super(TestVPNInstance, self).setUp()
        self.labelAllocator = LabelAllocator()

        self.mockDataplane = mock.Mock()
        self.mockDataplane.vifPlugged = mock.Mock()
        self.mockDataplane.vifUnplugged = mock.Mock()

        self.mockDPDriver = mock.Mock()
        self.mockDPDriver.initializeDataplaneInstance.returnValue = \
            self.mockDataplane

        VPNInstance.afi = AFI(AFI.ipv4)
        VPNInstance.safi = SAFI(SAFI.mpls_vpn)
        self.vpnInstance = TestableVPNInstance(mock.Mock(name='BGPManager'),
                                               self.labelAllocator,
                                               self.mockDPDriver, 1, 1, [RT1],
                                               [RT1], '10.0.0.1', 24, None)
        self.vpnInstance.synthesizeVifBGPRoute = mock.Mock(
            return_value=RouteEntry(self.vpnInstance.afi, self.vpnInstance.
                                    safi, NLRI1, RT1, Attributes(), None))
        self.vpnInstance._pushEvent = mock.Mock()
        self.vpnInstance._postFirstPlug = mock.Mock()
        self.vpnInstance.start()
Ejemplo n.º 5
0
 def __init__(self, nlri):
     self.nlri = nlri
     self.__address = Address(nlri.afi, nlri.safi)
     self.attributes = Attributes()
Ejemplo n.º 6
0
 def AttributesFactory(self, data):
     try:
         self.attributes = Attributes()
         return self._AttributesFactory(data).attributes
     except IndexError:
         raise Notify(3, 2, data)
Ejemplo n.º 7
0
	def __init__ (self,afi,safi):
		self.attributes = Attributes()
		self.nlri = Empty(afi,safi)
Ejemplo n.º 8
0
 def __init__(self, afi=AFI.ipv4, safi=SAFI.flow_ipv4):
     self.attributes = Attributes()
     self.nlri = _FlowNLRI(afi, safi)
     self.attributes[AttributeID.EXTENDED_COMMUNITY] = ECommunities()