1 | # encoding: utf-8 |
||
2 | """ |
||
3 | rsvpbw.py |
||
4 | |||
5 | Created by Evelio Vila on 2016-12-01. |
||
6 | Copyright (c) 2014-2017 Exa Networks. All rights reserved. |
||
7 | """ |
||
8 | |||
9 | from struct import unpack |
||
10 | |||
11 | from exabgp.bgp.message.notification import Notify |
||
12 | |||
13 | from exabgp.bgp.message.update.attribute.bgpls.linkstate import LINKSTATE |
||
14 | |||
15 | |||
16 | # This sub-TLV contains the maximum amount of bandwidth that can be |
||
17 | # reserved in this direction on this link. Note that for |
||
18 | # oversubscription purposes, this can be greater than the bandwidth of |
||
19 | # the link. |
||
20 | # https://tools.ietf.org/html/rfc5305#section-3.5 |
||
21 | # |
||
22 | # Units are in Bytes not Bits. |
||
23 | # ---------------------------- |
||
24 | |||
25 | |||
26 | View Code Duplication | @LINKSTATE.register() |
|
0 ignored issues
–
show
Duplication
introduced
by
Loading history...
|
|||
27 | class RsvpBw(object): |
||
28 | TLV = 1090 |
||
29 | |||
30 | def __init__(self, rsvpbw): |
||
31 | self.rsvpbw = rsvpbw |
||
32 | |||
33 | def __repr__(self): |
||
34 | return "Maximum reservable link bandwidth: %s" % (self.rsvpbw) |
||
35 | |||
36 | @classmethod |
||
37 | def unpack(cls, data, length): |
||
38 | if len(data) != 4: |
||
39 | raise Notify(3, 5, "Incorrect maximum reservable link bw metric") |
||
40 | |||
41 | rsvpbw = unpack('!f', data)[0] |
||
42 | return cls(rsvpbw=rsvpbw) |
||
43 | |||
44 | def json(self, compact=None): |
||
45 | return '"maximum-reservable-link-bandwidth": %s' % str(self.rsvpbw) |
||
46 |