Bug-2226: RFC5886 yang model
[bgpcep.git] / pcep / pcepy / message / _message.py
1 # PCEP message and implicit object definitions
2
3 # Copyright (c) 2012,2013 Cisco Systems, Inc. and others.  All rights reserved.
4 #
5 # This program and the accompanying materials are made available under the
6 # terms of the Eclipse Public License v1.0 which accompanies this distribution,
7 # and is available at http://www.eclipse.org/legal/epl-v10.html
8
9 from . import base
10 from . import object # Note: object here is a module
11
12 # RFC 5440 PCEP
13 class Open(base.Message):
14     type_id = 1
15
16     _sequence = [
17         ('open', object.Open, 1),
18     ]
19
20
21 # RFC 5440 PCEP
22 class Keepalive(base.Message):
23     type_id = 2
24
25     _sequence = [ ]
26
27 # RFC 5886 MON
28 class GMon(base.Group):
29     _sequence = [
30         ('mon', object.Monitoring, 1),
31         ('pcc', object.PccIdReq, 1),
32         ('pce', object.PceId, '*'),
33     ]
34
35 # RFC 5440 PCEP
36 class GRro(base.Group):
37     _sequence = [
38         ('rro', object.Rro, 1),
39         ('rbw', object.Bandwidth, '?'),
40     ]
41
42 # RFC 5440 PCEP
43 # Note: RFC 5520 PK says there's either a PatkKey,
44 # or all other objects in a request
45 # In RFC 5440 PCEP, Endpoints is a REQUIRED object
46 class Request(base.Group):
47     _sequence = [
48         ('rp', object.Rp, 1),
49         ('pk', object.PathKey, '?'), # RFC 5520 PK
50         ('ep', object.Endpoints, '?'), # Actually required
51         ('lsp', object.Lsp, '?'), # D STATEFUL
52         ('lspa', object.Lspa, '?'),
53         ('bw', object.Bandwidth, '?'),
54         ('metric', object.Metric, '*'),
55         ('of', object.Of, '?'), # RFC 5541 OF
56         ('grro', GRro, '?'),
57         ('iro', object.Iro, '?'),
58         ('lb', object.LoadBalancing, '?'),
59         ('xro', object.Xro, '?'), # RFC 5521 XRO
60     ]
61
62 # RFC 5440 PCEP
63 class GSvec(base.Group):
64     _sequence = [
65         ('svec', object.Svec, 1),
66         ('of', object.Of, '?'), # RFC 5541 OF
67         ('metric', object.Metric, '*'), # RFC 5541 OF
68     ]
69
70 # RFC 5440 PCEP
71 class PCReq(base.Message):
72     type_id = 3
73
74     _sequence = [
75         ('gmon', GMon, '?'), # RFC 5886 MON
76         ('gsvec', GSvec, '*'),
77         ('request', Request, '+'),
78     ]
79
80 # RFC 5440 PCEP
81 class PcePathAttributes(base.Group):
82     _sequence = [
83         ('of', object.Of, '?'), # RFC 5541 OF
84         ('lspa', object.Lspa, '?'),
85         ('bw', object.Bandwidth, '?'),
86         ('metric', object.Metric, '*'),
87         ('iro', object.Iro, '?'), # Not in D STATEFUL-01
88     ]
89
90 # RFC 5440 PCEP
91 class PcePath(base.Group):
92     _sequence = [
93         ('ero', object.Ero, 1),
94         ('pcepa', PcePathAttributes, '?'),
95     ]
96
97 # RFC 5886 MON
98 class MetricPce(base.Group):
99     _sequence = [
100         ('pce', object.PceId, 1),
101         ('pt', object.ProcTime, '?'),
102         ('ol', object.Overload, '?'),
103     ]
104
105 # RFC 5440 PCEP
106 class Response(base.Group):
107     _sequence = [
108         ('rp', object.Rp, 1),
109         ('gmon', GMon, '?'), # Without pce list # RFC 5886 MON
110         ('lsp', object.Lsp, '?'), # D STATEFUL
111         ('nopath', object.NoPath, '?'),
112         ('pcepa', PcePathAttributes, '?'),
113         ('path', PcePath, '*'),
114         ('mp', MetricPce, '*'), # RFC 5886 MON
115     ]
116
117 # RFC 5440 PCEP
118 class PCRep(base.Message):
119     type_id = 4
120
121     _sequence = [
122         ('response', Response, '+'),
123     ]
124
125 # RFC 5440 PCEP
126 class GNotify(base.Group):
127     _sequence = [
128         ('rp', object.Rp, '*'),
129         ('notify', object.Notification, '+'),
130     ]
131
132 # RFC 5440 PCEP
133 class PCNtf(base.Message):
134     type_id = 5
135
136     _sequence = [
137         ('gnotify', GNotify, '+'),
138     ]
139
140 # RFC 5440 PCEP
141 class GError(base.Group):
142     """Unified PCEP error item"""
143     _sequence = [
144         ('rp', object.Rp, '*'),
145         ('error', object.Error, '+'),
146         ('lsp', object.Lsp, '?'), # D STATEFUL
147     ]
148
149 # RFC 5440 PCEP
150 class PCErr(base.Message):
151     type_id = 6
152
153     _sequence = [
154         ('gerror', GError, '+'),
155         ('open', object.Open, '?'),
156     ]
157
158 # RFC 5440 PCEP
159 class Close(base.Message):
160     type_id = 7
161
162     _sequence = [
163         ('close', object.Close, 1)
164     ]
165
166 # RFC 5886 MON
167 class PCMonReq(base.Message):
168     type_id = 8
169
170     _sequence = [
171         ('gmon', GMon, 1),
172         ('gsvec', GSvec, '*'),
173         ('request', Request, '+'),
174     ]
175
176 # RFC 5886 MON
177 class PCMonRep(base.Message):
178     type_id = 9
179
180     _sequence = [
181         ('gmon', GMon, '?'), # Without pce list
182         ('rp', object.Rp, '*'),
183         ('mp', MetricPce, '*'),
184     ]
185
186 # D STATEFUL
187 class PccPath(base.Group):
188     _sequence = [
189         ('ero', object.Ero, 1),
190         ('lspa', object.Lspa, '?'),
191         ('bw', object.Bandwidth, '?'),
192         ('rro', object.Rro, '?'),
193         ('metric', object.Metric, '*'),
194     ]
195
196 # D STATEFUL
197 class StateReport(base.Group):
198     _sequence = [
199         ('lsp', object.Lsp, 1),
200         ('path', PccPath, '*'),
201     ]
202
203 # D STATEFUL
204 class PCRpt(base.Message):
205     type_id = 10
206
207     _sequence = [
208         ('report', StateReport, '+'),
209     ]
210
211
212 # D STATEFUL
213 class UpdateRequest(base.Group):
214     _sequence = [
215         ('lsp', object.Lsp, 1),
216         ('path', PcePath, '*'),
217     ]
218
219 # D STATEFUL
220 class PCUpd(base.Message):
221     type_id = 11
222
223     _sequence = [
224         ('update', UpdateRequest, '+'),
225     ]
226
227
228 # D STATEFUL
229 class CreateRequest(base.Group):
230     _sequence = [
231         ('end-points', object.Endpoints, 1),
232         ('lspa', object.Lspa, 1),
233         ('ero', object.Ero, '?'),
234         ('bw', object.Bandwidth, '?'),
235         ('metric', object.Metric, '*'),
236     ]
237
238 # D STATEFUL
239 class PCCreate(base.Message):
240     type_id = 12
241
242     _sequence = [
243         ('create', CreateRequest, '+'),
244     ]
245
246 # We do not need special handling for unknown messages
247 class Unknown(base.Message):
248     pass
249 base.Message.unknown_class = Unknown
250