1 | # encoding: utf-8 |
||
2 | """ |
||
3 | admingroup.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 | from exabgp.bgp.message.update.attribute.bgpls.linkstate import LinkState |
||
13 | |||
14 | |||
15 | View Code Duplication | @LinkState.register() |
|
0 ignored issues
–
show
Duplication
introduced
by
Loading history...
|
|||
16 | class AdminGroup(object): |
||
17 | TLV = 1088 |
||
18 | |||
19 | def __init__(self, colormask): |
||
20 | self.colormask = colormask |
||
21 | |||
22 | def __repr__(self): |
||
23 | return "Admin Group mask: %s" % (self.colormask) |
||
24 | |||
25 | @classmethod |
||
26 | def unpack(cls, data, length): |
||
27 | if length != 4: |
||
28 | raise Notify(3, 5, "Unable to decode attribute. Incorrect Size") |
||
29 | |||
30 | colormask = unpack('!L', data[:4])[0] |
||
31 | return cls(colormask=colormask) |
||
32 | |||
33 | def json(self, compact=None): |
||
34 | return '"admin-group-mask": %s' % self.colormask |
||
35 |