blob: 45d8b72b9a019a6871b911dfb6038c197e43ba14 [file] [log] [blame]
khenaidood2b6df92018-12-13 16:37:20 -05001/*
2 * Copyright 2018-present Open Networking Foundation
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 */
16package common
17
18import (
19 "errors"
20 "github.com/golang/protobuf/ptypes"
21 "github.com/golang/protobuf/ptypes/empty"
22 "github.com/opencord/voltha-go/adapters"
23 "github.com/opencord/voltha-go/common/log"
khenaidoo6d055132019-02-12 16:51:19 -050024 "github.com/opencord/voltha-go/kafka"
William Kurkiandaa6bb22019-03-07 12:26:28 -050025 ic "github.com/opencord/voltha-protos/go/inter_container"
khenaidoo2c6a0992019-04-29 13:46:56 -040026 "github.com/opencord/voltha-protos/go/openflow_13"
William Kurkiandaa6bb22019-03-07 12:26:28 -050027 "github.com/opencord/voltha-protos/go/voltha"
khenaidood2b6df92018-12-13 16:37:20 -050028 "google.golang.org/grpc/codes"
29 "google.golang.org/grpc/status"
30)
31
32type RequestHandlerProxy struct {
33 TestMode bool
34 coreInstanceId string
35 adapter adapters.IAdapter
khenaidoo2c6a0992019-04-29 13:46:56 -040036 coreProxy *CoreProxy
khenaidood2b6df92018-12-13 16:37:20 -050037}
38
khenaidoo54e0ddf2019-02-27 16:21:33 -050039func NewRequestHandlerProxy(coreInstanceId string, iadapter adapters.IAdapter, cProxy *CoreProxy) *RequestHandlerProxy {
khenaidood2b6df92018-12-13 16:37:20 -050040 var proxy RequestHandlerProxy
41 proxy.coreInstanceId = coreInstanceId
42 proxy.adapter = iadapter
khenaidoo54e0ddf2019-02-27 16:21:33 -050043 proxy.coreProxy = cProxy
khenaidood2b6df92018-12-13 16:37:20 -050044 return &proxy
45}
46
47func (rhp *RequestHandlerProxy) Adapter_descriptor() (*empty.Empty, error) {
48 return new(empty.Empty), nil
49}
50
51func (rhp *RequestHandlerProxy) Device_types() (*voltha.DeviceTypes, error) {
52 return nil, nil
53}
54
55func (rhp *RequestHandlerProxy) Health() (*voltha.HealthStatus, error) {
56 return nil, nil
57}
58
59func (rhp *RequestHandlerProxy) Adopt_device(args []*ic.Argument) (*empty.Empty, error) {
khenaidoo54e0ddf2019-02-27 16:21:33 -050060 if len(args) < 3 {
khenaidood2b6df92018-12-13 16:37:20 -050061 log.Warn("invalid-number-of-args", log.Fields{"args": args})
62 err := errors.New("invalid-number-of-args")
63 return nil, err
64 }
65 device := &voltha.Device{}
khenaidoo6d055132019-02-12 16:51:19 -050066 transactionID := &ic.StrType{}
khenaidoo54e0ddf2019-02-27 16:21:33 -050067 fromTopic := &ic.StrType{}
khenaidoo6d055132019-02-12 16:51:19 -050068 for _, arg := range args {
69 switch arg.Key {
70 case "device":
71 if err := ptypes.UnmarshalAny(arg.Value, device); err != nil {
72 log.Warnw("cannot-unmarshal-device", log.Fields{"error": err})
73 return nil, err
74 }
75 case kafka.TransactionKey:
76 if err := ptypes.UnmarshalAny(arg.Value, transactionID); err != nil {
77 log.Warnw("cannot-unmarshal-transaction-ID", log.Fields{"error": err})
78 return nil, err
79 }
khenaidoo54e0ddf2019-02-27 16:21:33 -050080 case kafka.FromTopic:
81 if err := ptypes.UnmarshalAny(arg.Value, fromTopic); err != nil {
82 log.Warnw("cannot-unmarshal-from-topic", log.Fields{"error": err})
83 return nil, err
84 }
khenaidoo6d055132019-02-12 16:51:19 -050085 }
khenaidood2b6df92018-12-13 16:37:20 -050086 }
khenaidoo6d055132019-02-12 16:51:19 -050087
khenaidood2b6df92018-12-13 16:37:20 -050088 log.Debugw("Adopt_device", log.Fields{"deviceId": device.Id})
89
khenaidoo54e0ddf2019-02-27 16:21:33 -050090 //Update the core reference for that device
91 rhp.coreProxy.UpdateCoreReference(device.Id, fromTopic.Val)
92
khenaidood2b6df92018-12-13 16:37:20 -050093 //Invoke the adopt device on the adapter
94 if err := rhp.adapter.Adopt_device(device); err != nil {
95 return nil, status.Errorf(codes.NotFound, "%s", err.Error())
96 }
97
98 return new(empty.Empty), nil
99}
100
101func (rhp *RequestHandlerProxy) Reconcile_device(args []*ic.Argument) (*empty.Empty, error) {
102 return new(empty.Empty), nil
103}
104
105func (rhp *RequestHandlerProxy) Abandon_device(args []*ic.Argument) (*empty.Empty, error) {
106 return new(empty.Empty), nil
107}
108
109func (rhp *RequestHandlerProxy) Disable_device(args []*ic.Argument) (*empty.Empty, error) {
khenaidoo3ab34882019-05-02 21:33:30 -0400110 if len(args) < 3 {
111 log.Warn("invalid-number-of-args", log.Fields{"args": args})
112 err := errors.New("invalid-number-of-args")
113 return nil, err
114 }
115
116 device := &voltha.Device{}
117 transactionID := &ic.StrType{}
118 fromTopic := &ic.StrType{}
119 for _, arg := range args {
120 switch arg.Key {
121 case "device":
122 if err := ptypes.UnmarshalAny(arg.Value, device); err != nil {
123 log.Warnw("cannot-unmarshal-device", log.Fields{"error": err})
124 return nil, err
125 }
126 case kafka.TransactionKey:
127 if err := ptypes.UnmarshalAny(arg.Value, transactionID); err != nil {
128 log.Warnw("cannot-unmarshal-transaction-ID", log.Fields{"error": err})
129 return nil, err
130 }
131 case kafka.FromTopic:
132 if err := ptypes.UnmarshalAny(arg.Value, fromTopic); err != nil {
133 log.Warnw("cannot-unmarshal-from-topic", log.Fields{"error": err})
134 return nil, err
135 }
136 }
137 }
138 //Update the core reference for that device
139 rhp.coreProxy.UpdateCoreReference(device.Id, fromTopic.Val)
140 //Invoke the Disable_device API on the adapter
141 if err := rhp.adapter.Disable_device(device); err != nil {
142 return nil, status.Errorf(codes.NotFound, "%s", err.Error())
143 }
khenaidood2b6df92018-12-13 16:37:20 -0500144 return new(empty.Empty), nil
145}
146
147func (rhp *RequestHandlerProxy) Reenable_device(args []*ic.Argument) (*empty.Empty, error) {
khenaidoo3ab34882019-05-02 21:33:30 -0400148 if len(args) < 3 {
149 log.Warn("invalid-number-of-args", log.Fields{"args": args})
150 err := errors.New("invalid-number-of-args")
151 return nil, err
152 }
153
154 device := &voltha.Device{}
155 transactionID := &ic.StrType{}
156 fromTopic := &ic.StrType{}
157 for _, arg := range args {
158 switch arg.Key {
159 case "device":
160 if err := ptypes.UnmarshalAny(arg.Value, device); err != nil {
161 log.Warnw("cannot-unmarshal-device", log.Fields{"error": err})
162 return nil, err
163 }
164 case kafka.TransactionKey:
165 if err := ptypes.UnmarshalAny(arg.Value, transactionID); err != nil {
166 log.Warnw("cannot-unmarshal-transaction-ID", log.Fields{"error": err})
167 return nil, err
168 }
169 case kafka.FromTopic:
170 if err := ptypes.UnmarshalAny(arg.Value, fromTopic); err != nil {
171 log.Warnw("cannot-unmarshal-from-topic", log.Fields{"error": err})
172 return nil, err
173 }
174 }
175 }
176 //Update the core reference for that device
177 rhp.coreProxy.UpdateCoreReference(device.Id, fromTopic.Val)
178 //Invoke the Reenable_device API on the adapter
179 if err := rhp.adapter.Reenable_device(device); err != nil {
180 return nil, status.Errorf(codes.NotFound, "%s", err.Error())
181 }
khenaidood2b6df92018-12-13 16:37:20 -0500182 return new(empty.Empty), nil
183}
184
185func (rhp *RequestHandlerProxy) Reboot_device(args []*ic.Argument) (*empty.Empty, error) {
Girish Gowdru894d97d2019-05-28 05:07:18 -0400186 if len(args) < 3 {
187 log.Warn("invalid-number-of-args", log.Fields{"args": args})
188 err := errors.New("invalid-number-of-args")
189 return nil, err
190 }
191
192 device := &voltha.Device{}
193 transactionID := &ic.StrType{}
194 fromTopic := &ic.StrType{}
195 for _, arg := range args {
196 switch arg.Key {
197 case "device":
198 if err := ptypes.UnmarshalAny(arg.Value, device); err != nil {
199 log.Warnw("cannot-unmarshal-device", log.Fields{"error": err})
200 return nil, err
201 }
202 case kafka.TransactionKey:
203 if err := ptypes.UnmarshalAny(arg.Value, transactionID); err != nil {
204 log.Warnw("cannot-unmarshal-transaction-ID", log.Fields{"error": err})
205 return nil, err
206 }
207 case kafka.FromTopic:
208 if err := ptypes.UnmarshalAny(arg.Value, fromTopic); err != nil {
209 log.Warnw("cannot-unmarshal-from-topic", log.Fields{"error": err})
210 return nil, err
211 }
212 }
213 }
214 //Update the core reference for that device
215 rhp.coreProxy.UpdateCoreReference(device.Id, fromTopic.Val)
216 //Invoke the Reboot_device API on the adapter
217 if err := rhp.adapter.Reboot_device(device); err != nil {
218 return nil, status.Errorf(codes.NotFound, "%s", err.Error())
219 }
khenaidood2b6df92018-12-13 16:37:20 -0500220 return new(empty.Empty), nil
Girish Gowdru894d97d2019-05-28 05:07:18 -0400221
khenaidood2b6df92018-12-13 16:37:20 -0500222}
223
224func (rhp *RequestHandlerProxy) Self_test_device(args []*ic.Argument) (*empty.Empty, error) {
225 return new(empty.Empty), nil
226}
227
228func (rhp *RequestHandlerProxy) Delete_device(args []*ic.Argument) (*empty.Empty, error) {
khenaidoo0a822f92019-05-08 15:15:57 -0400229 if len(args) < 3 {
230 log.Warn("invalid-number-of-args", log.Fields{"args": args})
231 err := errors.New("invalid-number-of-args")
232 return nil, err
233 }
234
235 device := &voltha.Device{}
236 transactionID := &ic.StrType{}
237 fromTopic := &ic.StrType{}
238 for _, arg := range args {
239 switch arg.Key {
240 case "device":
241 if err := ptypes.UnmarshalAny(arg.Value, device); err != nil {
242 log.Warnw("cannot-unmarshal-device", log.Fields{"error": err})
243 return nil, err
244 }
245 case kafka.TransactionKey:
246 if err := ptypes.UnmarshalAny(arg.Value, transactionID); err != nil {
247 log.Warnw("cannot-unmarshal-transaction-ID", log.Fields{"error": err})
248 return nil, err
249 }
250 case kafka.FromTopic:
251 if err := ptypes.UnmarshalAny(arg.Value, fromTopic); err != nil {
252 log.Warnw("cannot-unmarshal-from-topic", log.Fields{"error": err})
253 return nil, err
254 }
255 }
256 }
257 //Update the core reference for that device
258 rhp.coreProxy.UpdateCoreReference(device.Id, fromTopic.Val)
khenaidoob3127472019-07-24 21:04:55 -0400259 //Invoke the delete_device API on the adapter
khenaidoo0a822f92019-05-08 15:15:57 -0400260 if err := rhp.adapter.Delete_device(device); err != nil {
261 return nil, status.Errorf(codes.NotFound, "%s", err.Error())
262 }
khenaidood2b6df92018-12-13 16:37:20 -0500263 return new(empty.Empty), nil
264}
265
266func (rhp *RequestHandlerProxy) Get_device_details(args []*ic.Argument) (*empty.Empty, error) {
267 return new(empty.Empty), nil
268}
269
270func (rhp *RequestHandlerProxy) Update_flows_bulk(args []*ic.Argument) (*empty.Empty, error) {
khenaidoo0458db62019-06-20 08:50:36 -0400271 log.Debug("Update_flows_bulk")
272 if len(args) < 4 {
273 log.Warn("Update_flows_bulk-invalid-number-of-args", log.Fields{"args": args})
274 err := errors.New("invalid-number-of-args")
275 return nil, err
276 }
277 device := &voltha.Device{}
278 transactionID := &ic.StrType{}
279 flows := &voltha.Flows{}
280 groups := &voltha.FlowGroups{}
281 for _, arg := range args {
282 switch arg.Key {
283 case "device":
284 if err := ptypes.UnmarshalAny(arg.Value, device); err != nil {
285 log.Warnw("cannot-unmarshal-device", log.Fields{"error": err})
286 return nil, err
287 }
288 case "flows":
289 if err := ptypes.UnmarshalAny(arg.Value, flows); err != nil {
290 log.Warnw("cannot-unmarshal-flows", log.Fields{"error": err})
291 return nil, err
292 }
293 case "groups":
294 if err := ptypes.UnmarshalAny(arg.Value, groups); err != nil {
295 log.Warnw("cannot-unmarshal-groups", log.Fields{"error": err})
296 return nil, err
297 }
298 case kafka.TransactionKey:
299 if err := ptypes.UnmarshalAny(arg.Value, transactionID); err != nil {
300 log.Warnw("cannot-unmarshal-transaction-ID", log.Fields{"error": err})
301 return nil, err
302 }
303 }
304 }
305 log.Debugw("Update_flows_bulk", log.Fields{"flows": flows, "groups": groups})
khenaidoob3127472019-07-24 21:04:55 -0400306 //Invoke the bulk flow update API of the adapter
khenaidoo0458db62019-06-20 08:50:36 -0400307 if err := rhp.adapter.Update_flows_bulk(device, flows, groups); err != nil {
308 return nil, status.Errorf(codes.NotFound, "%s", err.Error())
309 }
khenaidood2b6df92018-12-13 16:37:20 -0500310 return new(empty.Empty), nil
311}
312
313func (rhp *RequestHandlerProxy) Update_flows_incrementally(args []*ic.Argument) (*empty.Empty, error) {
khenaidoo2c6a0992019-04-29 13:46:56 -0400314 log.Debug("Update_flows_incrementally")
mkoodali252f7672019-03-25 12:13:12 +0530315 if len(args) < 3 {
316 log.Warn("Update_flows_incrementally-invalid-number-of-args", log.Fields{"args": args})
317 err := errors.New("invalid-number-of-args")
318 return nil, err
319 }
320 device := &voltha.Device{}
321 transactionID := &ic.StrType{}
khenaidoo2c6a0992019-04-29 13:46:56 -0400322 flows := &openflow_13.FlowChanges{}
323 groups := &openflow_13.FlowGroupChanges{}
mkoodali252f7672019-03-25 12:13:12 +0530324 for _, arg := range args {
325 switch arg.Key {
326 case "device":
327 if err := ptypes.UnmarshalAny(arg.Value, device); err != nil {
328 log.Warnw("cannot-unmarshal-device", log.Fields{"error": err})
329 return nil, err
330 }
331 case "flow_changes":
332 if err := ptypes.UnmarshalAny(arg.Value, flows); err != nil {
333 log.Warnw("cannot-unmarshal-flows", log.Fields{"error": err})
334 return nil, err
335 }
336 case "group_changes":
337 if err := ptypes.UnmarshalAny(arg.Value, groups); err != nil {
338 log.Warnw("cannot-unmarshal-groups", log.Fields{"error": err})
339 return nil, err
340 }
341 case kafka.TransactionKey:
342 if err := ptypes.UnmarshalAny(arg.Value, transactionID); err != nil {
343 log.Warnw("cannot-unmarshal-transaction-ID", log.Fields{"error": err})
344 return nil, err
345 }
346 }
347 }
khenaidoo2c6a0992019-04-29 13:46:56 -0400348 log.Debugw("Update_flows_incrementally", log.Fields{"flows": flows, "groups": groups})
khenaidoob3127472019-07-24 21:04:55 -0400349 //Invoke the incremental flow update API of the adapter
khenaidoo2c6a0992019-04-29 13:46:56 -0400350 if err := rhp.adapter.Update_flows_incrementally(device, flows, groups); err != nil {
351 return nil, status.Errorf(codes.NotFound, "%s", err.Error())
352 }
khenaidood2b6df92018-12-13 16:37:20 -0500353 return new(empty.Empty), nil
354}
355
356func (rhp *RequestHandlerProxy) Update_pm_config(args []*ic.Argument) (*empty.Empty, error) {
khenaidoob3127472019-07-24 21:04:55 -0400357 log.Debug("Update_pm_config")
358 if len(args) < 2 {
359 log.Warn("Update_pm_config-invalid-number-of-args", log.Fields{"args": args})
360 err := errors.New("invalid-number-of-args")
361 return nil, err
362 }
363 device := &voltha.Device{}
364 transactionID := &ic.StrType{}
365 pmConfigs := &voltha.PmConfigs{}
366 for _, arg := range args {
367 switch arg.Key {
368 case "device":
369 if err := ptypes.UnmarshalAny(arg.Value, device); err != nil {
370 log.Warnw("cannot-unmarshal-device", log.Fields{"error": err})
371 return nil, err
372 }
373 case "pm_configs":
374 if err := ptypes.UnmarshalAny(arg.Value, pmConfigs); err != nil {
375 log.Warnw("cannot-unmarshal-pm-configs", log.Fields{"error": err})
376 return nil, err
377 }
378 case kafka.TransactionKey:
379 if err := ptypes.UnmarshalAny(arg.Value, transactionID); err != nil {
380 log.Warnw("cannot-unmarshal-transaction-ID", log.Fields{"error": err})
381 return nil, err
382 }
383 }
384 }
385 log.Debugw("Update_pm_config", log.Fields{"deviceId": device.Id, "pmConfigs": pmConfigs})
386 //Invoke the pm config update API of the adapter
387 if err := rhp.adapter.Update_pm_config(device, pmConfigs); err != nil {
388 return nil, status.Errorf(codes.NotFound, "%s", err.Error())
389 }
khenaidood2b6df92018-12-13 16:37:20 -0500390 return new(empty.Empty), nil
391}
392
393func (rhp *RequestHandlerProxy) Receive_packet_out(args []*ic.Argument) (*empty.Empty, error) {
manikkaraj k6c9689d2019-05-09 12:59:52 -0400394 log.Debugw("Receive_packet_out", log.Fields{"args": args})
395 if len(args) < 3 {
396 log.Warn("Receive_packet_out-invalid-number-of-args", log.Fields{"args": args})
397 err := errors.New("invalid-number-of-args")
398 return nil, err
399 }
400 deviceId := &ic.StrType{}
401 egressPort := &ic.IntType{}
402 packet := &openflow_13.OfpPacketOut{}
403 transactionID := &ic.StrType{}
404 for _, arg := range args {
405 switch arg.Key {
406 case "deviceId":
407 if err := ptypes.UnmarshalAny(arg.Value, deviceId); err != nil {
408 log.Warnw("cannot-unmarshal-deviceId", log.Fields{"error": err})
409 return nil, err
410 }
411 case "outPort":
412 if err := ptypes.UnmarshalAny(arg.Value, egressPort); err != nil {
413 log.Warnw("cannot-unmarshal-egressPort", log.Fields{"error": err})
414 return nil, err
415 }
416 case "packet":
417 if err := ptypes.UnmarshalAny(arg.Value, packet); err != nil {
418 log.Warnw("cannot-unmarshal-packet", log.Fields{"error": err})
419 return nil, err
420 }
421 case kafka.TransactionKey:
422 if err := ptypes.UnmarshalAny(arg.Value, transactionID); err != nil {
423 log.Warnw("cannot-unmarshal-transaction-ID", log.Fields{"error": err})
424 return nil, err
425 }
426 }
427 }
428 log.Debugw("Receive_packet_out", log.Fields{"deviceId": deviceId.Val, "outPort": egressPort, "packet": packet})
429 //Invoke the adopt device on the adapter
430 if err := rhp.adapter.Receive_packet_out(deviceId.Val, int(egressPort.Val), packet); err != nil {
431 return nil, status.Errorf(codes.NotFound, "%s", err.Error())
432 }
khenaidood2b6df92018-12-13 16:37:20 -0500433 return new(empty.Empty), nil
434}
435
436func (rhp *RequestHandlerProxy) Suppress_alarm(args []*ic.Argument) (*empty.Empty, error) {
437 return new(empty.Empty), nil
438}
439
440func (rhp *RequestHandlerProxy) Unsuppress_alarm(args []*ic.Argument) (*empty.Empty, error) {
441 return new(empty.Empty), nil
442}
443
444func (rhp *RequestHandlerProxy) Get_ofp_device_info(args []*ic.Argument) (*ic.SwitchCapability, error) {
khenaidoo54e0ddf2019-02-27 16:21:33 -0500445 if len(args) < 2 {
khenaidood2b6df92018-12-13 16:37:20 -0500446 log.Warn("invalid-number-of-args", log.Fields{"args": args})
447 err := errors.New("invalid-number-of-args")
448 return nil, err
449 }
450 device := &voltha.Device{}
khenaidoo6d055132019-02-12 16:51:19 -0500451 transactionID := &ic.StrType{}
452 for _, arg := range args {
453 switch arg.Key {
454 case "device":
455 if err := ptypes.UnmarshalAny(arg.Value, device); err != nil {
456 log.Warnw("cannot-unmarshal-device", log.Fields{"error": err})
457 return nil, err
458 }
459 case kafka.TransactionKey:
460 if err := ptypes.UnmarshalAny(arg.Value, transactionID); err != nil {
461 log.Warnw("cannot-unmarshal-transaction-ID", log.Fields{"error": err})
462 return nil, err
463 }
464 }
khenaidood2b6df92018-12-13 16:37:20 -0500465 }
khenaidoo6d055132019-02-12 16:51:19 -0500466
khenaidood2b6df92018-12-13 16:37:20 -0500467 log.Debugw("Get_ofp_device_info", log.Fields{"deviceId": device.Id})
468
469 var cap *ic.SwitchCapability
470 var err error
471 if cap, err = rhp.adapter.Get_ofp_device_info(device); err != nil {
472 return nil, status.Errorf(codes.NotFound, "%s", err.Error())
473 }
khenaidoo6d055132019-02-12 16:51:19 -0500474 log.Debugw("Get_ofp_device_info", log.Fields{"cap": cap})
khenaidood2b6df92018-12-13 16:37:20 -0500475 return cap, nil
476}
477
478func (rhp *RequestHandlerProxy) Get_ofp_port_info(args []*ic.Argument) (*ic.PortCapability, error) {
khenaidoo54e0ddf2019-02-27 16:21:33 -0500479 if len(args) < 3 {
khenaidood2b6df92018-12-13 16:37:20 -0500480 log.Warn("invalid-number-of-args", log.Fields{"args": args})
481 err := errors.New("invalid-number-of-args")
482 return nil, err
483 }
484 device := &voltha.Device{}
485 pNo := &ic.IntType{}
khenaidoo6d055132019-02-12 16:51:19 -0500486 transactionID := &ic.StrType{}
khenaidood2b6df92018-12-13 16:37:20 -0500487 for _, arg := range args {
488 switch arg.Key {
489 case "device":
490 if err := ptypes.UnmarshalAny(arg.Value, device); err != nil {
491 log.Warnw("cannot-unmarshal-device", log.Fields{"error": err})
492 return nil, err
493 }
494 case "port_no":
495 if err := ptypes.UnmarshalAny(arg.Value, pNo); err != nil {
496 log.Warnw("cannot-unmarshal-port-no", log.Fields{"error": err})
497 return nil, err
498 }
khenaidoo6d055132019-02-12 16:51:19 -0500499 case kafka.TransactionKey:
500 if err := ptypes.UnmarshalAny(arg.Value, transactionID); err != nil {
501 log.Warnw("cannot-unmarshal-transaction-ID", log.Fields{"error": err})
502 return nil, err
503 }
khenaidood2b6df92018-12-13 16:37:20 -0500504 }
505 }
506 log.Debugw("Get_ofp_port_info", log.Fields{"deviceId": device.Id, "portNo": pNo.Val})
507 var cap *ic.PortCapability
508 var err error
509 if cap, err = rhp.adapter.Get_ofp_port_info(device, pNo.Val); err != nil {
510 return nil, status.Errorf(codes.NotFound, "%s", err.Error())
511 }
512 return cap, nil
513}
514
515func (rhp *RequestHandlerProxy) Process_inter_adapter_message(args []*ic.Argument) (*empty.Empty, error) {
khenaidoo54e0ddf2019-02-27 16:21:33 -0500516 if len(args) < 2 {
khenaidood2b6df92018-12-13 16:37:20 -0500517 log.Warn("invalid-number-of-args", log.Fields{"args": args})
518 err := errors.New("invalid-number-of-args")
519 return nil, err
520 }
521 iaMsg := &ic.InterAdapterMessage{}
khenaidoo6d055132019-02-12 16:51:19 -0500522 transactionID := &ic.StrType{}
523 for _, arg := range args {
524 switch arg.Key {
525 case "msg":
526 if err := ptypes.UnmarshalAny(arg.Value, iaMsg); err != nil {
527 log.Warnw("cannot-unmarshal-device", log.Fields{"error": err})
528 return nil, err
529 }
530 case kafka.TransactionKey:
531 if err := ptypes.UnmarshalAny(arg.Value, transactionID); err != nil {
532 log.Warnw("cannot-unmarshal-transaction-ID", log.Fields{"error": err})
533 return nil, err
534 }
535 }
khenaidood2b6df92018-12-13 16:37:20 -0500536 }
537
538 log.Debugw("Process_inter_adapter_message", log.Fields{"msgId": iaMsg.Header.Id})
539
540 //Invoke the inter adapter API on the handler
541 if err := rhp.adapter.Process_inter_adapter_message(iaMsg); err != nil {
542 return nil, status.Errorf(codes.NotFound, "%s", err.Error())
543 }
544
545 return new(empty.Empty), nil
546}
547
khenaidoof5a5bfa2019-01-23 22:20:29 -0500548func (rhp *RequestHandlerProxy) Download_image(args []*ic.Argument) (*voltha.ImageDownload, error) {
549 return &voltha.ImageDownload{}, nil
khenaidood2b6df92018-12-13 16:37:20 -0500550}
551
khenaidoof5a5bfa2019-01-23 22:20:29 -0500552func (rhp *RequestHandlerProxy) Get_image_download_status(args []*ic.Argument) (*voltha.ImageDownload, error) {
553 return &voltha.ImageDownload{}, nil
khenaidood2b6df92018-12-13 16:37:20 -0500554}
555
khenaidoof5a5bfa2019-01-23 22:20:29 -0500556func (rhp *RequestHandlerProxy) Cancel_image_download(args []*ic.Argument) (*voltha.ImageDownload, error) {
557 return &voltha.ImageDownload{}, nil
khenaidood2b6df92018-12-13 16:37:20 -0500558}
559
khenaidoof5a5bfa2019-01-23 22:20:29 -0500560func (rhp *RequestHandlerProxy) Activate_image_update(args []*ic.Argument) (*voltha.ImageDownload, error) {
561 return &voltha.ImageDownload{}, nil
khenaidood2b6df92018-12-13 16:37:20 -0500562}
563
khenaidoof5a5bfa2019-01-23 22:20:29 -0500564func (rhp *RequestHandlerProxy) Revert_image_update(args []*ic.Argument) (*voltha.ImageDownload, error) {
565 return &voltha.ImageDownload{}, nil
khenaidood2b6df92018-12-13 16:37:20 -0500566}