Matteo Scandolo
Committed by Gerrit Code Review

Enabling UI live-reload for apps not in the ONOS source code

Change-Id: Ib88929a8825b7adf136d2b6b90d66db10549c165
1 +namespace java org.p4.bmv2.thrift
2 +namespace cpp cpservice
3 +
4 +service ControlPlaneService {
5 +
6 + bool ping(),
7 +
8 + oneway void packetIn(1: i32 port, 2: i64 reason, 3: i32 tableId, 4: i32 contextId, 5: binary packet),
9 +
10 + oneway void hello(1: i32 thriftServerPort, 2: i32 deviceId)
11 +
12 +}
...\ No newline at end of file ...\ No newline at end of file
1 +namespace java org.p4.bmv2.thrift
2 +/* Copyright 2013-present Barefoot Networks, Inc.
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +/*
18 + * Antonin Bas (antonin@barefootnetworks.com)
19 + *
20 + */
21 +
22 +namespace cpp bm_runtime.simple_pre
23 +namespace py bm_runtime.simple_pre
24 +
25 +typedef i32 BmMcMgrp
26 +typedef i32 BmMcRid
27 +typedef i32 BmMcMgrpHandle
28 +typedef i32 BmMcL1Handle
29 +typedef string BmMcPortMap // string of 0s and 1s
30 +
31 +enum McOperationErrorCode {
32 + TABLE_FULL = 1,
33 + INVALID_HANDLE = 2,
34 + INVALID_MGID = 3,
35 + INVALID_L1_HANDLE = 4,
36 + INVALID_L2_HANLDE = 5,
37 + ERROR = 6
38 +}
39 +
40 +exception InvalidMcOperation {
41 + 1:McOperationErrorCode code
42 +}
43 +
44 +service SimplePre {
45 +
46 + BmMcMgrpHandle bm_mc_mgrp_create(
47 + 1:i32 cxt_id,
48 + 2:BmMcMgrp mgrp
49 + ) throws (1:InvalidMcOperation ouch),
50 +
51 + void bm_mc_mgrp_destroy(
52 + 1:i32 cxt_id,
53 + 2:BmMcMgrpHandle mgrp_handle
54 + ) throws (1:InvalidMcOperation ouch),
55 +
56 + BmMcL1Handle bm_mc_node_create(
57 + 1:i32 cxt_id,
58 + 2:BmMcRid rid
59 + 3:BmMcPortMap port_map
60 + ) throws (1:InvalidMcOperation ouch),
61 +
62 + void bm_mc_node_associate(
63 + 1:i32 cxt_id,
64 + 2:BmMcMgrpHandle mgrp_handle,
65 + 3:BmMcL1Handle l1_handle
66 + ) throws (1:InvalidMcOperation ouch),
67 +
68 + void bm_mc_node_dissociate(
69 + 1:i32 cxt_id,
70 + 2:BmMcMgrpHandle mgrp_handle,
71 + 3:BmMcL1Handle l1_handle
72 + ) throws (1:InvalidMcOperation ouch),
73 +
74 + void bm_mc_node_destroy(
75 + 1:i32 cxt_id,
76 + 2:BmMcL1Handle l1_handle
77 + ) throws (1:InvalidMcOperation ouch),
78 +
79 + void bm_mc_node_update(
80 + 1:i32 cxt_id,
81 + 2:BmMcL1Handle l1_handle,
82 + 3:BmMcPortMap port_map
83 + ) throws (1:InvalidMcOperation ouch),
84 +}
1 +namespace java org.p4.bmv2.thrift
2 +/* Copyright 2013-present Barefoot Networks, Inc.
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +/*
18 + * Srikrishna Gopu (krishna@barefootnetworks.com)
19 + * Antonin Bas (antonin@barefootnetworks.com)
20 + *
21 + */
22 +
23 +namespace cpp bm_runtime.simple_pre_lag
24 +namespace py bm_runtime.simple_pre_lag
25 +
26 +typedef i32 BmMcMgrp
27 +typedef i32 BmMcRid
28 +typedef i32 BmMcMgrpHandle
29 +typedef i32 BmMcL1Handle
30 +typedef i16 BmMcLagIndex
31 +typedef string BmMcPortMap // string of 0s and 1s
32 +typedef string BmMcLagMap // string of 0s and 1s
33 +
34 +enum McOperationErrorCode {
35 + TABLE_FULL = 1,
36 + INVALID_HANDLE = 2,
37 + INVALID_MGID = 3,
38 + INVALID_L1_HANDLE = 4,
39 + INVALID_L2_HANLDE = 5,
40 + ERROR = 6
41 +}
42 +
43 +exception InvalidMcOperation {
44 + 1:McOperationErrorCode code
45 +}
46 +
47 +service SimplePreLAG {
48 +
49 + BmMcMgrpHandle bm_mc_mgrp_create(
50 + 1:i32 cxt_id,
51 + 2:BmMcMgrp mgrp
52 + ) throws (1:InvalidMcOperation ouch),
53 +
54 + void bm_mc_mgrp_destroy(
55 + 1:i32 cxt_id,
56 + 2:BmMcMgrpHandle mgrp_handle
57 + ) throws (1:InvalidMcOperation ouch),
58 +
59 + BmMcL1Handle bm_mc_node_create(
60 + 1:i32 cxt_id,
61 + 2:BmMcRid rid,
62 + 3:BmMcPortMap port_map,
63 + 4:BmMcLagMap lag_map
64 + ) throws (1:InvalidMcOperation ouch),
65 +
66 + void bm_mc_node_associate(
67 + 1:i32 cxt_id,
68 + 2:BmMcMgrpHandle mgrp_handle,
69 + 3:BmMcL1Handle l1_handle
70 + ) throws (1:InvalidMcOperation ouch),
71 +
72 + void bm_mc_node_dissociate(
73 + 1:i32 cxt_id,
74 + 2:BmMcMgrpHandle mgrp_handle,
75 + 3:BmMcL1Handle l1_handle
76 + ) throws (1:InvalidMcOperation ouch),
77 +
78 + void bm_mc_node_destroy(
79 + 1:i32 cxt_id,
80 + 2:BmMcL1Handle l1_handle
81 + ) throws (1:InvalidMcOperation ouch),
82 +
83 + void bm_mc_node_update(
84 + 1:i32 cxt_id,
85 + 2:BmMcL1Handle l1_handle,
86 + 3:BmMcPortMap port_map,
87 + 4:BmMcLagMap lag_map
88 + ) throws (1:InvalidMcOperation ouch),
89 +
90 + void bm_mc_set_lag_membership(
91 + 1:i32 cxt_id,
92 + 2:BmMcLagIndex lag_index,
93 + 3:BmMcPortMap port_map
94 + ) throws (1:InvalidMcOperation ouch),
95 +}
1 +namespace java org.p4.bmv2.thrift
2 +/* Copyright 2013-present Barefoot Networks, Inc.
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +/*
18 + * Antonin Bas (antonin@barefootnetworks.com)
19 + *
20 + */
21 +
22 +namespace cpp sswitch_runtime
23 +namespace py sswitch_runtime
24 +
25 +service SimpleSwitch {
26 +
27 + i32 mirroring_mapping_add(1:i32 mirror_id, 2:i32 egress_port);
28 + i32 mirroring_mapping_delete(1:i32 mirror_id);
29 + i32 mirroring_mapping_get_egress_port(1:i32 mirror_id);
30 +
31 + i32 set_egress_queue_depth(1:i32 depth_pkts);
32 + i32 set_egress_queue_rate(1:i64 rate_pps);
33 +
34 + oneway void push_packet(1:i32 port, 2:binary packet);
35 +
36 + bool ping();
37 +
38 +}
1 +namespace java org.p4.bmv2.thrift
2 +/* Copyright 2013-present Barefoot Networks, Inc.
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +/*
18 + * Antonin Bas (antonin@barefootnetworks.com)
19 + *
20 + */
21 +
22 +namespace cpp bm_runtime.standard
23 +namespace py bm_runtime.standard
24 +
25 +typedef i64 BmEntryHandle
26 +typedef list<binary> BmActionData
27 +
28 +typedef i32 BmMemberHandle
29 +typedef i32 BmGroupHandle
30 +
31 +typedef i32 BmLearningListId
32 +typedef i64 BmLearningBufferId
33 +typedef i32 BmLearningSampleId
34 +
35 +enum BmMatchParamType {
36 + EXACT = 0,
37 + LPM = 1,
38 + TERNARY = 2,
39 + VALID = 3
40 +}
41 +
42 +struct BmMatchParamExact {
43 + 1:binary key
44 +}
45 +
46 +struct BmMatchParamLPM {
47 + 1:binary key,
48 + 2:i32 prefix_length
49 +}
50 +
51 +struct BmMatchParamTernary {
52 + 1:binary key,
53 + 2:binary mask
54 +}
55 +
56 +struct BmMatchParamValid {
57 + 1:bool key
58 +}
59 +
60 +# Thrift union sucks in C++, the following is much better
61 +struct BmMatchParam {
62 + 1:BmMatchParamType type,
63 + 2:optional BmMatchParamExact exact,
64 + 3:optional BmMatchParamLPM lpm,
65 + 4:optional BmMatchParamTernary ternary,
66 + 5:optional BmMatchParamValid valid
67 +}
68 +
69 +typedef list<BmMatchParam> BmMatchParams
70 +
71 +struct BmAddEntryOptions {
72 + 1:optional i32 priority
73 +}
74 +
75 +struct BmCounterValue {
76 + 1:i64 bytes;
77 + 2:i64 packets;
78 +}
79 +
80 +struct BmMeterRateConfig {
81 + 1:double units_per_micros;
82 + 2:i32 burst_size;
83 +}
84 +
85 +enum TableOperationErrorCode {
86 + TABLE_FULL = 1,
87 + INVALID_HANDLE = 2,
88 + EXPIRED_HANDLE = 3,
89 + COUNTERS_DISABLED = 4,
90 + METERS_DISABLED = 5,
91 + AGEING_DISABLED = 6,
92 + INVALID_TABLE_NAME = 7,
93 + INVALID_ACTION_NAME = 8,
94 + WRONG_TABLE_TYPE = 9,
95 + INVALID_MBR_HANDLE = 10,
96 + MBR_STILL_USED = 11,
97 + MBR_ALREADY_IN_GRP = 12,
98 + MBR_NOT_IN_GRP = 13,
99 + INVALID_GRP_HANDLE = 14,
100 + GRP_STILL_USED = 15,
101 + EMPTY_GRP = 16,
102 + DUPLICATE_ENTRY = 17,
103 + BAD_MATCH_KEY = 18,
104 + INVALID_METER_OPERATION = 19,
105 + ERROR = 20,
106 +}
107 +
108 +exception InvalidTableOperation {
109 + 1:TableOperationErrorCode code
110 +}
111 +
112 +enum CounterOperationErrorCode {
113 + INVALID_COUNTER_NAME = 1,
114 + INVALID_INDEX = 2,
115 + ERROR = 3,
116 +}
117 +
118 +exception InvalidCounterOperation {
119 + 1:CounterOperationErrorCode code
120 +}
121 +
122 +enum SwapOperationErrorCode {
123 + CONFIG_SWAP_DISABLED = 1,
124 + ONGOING_SWAP = 2,
125 + NO_ONGOING_SWAP = 3
126 +}
127 +
128 +exception InvalidSwapOperation {
129 + 1:SwapOperationErrorCode code
130 +}
131 +
132 +enum MeterOperationErrorCode {
133 + INVALID_INDEX = 1,
134 + BAD_RATES_LIST = 2,
135 + INVALID_INFO_RATE_VALUE = 3,
136 + INVALID_BURST_SIZE_VALUE = 4,
137 + ERROR = 5
138 +}
139 +
140 +exception InvalidMeterOperation {
141 + 1:MeterOperationErrorCode code
142 +}
143 +
144 +typedef i64 BmRegisterValue
145 +
146 +enum RegisterOperationErrorCode {
147 + INVALID_INDEX = 1,
148 + ERROR = 2
149 +}
150 +
151 +exception InvalidRegisterOperation {
152 + 1:RegisterOperationErrorCode code
153 +}
154 +
155 +enum LearnOperationErrorCode {
156 + INVALID_LIST_ID = 1,
157 + ERROR = 2
158 +}
159 +
160 +exception InvalidLearnOperation {
161 + 1:LearnOperationErrorCode code
162 +}
163 +
164 +// TODO
165 +enum DevMgrErrorCode {
166 + ERROR = 1
167 +}
168 +
169 +exception InvalidDevMgrOperation {
170 + 1:DevMgrErrorCode code
171 +}
172 +
173 +struct DevMgrPortInfo {
174 + 1:i32 port_num;
175 + 2:string iface_name;
176 + 3:bool is_up;
177 + 4:map<string, string> extra;
178 +}
179 +
180 +service Standard {
181 +
182 + // table operations
183 +
184 + BmEntryHandle bm_mt_add_entry(
185 + 1:i32 cxt_id,
186 + 2:string table_name,
187 + 3:BmMatchParams match_key,
188 + 4:string action_name,
189 + 5:BmActionData action_data,
190 + 6:BmAddEntryOptions options
191 + ) throws (1:InvalidTableOperation ouch),
192 +
193 + void bm_mt_set_default_action(
194 + 1:i32 cxt_id,
195 + 2:string table_name,
196 + 3:string action_name,
197 + 4:BmActionData action_data
198 + ) throws (1:InvalidTableOperation ouch),
199 +
200 + void bm_mt_delete_entry(
201 + 1:i32 cxt_id,
202 + 2:string table_name,
203 + 3:BmEntryHandle entry_handle
204 + ) throws (1:InvalidTableOperation ouch),
205 +
206 + void bm_mt_modify_entry(
207 + 1:i32 cxt_id,
208 + 2:string table_name,
209 + 3:BmEntryHandle entry_handle,
210 + 4:string action_name,
211 + 5:BmActionData action_data
212 + ) throws (1:InvalidTableOperation ouch),
213 +
214 + void bm_mt_set_entry_ttl(
215 + 1:i32 cxt_id,
216 + 2:string table_name
217 + 3:BmEntryHandle entry_handle,
218 + 4:i32 timeout_ms
219 + ) throws (1:InvalidTableOperation ouch),
220 +
221 + // indirect tables
222 +
223 + BmMemberHandle bm_mt_indirect_add_member(
224 + 1:i32 cxt_id,
225 + 2:string table_name,
226 + 3:string action_name,
227 + 4:BmActionData action_data
228 + ) throws (1:InvalidTableOperation ouch),
229 +
230 + void bm_mt_indirect_delete_member(
231 + 1:i32 cxt_id,
232 + 2:string table_name,
233 + 3:BmMemberHandle mbr_handle
234 + ) throws (1:InvalidTableOperation ouch),
235 +
236 + void bm_mt_indirect_modify_member(
237 + 1:i32 cxt_id,
238 + 2:string table_name,
239 + 3:BmMemberHandle mbr_handle,
240 + 4:string action_name,
241 + 5:BmActionData action_data
242 + ) throws (1:InvalidTableOperation ouch),
243 +
244 + BmEntryHandle bm_mt_indirect_add_entry(
245 + 1:i32 cxt_id,
246 + 2:string table_name,
247 + 3:BmMatchParams match_key,
248 + 4:BmMemberHandle mbr_handle,
249 + 5:BmAddEntryOptions options
250 + ) throws (1:InvalidTableOperation ouch),
251 +
252 + void bm_mt_indirect_modify_entry(
253 + 1:i32 cxt_id,
254 + 2:string table_name,
255 + 3:BmEntryHandle entry_handle,
256 + 4:BmMemberHandle mbr_handle
257 + ) throws (1:InvalidTableOperation ouch),
258 +
259 + void bm_mt_indirect_delete_entry(
260 + 1:i32 cxt_id,
261 + 2:string table_name,
262 + 3:BmEntryHandle entry_handle
263 + ) throws (1:InvalidTableOperation ouch),
264 +
265 + void bm_mt_indirect_set_entry_ttl(
266 + 1:i32 cxt_id,
267 + 2:string table_name
268 + 3:BmEntryHandle entry_handle,
269 + 4:i32 timeout_ms
270 + ) throws (1:InvalidTableOperation ouch),
271 +
272 + void bm_mt_indirect_set_default_member(
273 + 1:i32 cxt_id,
274 + 2:string table_name,
275 + 3:BmMemberHandle mbr_handle
276 + ) throws (1:InvalidTableOperation ouch),
277 +
278 + // indirect tables with selector
279 +
280 + BmGroupHandle bm_mt_indirect_ws_create_group(
281 + 1:i32 cxt_id,
282 + 2:string table_name
283 + ) throws (1:InvalidTableOperation ouch),
284 +
285 + void bm_mt_indirect_ws_delete_group(
286 + 1:i32 cxt_id,
287 + 2:string table_name,
288 + 3:BmGroupHandle grp_handle
289 + ) throws (1:InvalidTableOperation ouch),
290 +
291 + void bm_mt_indirect_ws_add_member_to_group(
292 + 1:i32 cxt_id,
293 + 2:string table_name,
294 + 3:BmMemberHandle mbr_handle,
295 + 4:BmGroupHandle grp_handle
296 + ) throws (1:InvalidTableOperation ouch),
297 +
298 + void bm_mt_indirect_ws_remove_member_from_group(
299 + 1:i32 cxt_id,
300 + 2:string table_name,
301 + 3:BmMemberHandle mbr_handle,
302 + 4:BmGroupHandle grp_handle
303 + ) throws (1:InvalidTableOperation ouch),
304 +
305 + BmEntryHandle bm_mt_indirect_ws_add_entry(
306 + 1:i32 cxt_id,
307 + 2:string table_name,
308 + 3:BmMatchParams match_key,
309 + 4:BmGroupHandle grp_handle
310 + 5:BmAddEntryOptions options
311 + ) throws (1:InvalidTableOperation ouch),
312 +
313 + void bm_mt_indirect_ws_modify_entry(
314 + 1:i32 cxt_id,
315 + 2:string table_name,
316 + 3:BmEntryHandle entry_handle,
317 + 4:BmGroupHandle grp_handle
318 + ) throws (1:InvalidTableOperation ouch),
319 +
320 + void bm_mt_indirect_ws_set_default_group(
321 + 1:i32 cxt_id,
322 + 2:string table_name,
323 + 3:BmGroupHandle grp_handle
324 + ) throws (1:InvalidTableOperation ouch),
325 +
326 + BmCounterValue bm_mt_read_counter(
327 + 1:i32 cxt_id,
328 + 2:string table_name,
329 + 3:BmEntryHandle entry_handle
330 + ) throws (1:InvalidTableOperation ouch),
331 +
332 + void bm_mt_reset_counters(
333 + 1:i32 cxt_id,
334 + 2:string table_name
335 + ) throws (1:InvalidTableOperation ouch),
336 +
337 + void bm_mt_write_counter(
338 + 1:i32 cxt_id,
339 + 2:string table_name,
340 + 3:BmEntryHandle entry_handle,
341 + 4:BmCounterValue value
342 + ) throws (1:InvalidTableOperation ouch),
343 +
344 + void bm_mt_set_meter_rates(
345 + 1:i32 cxt_id,
346 + 2:string table_name,
347 + 3:BmEntryHandle entry_handle,
348 + 4:list<BmMeterRateConfig> rates
349 + ) throws (1:InvalidTableOperation ouch),
350 +
351 + // indirect counters
352 +
353 + BmCounterValue bm_counter_read(
354 + 1:i32 cxt_id,
355 + 2:string counter_name,
356 + 3:i32 index
357 + ) throws (1:InvalidCounterOperation ouch),
358 +
359 + void bm_counter_reset_all(
360 + 1:i32 cxt_id,
361 + 2:string counter_name
362 + ) throws (1:InvalidCounterOperation ouch),
363 +
364 + void bm_counter_write(
365 + 1:i32 cxt_id,
366 + 2:string counter_name,
367 + 3:i32 index,
368 + 4:BmCounterValue value
369 + ) throws (1:InvalidCounterOperation ouch),
370 +
371 + // learning acks
372 +
373 + void bm_learning_ack(
374 + 1:i32 cxt_id,
375 + 2:BmLearningListId list_id,
376 + 3:BmLearningBufferId buffer_id,
377 + 4:list<BmLearningSampleId> sample_ids
378 + ) throws (1:InvalidLearnOperation ouch),
379 +
380 + void bm_learning_ack_buffer(
381 + 1:i32 cxt_id,
382 + 2:BmLearningListId list_id,
383 + 3:BmLearningBufferId buffer_id
384 + ) throws (1:InvalidLearnOperation ouch),
385 +
386 + void bm_learning_set_timeout(
387 + 1:i32 cxt_id,
388 + 2:BmLearningListId list_id,
389 + 3:i32 timeout_ms
390 + ) throws (1:InvalidLearnOperation ouch),
391 +
392 + void bm_learning_set_buffer_size(
393 + 1:i32 cxt_id,
394 + 2:BmLearningListId list_id,
395 + 3:i32 nb_samples
396 + ) throws (1:InvalidLearnOperation ouch),
397 +
398 + // swap configs
399 +
400 + void bm_load_new_config(
401 + 1:string config_str
402 + ) throws (1:InvalidSwapOperation ouch),
403 +
404 + void bm_swap_configs() throws (1:InvalidSwapOperation ouch),
405 +
406 + // meters
407 +
408 + void bm_meter_array_set_rates(
409 + 1:i32 cxt_id,
410 + 2:string meter_array_name,
411 + 3:list<BmMeterRateConfig> rates
412 + ) throws (1:InvalidMeterOperation ouch)
413 +
414 + void bm_meter_set_rates(
415 + 1:i32 cxt_id,
416 + 2:string meter_array_name,
417 + 3:i32 index,
418 + 4:list<BmMeterRateConfig> rates
419 + ) throws (1:InvalidMeterOperation ouch)
420 +
421 +
422 + // registers
423 +
424 + BmRegisterValue bm_register_read(
425 + 1:i32 cxt_id,
426 + 2:string register_array_name,
427 + 3:i32 idx
428 + ) throws (1:InvalidRegisterOperation ouch)
429 +
430 + void bm_register_write(
431 + 1:i32 cxt_id,
432 + 2:string register_array_name,
433 + 3:i32 index,
434 + 4:BmRegisterValue value
435 + ) throws (1:InvalidRegisterOperation ouch)
436 +
437 + void bm_register_write_range(
438 + 1:i32 cxt_id,
439 + 2:string register_array_name,
440 + 3:i32 start_index,
441 + 4:i32 end_index,
442 + 5:BmRegisterValue value
443 + ) throws (1:InvalidRegisterOperation ouch)
444 +
445 + void bm_register_reset(
446 + 1:i32 cxt_id,
447 + 2:string register_array_name
448 + ) throws (1:InvalidRegisterOperation ouch)
449 +
450 +
451 + // device manager
452 +
453 + void bm_dev_mgr_add_port(
454 + 1:string iface_name,
455 + 2:i32 port_num,
456 + 3:string pcap_path // optional
457 + ) throws (1:InvalidDevMgrOperation ouch)
458 +
459 + void bm_dev_mgr_remove_port(
460 + 1:i32 port_num
461 + ) throws (1:InvalidDevMgrOperation ouch)
462 +
463 + list<DevMgrPortInfo> bm_dev_mgr_show_ports(
464 + ) throws (1:InvalidDevMgrOperation ouch)
465 +
466 + // debug functions
467 +
468 + string bm_dump_table(
469 + 1:i32 cxt_id,
470 + 2:string table_name
471 + )
472 +
473 + void bm_reset_state()
474 +
475 + string bm_get_config()
476 + string bm_get_config_md5()
477 +
478 + string bm_serialize_state()
479 +}
...@@ -26,4 +26,17 @@ Dev server is up and listening on http://localhost: 8182 ...@@ -26,4 +26,17 @@ Dev server is up and listening on http://localhost: 8182
26 [BS] Watching files... 26 [BS] Watching files...
27 ``` 27 ```
28 28
29 -To open ONOS visit the local URL (eg: `http://localhost:3000`) plus `/onos/ui` (eg: `http://localhost:3000/onos/ui`)
...\ No newline at end of file ...\ No newline at end of file
29 +To open ONOS visit the local URL (eg: `http://localhost:3000`) plus `/onos/ui`
30 +(eg: `http://localhost:3000/onos/ui`)
31 +
32 +## Loading files from external applications
33 +
34 +The UI development environment provide the ability to serve UI files
35 +from an external forlder that can be specified with:
36 +`ONOS_EXTERNAL_APP_DIRS="appName:path-to-the-first-folder" npm start`
37 +
38 +Eg:
39 +`ONOS_EXTERNAL_APP_DIRS="sampleCustom:../../meow/sample/meowster-sample/" npm start`
40 +
41 +_Note that `ONOS_EXTERNAL_APP_DIRS` is an environment variable,so it can be set with_
42 +_`export ONOS_EXTERNAL_APP_DIRS="sampleCustom:../../meow/sample/meowster-sample/"`_
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -19,15 +19,38 @@ var proxy = httpProxy.createProxyServer({ ...@@ -19,15 +19,38 @@ var proxy = httpProxy.createProxyServer({
19 target: 'http://localhost:8182', 19 target: 'http://localhost:8182',
20 }); 20 });
21 21
22 +if (process.env.ONOS_EXTERNAL_APP_DIRS) {
23 + var external_apps = process.env.ONOS_EXTERNAL_APP_DIRS.replace(/\s/,'').split(',');
24 + external_apps = external_apps.reduce(function(dict, app){
25 + var pieces = app.split(':');
26 + var appName = pieces[0];
27 + var appPath = pieces[1];
28 + dict[appName] = appPath;
29 + return dict;
30 + }, {});
31 +}
32 +
22 var defaultViews = fs.readdirSync('./app/view/'); 33 var defaultViews = fs.readdirSync('./app/view/');
23 var viewNameMatcher = new RegExp(/\/onos\/ui\/app\/view\/(.+)\/.+\.(?:js|css|html)/); 34 var viewNameMatcher = new RegExp(/\/onos\/ui\/app\/view\/(.+)\/.+\.(?:js|css|html)/);
24 35
36 +var checkExternalApp = function (url) {
37 + if(external_apps){
38 + for(var i = 0; i < Object.keys(external_apps).length; i++){
39 + var key = Object.keys(external_apps)[i];
40 + if(url.indexOf(key) !== -1){
41 + return key;
42 + };
43 + }
44 + }
45 + return false;
46 +};
47 +
25 proxy.on('upgrade', function (req, socket, head) { 48 proxy.on('upgrade', function (req, socket, head) {
26 console.log('[WS]: ', head); 49 console.log('[WS]: ', head);
27 proxy.ws(req, socket, head); 50 proxy.ws(req, socket, head);
28 }); 51 });
29 52
30 -proxy.on('error', function(error, req, res) { 53 +proxy.on('error', function (error, req, res) {
31 res.writeHead(500, { 54 res.writeHead(500, {
32 'Content-Type': 'text/plain' 55 'Content-Type': 'text/plain'
33 }); 56 });
...@@ -50,21 +73,29 @@ module.exports = { ...@@ -50,21 +73,29 @@ module.exports = {
50 proxy: { 73 proxy: {
51 target: "http://localhost:8181", 74 target: "http://localhost:8181",
52 ws: true, 75 ws: true,
53 - middleware: function(req, res, next){ 76 + middleware: function (req, res, next) {
54 -
55 77
56 var viewName = viewNameMatcher.exec(req.url); 78 var viewName = viewNameMatcher.exec(req.url);
57 - if(!!viewName && defaultViews.indexOf(viewName[1]) === -1){ 79 + var isExternalApp = checkExternalApp(req.url);
58 - // in this case it is an external application that extend the view 80 +
81 + if (!!viewName && !isExternalApp && defaultViews.indexOf(viewName[1]) === -1) {
82 + // in this case it is an application that extend the view
59 // so we redirect the request to the app folder in case of .js, .css, .html 83 // so we redirect the request to the app folder in case of .js, .css, .html
60 req.url = req.url.replace('/onos/ui/', '/apps/' + viewName[1] + '/app/src/main/resources/'); 84 req.url = req.url.replace('/onos/ui/', '/apps/' + viewName[1] + '/app/src/main/resources/');
61 proxy.web(req, res); 85 proxy.web(req, res);
62 } 86 }
87 + else if (isExternalApp) {
88 + // in this case it is an external application (not in ONOS source code) that extend the view
89 + // so we redirect the request to the app folder in case of .js, .css, .html
90 + req.url = req.url.replace('/onos/ui/', '/src/main/resources/');
91 + proxy.web(req, res);
92 + }
63 // NOTE onos.js and index.html should not be proxied (require server side injection) 93 // NOTE onos.js and index.html should not be proxied (require server side injection)
64 - else if(req.url.match(/(?:js|css|html)/) && req.url !== '/onos/ui/onos.js' && req.url !== '/onos/ui/index.html' && req.url !== '/onos/ui/nav.html'){ 94 + else if (req.url.match(/(?:js|css|html)/) && req.url !== '/onos/ui/onos.js' &&
95 + req.url !== '/onos/ui/index.html' && req.url !== '/onos/ui/nav.html') {
65 // redirect onos base js files to the source folder 96 // redirect onos base js files to the source folder
66 req.url = req.url.replace('/onos/ui/', '/web/gui/src/main/webapp/'); 97 req.url = req.url.replace('/onos/ui/', '/web/gui/src/main/webapp/');
67 - proxy.web(req, res); 98 + proxy.web(req, res);
68 } 99 }
69 else { 100 else {
70 return next(); 101 return next();
......
1 'use strict'; 1 'use strict';
2 2
3 -var http = require('http');
4 -// var httpProxy = require('http-proxy');
5 -var connect = require('connect');
6 -var serveStatic = require('serve-static');
7 var path = require('path'); 3 var path = require('path');
4 +var express = require('express');
5 +var app = express();
8 6
9 var conf = { 7 var conf = {
10 paths: { 8 paths: {
...@@ -13,17 +11,31 @@ var conf = { ...@@ -13,17 +11,31 @@ var conf = {
13 port: '8182' 11 port: '8182'
14 } 12 }
15 13
16 -var httpProxyInit = function (baseDir) { 14 +if (process.env.ONOS_EXTERNAL_APP_DIRS) {
15 + var external_apps = process.env.ONOS_EXTERNAL_APP_DIRS.replace(/\s/,'').split(',');
16 + external_apps.forEach(function(a, i){
17 + let [appName, appPath] = a.split(':');
18 + conf.paths[appName] = appPath;
19 + });
20 +}
17 21
18 - var app = connect(); 22 +var httpProxyInit = function (baseDirs) {
19 23
20 - app.use(serveStatic(path.join(__dirname, baseDir))); 24 + Object.keys(baseDirs).forEach(dir => {
25 + var d = path.isAbsolute(baseDirs[dir]) ? baseDirs[dir] : path.join(__dirname, baseDirs[dir]);
26 + app.use(express.static(d));
27 + });
21 28
22 - var server = http.createServer(app); 29 + app.get('/', function (req, res) {
30 + res.send('Hello World!');
31 + });
23 32
24 - server.listen(conf.port, function(){ 33 + app.listen(conf.port, function () {
25 - console.log('Dev server is up and listening on http://localhost:', conf.port); 34 + console.log(`Dev server is up and listening on http://localhost:${conf.port}!`);
26 }); 35 });
27 }; 36 };
28 37
29 -httpProxyInit(conf.paths.root);
...\ No newline at end of file ...\ No newline at end of file
38 +httpProxyInit(conf.paths);
39 +
40 +
41 +
......
...@@ -7,17 +7,16 @@ ...@@ -7,17 +7,16 @@
7 "test": "tests" 7 "test": "tests"
8 }, 8 },
9 "scripts": { 9 "scripts": {
10 - "bs": "browser-sync start --config bs-config.js", 10 + "bs": "browser-sync start --config bs-config.js",
11 - "dev-server": "node dev_server.js", 11 + "dev-server": "node --harmony_destructuring dev_server.js",
12 "start": "parallelshell \"npm run dev-server\" \"npm run bs\"" 12 "start": "parallelshell \"npm run dev-server\" \"npm run bs\""
13 }, 13 },
14 "author": "ON.Lab", 14 "author": "ON.Lab",
15 "license": "Apache 2.0", 15 "license": "Apache 2.0",
16 "devDependencies": { 16 "devDependencies": {
17 "browser-sync": "^2.12.8", 17 "browser-sync": "^2.12.8",
18 - "connect": "^3.4.1",
19 - "http-proxy": "^1.13.2",
20 "parallelshell": "^2.0.0", 18 "parallelshell": "^2.0.0",
21 - "serve-static": "^1.10.2" 19 + "serve-static": "^1.10.2",
20 + "express": "^4.14.0"
22 } 21 }
23 } 22 }
......