Beispiel #1
0
 def discard(self, scope, name, command, tokens):
     # README: We are setting the ASN as zero as that what Juniper (and Arbor) did when we created a local flow route
     try:
         scope[-1]['announce'][-1].attributes[
             Attribute.CODE.EXTENDED_COMMUNITY].add(TrafficRate(ASN(0), 0))
         return True
     except ValueError:
         return self.error.set(self.syntax)
Beispiel #2
0
def rate_limit(tokeniser):
    # README: We are setting the ASN as zero as that what Juniper (and Arbor) did when we created a local flow route
    speed = int(tokeniser())
    if speed < 9600 and speed != 0:
        log.warning("rate-limiting flow under 9600 bytes per seconds may not work", 'configuration')
    if speed > 1000000000000:
        speed = 1000000000000
        log.warning("rate-limiting changed for 1 000 000 000 000 bytes from %s" % speed, 'configuration')
    return ExtendedCommunities().add(TrafficRate(ASN(0), speed))
Beispiel #3
0
 def rate_limit(self, scope, name, command, tokens):
     # README: We are setting the ASN as zero as that what Juniper (and Arbor) did when we created a local flow route
     try:
         speed = int(tokens[0])
         if speed < 9600 and speed != 0:
             self.logger.configuration(
                 "rate-limiting flow under 9600 bytes per seconds may not work",
                 'warning')
         if speed > 1000000000000:
             speed = 1000000000000
             self.logger.configuration(
                 "rate-limiting changed for 1 000 000 000 000 bytes from %s"
                 % tokens[0], 'warning')
         scope[-1]['announce'][-1].attributes[
             Attribute.CODE.EXTENDED_COMMUNITY].add(
                 TrafficRate(ASN(0), speed))
         return True
     except ValueError:
         return self.error.set(self.syntax)
Beispiel #4
0
def discard(tokeniser):
    # README: We are setting the ASN as zero as that what Juniper (and Arbor) did when we created a local flow route
    return ExtendedCommunities().add(TrafficRate(ASN(0), 0))