Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 1 | /* |
| 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 | */ |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 16 | |
Scott Baker | dbd960e | 2020-02-28 08:57:51 -0800 | [diff] [blame] | 17 | //Package core provides the utility for olt devices, flows and statistics |
| 18 | package core |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 19 | |
| 20 | import ( |
| 21 | "context" |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 22 | "sync" |
Abhilash Laxmeshwar | f9942e9 | 2020-01-07 15:32:44 +0530 | [diff] [blame] | 23 | "time" |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 24 | |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 25 | "github.com/opencord/voltha-lib-go/v4/pkg/adapters/adapterif" |
Matteo Scandolo | dfa7a97 | 2020-11-06 13:03:40 -0800 | [diff] [blame] | 26 | conf "github.com/opencord/voltha-lib-go/v4/pkg/config" |
Himani Chawla | cd40780 | 2020-12-10 12:08:59 +0530 | [diff] [blame] | 27 | "github.com/opencord/voltha-lib-go/v4/pkg/events/eventif" |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 28 | "github.com/opencord/voltha-lib-go/v4/pkg/kafka" |
| 29 | "github.com/opencord/voltha-lib-go/v4/pkg/log" |
Scott Baker | dbd960e | 2020-02-28 08:57:51 -0800 | [diff] [blame] | 30 | "github.com/opencord/voltha-openolt-adapter/internal/pkg/config" |
Thomas Lee S | 94109f1 | 2020-03-03 16:39:29 +0530 | [diff] [blame] | 31 | "github.com/opencord/voltha-openolt-adapter/internal/pkg/olterrors" |
kesavand | 6212621 | 2021-01-12 04:56:06 -0500 | [diff] [blame] | 32 | "github.com/opencord/voltha-protos/v4/go/extension" |
Girish Gowdra | a09aeab | 2020-09-14 16:30:52 -0700 | [diff] [blame] | 33 | ic "github.com/opencord/voltha-protos/v4/go/inter_container" |
| 34 | "github.com/opencord/voltha-protos/v4/go/openflow_13" |
| 35 | "github.com/opencord/voltha-protos/v4/go/voltha" |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 36 | ) |
| 37 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 38 | //OpenOLT structure holds the OLT information |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 39 | type OpenOLT struct { |
Matteo Scandolo | dfa7a97 | 2020-11-06 13:03:40 -0800 | [diff] [blame] | 40 | configManager *conf.ConfigManager |
Abhilash Laxmeshwar | f9942e9 | 2020-01-07 15:32:44 +0530 | [diff] [blame] | 41 | deviceHandlers map[string]*DeviceHandler |
| 42 | coreProxy adapterif.CoreProxy |
| 43 | adapterProxy adapterif.AdapterProxy |
Himani Chawla | cd40780 | 2020-12-10 12:08:59 +0530 | [diff] [blame] | 44 | eventProxy eventif.EventProxy |
npujar | ec5762e | 2020-01-01 14:08:48 +0530 | [diff] [blame] | 45 | kafkaICProxy kafka.InterContainerProxy |
Abhilash Laxmeshwar | f9942e9 | 2020-01-07 15:32:44 +0530 | [diff] [blame] | 46 | config *config.AdapterFlags |
| 47 | numOnus int |
Neha Sharma | 3f221ae | 2020-04-29 19:02:12 +0000 | [diff] [blame] | 48 | KVStoreAddress string |
Abhilash Laxmeshwar | f9942e9 | 2020-01-07 15:32:44 +0530 | [diff] [blame] | 49 | KVStoreType string |
| 50 | exitChannel chan int |
| 51 | HeartbeatCheckInterval time.Duration |
| 52 | HeartbeatFailReportInterval time.Duration |
| 53 | GrpcTimeoutInterval time.Duration |
| 54 | lockDeviceHandlersMap sync.RWMutex |
Gamze Abaka | fcbd6e7 | 2020-12-17 13:25:16 +0000 | [diff] [blame] | 55 | enableONUStats bool |
| 56 | enableGemStats bool |
Matteo Scandolo | 66fbaf5 | 2021-03-24 14:13:38 -0700 | [diff] [blame^] | 57 | ReconnectTimeout time.Duration |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 58 | } |
| 59 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 60 | //NewOpenOLT returns a new instance of OpenOLT |
npujar | ec5762e | 2020-01-01 14:08:48 +0530 | [diff] [blame] | 61 | func NewOpenOLT(ctx context.Context, kafkaICProxy kafka.InterContainerProxy, |
kdarapu | 381c690 | 2019-07-31 18:23:16 +0530 | [diff] [blame] | 62 | coreProxy adapterif.CoreProxy, adapterProxy adapterif.AdapterProxy, |
Himani Chawla | cd40780 | 2020-12-10 12:08:59 +0530 | [diff] [blame] | 63 | eventProxy eventif.EventProxy, cfg *config.AdapterFlags, cm *conf.ConfigManager) *OpenOLT { |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 64 | var openOLT OpenOLT |
| 65 | openOLT.exitChannel = make(chan int, 1) |
| 66 | openOLT.deviceHandlers = make(map[string]*DeviceHandler) |
| 67 | openOLT.kafkaICProxy = kafkaICProxy |
Abhilash Laxmeshwar | f9942e9 | 2020-01-07 15:32:44 +0530 | [diff] [blame] | 68 | openOLT.config = cfg |
| 69 | openOLT.numOnus = cfg.OnuNumber |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 70 | openOLT.coreProxy = coreProxy |
| 71 | openOLT.adapterProxy = adapterProxy |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 72 | openOLT.eventProxy = eventProxy |
Neha Sharma | 3f221ae | 2020-04-29 19:02:12 +0000 | [diff] [blame] | 73 | openOLT.KVStoreAddress = cfg.KVStoreAddress |
Abhilash Laxmeshwar | f9942e9 | 2020-01-07 15:32:44 +0530 | [diff] [blame] | 74 | openOLT.KVStoreType = cfg.KVStoreType |
| 75 | openOLT.HeartbeatCheckInterval = cfg.HeartbeatCheckInterval |
| 76 | openOLT.HeartbeatFailReportInterval = cfg.HeartbeatFailReportInterval |
| 77 | openOLT.GrpcTimeoutInterval = cfg.GrpcTimeoutInterval |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 78 | openOLT.lockDeviceHandlersMap = sync.RWMutex{} |
Matteo Scandolo | dfa7a97 | 2020-11-06 13:03:40 -0800 | [diff] [blame] | 79 | openOLT.configManager = cm |
Gamze Abaka | fcbd6e7 | 2020-12-17 13:25:16 +0000 | [diff] [blame] | 80 | openOLT.enableONUStats = cfg.EnableONUStats |
| 81 | openOLT.enableGemStats = cfg.EnableGEMStats |
Matteo Scandolo | 66fbaf5 | 2021-03-24 14:13:38 -0700 | [diff] [blame^] | 82 | openOLT.ReconnectTimeout = cfg.ReconnectTimeout |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 83 | return &openOLT |
| 84 | } |
| 85 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 86 | //Start starts (logs) the device manager |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 87 | func (oo *OpenOLT) Start(ctx context.Context) error { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 88 | logger.Info(ctx, "starting-device-manager") |
| 89 | logger.Info(ctx, "device-manager-started") |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 90 | return nil |
| 91 | } |
| 92 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 93 | //Stop terminates the session |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 94 | func (oo *OpenOLT) Stop(ctx context.Context) error { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 95 | logger.Info(ctx, "stopping-device-manager") |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 96 | oo.exitChannel <- 1 |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 97 | logger.Info(ctx, "device-manager-stopped") |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 98 | return nil |
| 99 | } |
| 100 | |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 101 | func (oo *OpenOLT) addDeviceHandlerToMap(agent *DeviceHandler) { |
| 102 | oo.lockDeviceHandlersMap.Lock() |
| 103 | defer oo.lockDeviceHandlersMap.Unlock() |
Thomas Lee S | 985938d | 2020-05-04 11:40:41 +0530 | [diff] [blame] | 104 | if _, exist := oo.deviceHandlers[agent.device.Id]; !exist { |
| 105 | oo.deviceHandlers[agent.device.Id] = agent |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 106 | } |
| 107 | } |
| 108 | |
| 109 | func (oo *OpenOLT) deleteDeviceHandlerToMap(agent *DeviceHandler) { |
| 110 | oo.lockDeviceHandlersMap.Lock() |
| 111 | defer oo.lockDeviceHandlersMap.Unlock() |
Thomas Lee S | 985938d | 2020-05-04 11:40:41 +0530 | [diff] [blame] | 112 | delete(oo.deviceHandlers, agent.device.Id) |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 113 | } |
| 114 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 115 | func (oo *OpenOLT) getDeviceHandler(deviceID string) *DeviceHandler { |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 116 | oo.lockDeviceHandlersMap.Lock() |
| 117 | defer oo.lockDeviceHandlersMap.Unlock() |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 118 | if agent, ok := oo.deviceHandlers[deviceID]; ok { |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 119 | return agent |
| 120 | } |
| 121 | return nil |
| 122 | } |
| 123 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 124 | // Adopt_device creates a new device handler if not present already and then adopts the device |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 125 | func (oo *OpenOLT) Adopt_device(ctx context.Context, device *voltha.Device) error { |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 126 | if device == nil { |
Thomas Lee S | 94109f1 | 2020-03-03 16:39:29 +0530 | [diff] [blame] | 127 | return olterrors.NewErrInvalidValue(log.Fields{"device": nil}, nil).Log() |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 128 | } |
divyadesai | 3af43e1 | 2020-08-18 07:10:54 +0000 | [diff] [blame] | 129 | logger.Infow(ctx, "adopt-device", log.Fields{"device-id": device.Id}) |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 130 | var handler *DeviceHandler |
| 131 | if handler = oo.getDeviceHandler(device.Id); handler == nil { |
Matteo Scandolo | dfa7a97 | 2020-11-06 13:03:40 -0800 | [diff] [blame] | 132 | handler := NewDeviceHandler(oo.coreProxy, oo.adapterProxy, oo.eventProxy, device, oo, oo.configManager) |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 133 | oo.addDeviceHandlerToMap(handler) |
npujar | ec5762e | 2020-01-01 14:08:48 +0530 | [diff] [blame] | 134 | go handler.AdoptDevice(ctx, device) |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 135 | // Launch the creation of the device topic |
| 136 | // go oo.createDeviceTopic(device) |
| 137 | } |
| 138 | return nil |
| 139 | } |
| 140 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 141 | //Get_ofp_device_info returns OFP information for the given device |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 142 | func (oo *OpenOLT) Get_ofp_device_info(ctx context.Context, device *voltha.Device) (*ic.SwitchCapability, error) { |
divyadesai | 3af43e1 | 2020-08-18 07:10:54 +0000 | [diff] [blame] | 143 | logger.Infow(ctx, "Get_ofp_device_info", log.Fields{"device-id": device.Id}) |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 144 | if handler := oo.getDeviceHandler(device.Id); handler != nil { |
| 145 | return handler.GetOfpDeviceInfo(device) |
| 146 | } |
Girish Kumar | f26e488 | 2020-03-05 06:49:10 +0000 | [diff] [blame] | 147 | return nil, olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": device.Id}, nil) |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 148 | } |
| 149 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 150 | //Process_inter_adapter_message sends messages to a target device (between adapters) |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 151 | func (oo *OpenOLT) Process_inter_adapter_message(ctx context.Context, msg *ic.InterAdapterMessage) error { |
| 152 | logger.Debugw(ctx, "Process_inter_adapter_message", log.Fields{"msgId": msg.Header.Id}) |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 153 | targetDevice := msg.Header.ProxyDeviceId // Request? |
| 154 | if targetDevice == "" && msg.Header.ToDeviceId != "" { |
| 155 | // Typical response |
| 156 | targetDevice = msg.Header.ToDeviceId |
| 157 | } |
| 158 | if handler := oo.getDeviceHandler(targetDevice); handler != nil { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 159 | return handler.ProcessInterAdapterMessage(ctx, msg) |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 160 | } |
Girish Kumar | f26e488 | 2020-03-05 06:49:10 +0000 | [diff] [blame] | 161 | return olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": targetDevice}, nil) |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 162 | } |
| 163 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 164 | //Adapter_descriptor not implemented |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 165 | func (oo *OpenOLT) Adapter_descriptor(ctx context.Context) error { |
Thomas Lee S | 94109f1 | 2020-03-03 16:39:29 +0530 | [diff] [blame] | 166 | return olterrors.ErrNotImplemented |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 167 | } |
| 168 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 169 | //Device_types unimplemented |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 170 | func (oo *OpenOLT) Device_types(ctx context.Context) (*voltha.DeviceTypes, error) { |
Thomas Lee S | 94109f1 | 2020-03-03 16:39:29 +0530 | [diff] [blame] | 171 | return nil, olterrors.ErrNotImplemented |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 172 | } |
| 173 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 174 | //Health returns unimplemented |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 175 | func (oo *OpenOLT) Health(ctx context.Context) (*voltha.HealthStatus, error) { |
Thomas Lee S | 94109f1 | 2020-03-03 16:39:29 +0530 | [diff] [blame] | 176 | return nil, olterrors.ErrNotImplemented |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 177 | } |
| 178 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 179 | //Reconcile_device unimplemented |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 180 | func (oo *OpenOLT) Reconcile_device(ctx context.Context, device *voltha.Device) error { |
Abhilash Laxmeshwar | ab0bd52 | 2019-10-21 15:05:15 +0530 | [diff] [blame] | 181 | if device == nil { |
Girish Kumar | f26e488 | 2020-03-05 06:49:10 +0000 | [diff] [blame] | 182 | return olterrors.NewErrInvalidValue(log.Fields{"device": nil}, nil) |
Abhilash Laxmeshwar | ab0bd52 | 2019-10-21 15:05:15 +0530 | [diff] [blame] | 183 | } |
divyadesai | 3af43e1 | 2020-08-18 07:10:54 +0000 | [diff] [blame] | 184 | logger.Infow(ctx, "reconcile-device", log.Fields{"device-id": device.Id}) |
Abhilash Laxmeshwar | ab0bd52 | 2019-10-21 15:05:15 +0530 | [diff] [blame] | 185 | var handler *DeviceHandler |
| 186 | if handler = oo.getDeviceHandler(device.Id); handler == nil { |
Matteo Scandolo | dfa7a97 | 2020-11-06 13:03:40 -0800 | [diff] [blame] | 187 | handler := NewDeviceHandler(oo.coreProxy, oo.adapterProxy, oo.eventProxy, device, oo, oo.configManager) |
Gamze Abaka | c2c32a6 | 2021-03-11 11:44:18 +0000 | [diff] [blame] | 188 | handler.adapterPreviouslyConnected = true |
Abhilash Laxmeshwar | ab0bd52 | 2019-10-21 15:05:15 +0530 | [diff] [blame] | 189 | oo.addDeviceHandlerToMap(handler) |
| 190 | handler.transitionMap = NewTransitionMap(handler) |
npujar | ec5762e | 2020-01-01 14:08:48 +0530 | [diff] [blame] | 191 | handler.transitionMap.Handle(ctx, DeviceInit) |
Abhilash Laxmeshwar | ab0bd52 | 2019-10-21 15:05:15 +0530 | [diff] [blame] | 192 | } |
| 193 | return nil |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 194 | } |
| 195 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 196 | //Abandon_device unimplemented |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 197 | func (oo *OpenOLT) Abandon_device(ctx context.Context, device *voltha.Device) error { |
Thomas Lee S | 94109f1 | 2020-03-03 16:39:29 +0530 | [diff] [blame] | 198 | return olterrors.ErrNotImplemented |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 199 | } |
| 200 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 201 | //Disable_device disables the given device |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 202 | func (oo *OpenOLT) Disable_device(ctx context.Context, device *voltha.Device) error { |
divyadesai | 3af43e1 | 2020-08-18 07:10:54 +0000 | [diff] [blame] | 203 | logger.Infow(ctx, "disable-device", log.Fields{"device-id": device.Id}) |
Girish Gowdru | 5ba46c9 | 2019-04-25 05:00:05 -0400 | [diff] [blame] | 204 | if handler := oo.getDeviceHandler(device.Id); handler != nil { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 205 | return handler.DisableDevice(ctx, device) |
Girish Gowdru | 5ba46c9 | 2019-04-25 05:00:05 -0400 | [diff] [blame] | 206 | } |
Girish Kumar | f26e488 | 2020-03-05 06:49:10 +0000 | [diff] [blame] | 207 | return olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": device.Id}, nil) |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 208 | } |
| 209 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 210 | //Reenable_device enables the olt device after disable |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 211 | func (oo *OpenOLT) Reenable_device(ctx context.Context, device *voltha.Device) error { |
divyadesai | 3af43e1 | 2020-08-18 07:10:54 +0000 | [diff] [blame] | 212 | logger.Infow(ctx, "reenable-device", log.Fields{"device-id": device.Id}) |
Girish Gowdru | 5ba46c9 | 2019-04-25 05:00:05 -0400 | [diff] [blame] | 213 | if handler := oo.getDeviceHandler(device.Id); handler != nil { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 214 | return handler.ReenableDevice(ctx, device) |
Girish Gowdru | 5ba46c9 | 2019-04-25 05:00:05 -0400 | [diff] [blame] | 215 | } |
Girish Kumar | f26e488 | 2020-03-05 06:49:10 +0000 | [diff] [blame] | 216 | return olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": device.Id}, nil) |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 217 | } |
| 218 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 219 | //Reboot_device reboots the given device |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 220 | func (oo *OpenOLT) Reboot_device(ctx context.Context, device *voltha.Device) error { |
divyadesai | 3af43e1 | 2020-08-18 07:10:54 +0000 | [diff] [blame] | 221 | logger.Infow(ctx, "reboot-device", log.Fields{"device-id": device.Id}) |
Girish Gowdru | 0fe5f7e | 2019-05-28 05:12:27 -0400 | [diff] [blame] | 222 | if handler := oo.getDeviceHandler(device.Id); handler != nil { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 223 | return handler.RebootDevice(ctx, device) |
Girish Gowdru | 0fe5f7e | 2019-05-28 05:12:27 -0400 | [diff] [blame] | 224 | } |
Girish Kumar | f26e488 | 2020-03-05 06:49:10 +0000 | [diff] [blame] | 225 | return olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": device.Id}, nil) |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 226 | } |
| 227 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 228 | //Self_test_device unimplented |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 229 | func (oo *OpenOLT) Self_test_device(ctx context.Context, device *voltha.Device) error { |
Thomas Lee S | 94109f1 | 2020-03-03 16:39:29 +0530 | [diff] [blame] | 230 | return olterrors.ErrNotImplemented |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 231 | } |
| 232 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 233 | //Delete_device unimplemented |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 234 | func (oo *OpenOLT) Delete_device(ctx context.Context, device *voltha.Device) error { |
divyadesai | 3af43e1 | 2020-08-18 07:10:54 +0000 | [diff] [blame] | 235 | logger.Infow(ctx, "delete-device", log.Fields{"device-id": device.Id}) |
Devmalya Paul | 495b94a | 2019-08-27 19:42:00 -0400 | [diff] [blame] | 236 | if handler := oo.getDeviceHandler(device.Id); handler != nil { |
npujar | ec5762e | 2020-01-01 14:08:48 +0530 | [diff] [blame] | 237 | if err := handler.DeleteDevice(ctx, device); err != nil { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 238 | logger.Errorw(ctx, "failed-to-handle-delete-device", log.Fields{"device-id": device.Id}) |
Devmalya Paul | 495b94a | 2019-08-27 19:42:00 -0400 | [diff] [blame] | 239 | } |
| 240 | oo.deleteDeviceHandlerToMap(handler) |
| 241 | return nil |
| 242 | } |
Girish Kumar | f26e488 | 2020-03-05 06:49:10 +0000 | [diff] [blame] | 243 | return olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": device.Id}, nil) |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 244 | } |
| 245 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 246 | //Get_device_details unimplemented |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 247 | func (oo *OpenOLT) Get_device_details(ctx context.Context, device *voltha.Device) error { |
Thomas Lee S | 94109f1 | 2020-03-03 16:39:29 +0530 | [diff] [blame] | 248 | return olterrors.ErrNotImplemented |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 249 | } |
| 250 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 251 | //Update_flows_bulk returns |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 252 | func (oo *OpenOLT) Update_flows_bulk(ctx context.Context, device *voltha.Device, flows *voltha.Flows, groups *voltha.FlowGroups, flowMetadata *voltha.FlowMetadata) error { |
Thomas Lee S | 94109f1 | 2020-03-03 16:39:29 +0530 | [diff] [blame] | 253 | return olterrors.ErrNotImplemented |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 254 | } |
| 255 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 256 | //Update_flows_incrementally updates (add/remove) the flows on a given device |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 257 | func (oo *OpenOLT) Update_flows_incrementally(ctx context.Context, device *voltha.Device, flows *openflow_13.FlowChanges, groups *openflow_13.FlowGroupChanges, flowMetadata *voltha.FlowMetadata) error { |
Girish Gowdra | eb45029 | 2020-10-26 10:03:39 -0700 | [diff] [blame] | 258 | logger.Infow(ctx, "Update_flows_incrementally", log.Fields{"device-id": device.Id, "flows": flows, "flowMetadata": flowMetadata}) |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 259 | if handler := oo.getDeviceHandler(device.Id); handler != nil { |
npujar | ec5762e | 2020-01-01 14:08:48 +0530 | [diff] [blame] | 260 | return handler.UpdateFlowsIncrementally(ctx, device, flows, groups, flowMetadata) |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 261 | } |
Girish Kumar | f26e488 | 2020-03-05 06:49:10 +0000 | [diff] [blame] | 262 | return olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": device.Id}, nil) |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 263 | } |
| 264 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 265 | //Update_pm_config returns PmConfigs nil or error |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 266 | func (oo *OpenOLT) Update_pm_config(ctx context.Context, device *voltha.Device, pmConfigs *voltha.PmConfigs) error { |
| 267 | logger.Debugw(ctx, "Update_pm_config", log.Fields{"device-id": device.Id, "pm-configs": pmConfigs}) |
Rohan Agrawal | da5e0b2 | 2020-05-20 11:10:26 +0000 | [diff] [blame] | 268 | if handler := oo.getDeviceHandler(device.Id); handler != nil { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 269 | handler.UpdatePmConfig(ctx, pmConfigs) |
Rohan Agrawal | da5e0b2 | 2020-05-20 11:10:26 +0000 | [diff] [blame] | 270 | return nil |
| 271 | } |
| 272 | return olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": device.Id}, nil) |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 273 | } |
| 274 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 275 | //Receive_packet_out sends packet out to the device |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 276 | func (oo *OpenOLT) Receive_packet_out(ctx context.Context, deviceID string, egressPortNo int, packet *openflow_13.OfpPacketOut) error { |
divyadesai | 3af43e1 | 2020-08-18 07:10:54 +0000 | [diff] [blame] | 277 | logger.Debugw(ctx, "Receive_packet_out", log.Fields{"device-id": deviceID, "egress_port_no": egressPortNo, "pkt": packet}) |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 278 | if handler := oo.getDeviceHandler(deviceID); handler != nil { |
npujar | ec5762e | 2020-01-01 14:08:48 +0530 | [diff] [blame] | 279 | return handler.PacketOut(ctx, egressPortNo, packet) |
manikkaraj k | 9eb6cac | 2019-05-09 12:32:03 -0400 | [diff] [blame] | 280 | } |
Girish Kumar | f26e488 | 2020-03-05 06:49:10 +0000 | [diff] [blame] | 281 | return olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": deviceID}, nil) |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 282 | } |
| 283 | |
Devmalya Paul | dd23a99 | 2019-11-14 07:06:31 +0000 | [diff] [blame] | 284 | //Suppress_event unimplemented |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 285 | func (oo *OpenOLT) Suppress_event(ctx context.Context, filter *voltha.EventFilter) error { |
Thomas Lee S | 94109f1 | 2020-03-03 16:39:29 +0530 | [diff] [blame] | 286 | return olterrors.ErrNotImplemented |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 287 | } |
| 288 | |
Devmalya Paul | dd23a99 | 2019-11-14 07:06:31 +0000 | [diff] [blame] | 289 | //Unsuppress_event unimplemented |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 290 | func (oo *OpenOLT) Unsuppress_event(ctx context.Context, filter *voltha.EventFilter) error { |
Thomas Lee S | 94109f1 | 2020-03-03 16:39:29 +0530 | [diff] [blame] | 291 | return olterrors.ErrNotImplemented |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 292 | } |
| 293 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 294 | //Download_image unimplemented |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 295 | func (oo *OpenOLT) Download_image(ctx context.Context, device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) { |
Thomas Lee S | 94109f1 | 2020-03-03 16:39:29 +0530 | [diff] [blame] | 296 | return nil, olterrors.ErrNotImplemented |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 297 | } |
| 298 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 299 | //Get_image_download_status unimplemented |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 300 | func (oo *OpenOLT) Get_image_download_status(ctx context.Context, device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) { |
Thomas Lee S | 94109f1 | 2020-03-03 16:39:29 +0530 | [diff] [blame] | 301 | return nil, olterrors.ErrNotImplemented |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 302 | } |
| 303 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 304 | //Cancel_image_download unimplemented |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 305 | func (oo *OpenOLT) Cancel_image_download(ctx context.Context, device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) { |
Thomas Lee S | 94109f1 | 2020-03-03 16:39:29 +0530 | [diff] [blame] | 306 | return nil, olterrors.ErrNotImplemented |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 307 | } |
| 308 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 309 | //Activate_image_update unimplemented |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 310 | func (oo *OpenOLT) Activate_image_update(ctx context.Context, device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) { |
Thomas Lee S | 94109f1 | 2020-03-03 16:39:29 +0530 | [diff] [blame] | 311 | return nil, olterrors.ErrNotImplemented |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 312 | } |
| 313 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 314 | //Revert_image_update unimplemented |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 315 | func (oo *OpenOLT) Revert_image_update(ctx context.Context, device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) { |
Thomas Lee S | 94109f1 | 2020-03-03 16:39:29 +0530 | [diff] [blame] | 316 | return nil, olterrors.ErrNotImplemented |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 317 | } |
kesavand | 39e0aa3 | 2020-01-28 20:58:50 -0500 | [diff] [blame] | 318 | |
Girish Gowdra | c1b9d5e | 2021-04-22 12:47:44 -0700 | [diff] [blame] | 319 | //Download_onu_image unimplemented |
| 320 | func (oo *OpenOLT) Download_onu_image(ctx context.Context, request *voltha.DeviceImageDownloadRequest) (*voltha.DeviceImageResponse, error) { |
| 321 | return nil, olterrors.ErrNotImplemented |
| 322 | } |
| 323 | |
| 324 | //Get_onu_image_status unimplemented |
| 325 | func (oo *OpenOLT) Get_onu_image_status(ctx context.Context, in *voltha.DeviceImageRequest) (*voltha.DeviceImageResponse, error) { |
| 326 | return nil, olterrors.ErrNotImplemented |
| 327 | } |
| 328 | |
| 329 | //Abort_onu_image_upgrade unimplemented |
| 330 | func (oo *OpenOLT) Abort_onu_image_upgrade(ctx context.Context, in *voltha.DeviceImageRequest) (*voltha.DeviceImageResponse, error) { |
| 331 | return nil, olterrors.ErrNotImplemented |
| 332 | } |
| 333 | |
| 334 | //Get_onu_images unimplemented |
| 335 | func (oo *OpenOLT) Get_onu_images(ctx context.Context, deviceID string) (*voltha.OnuImages, error) { |
| 336 | return nil, olterrors.ErrNotImplemented |
| 337 | } |
| 338 | |
| 339 | //Activate_onu_image unimplemented |
| 340 | func (oo *OpenOLT) Activate_onu_image(ctx context.Context, in *voltha.DeviceImageRequest) (*voltha.DeviceImageResponse, error) { |
| 341 | return nil, olterrors.ErrNotImplemented |
| 342 | } |
| 343 | |
| 344 | //Commit_onu_image unimplemented |
| 345 | func (oo *OpenOLT) Commit_onu_image(ctx context.Context, in *voltha.DeviceImageRequest) (*voltha.DeviceImageResponse, error) { |
| 346 | return nil, olterrors.ErrNotImplemented |
| 347 | } |
| 348 | |
kesavand | 39e0aa3 | 2020-01-28 20:58:50 -0500 | [diff] [blame] | 349 | // Enable_port to Enable PON/NNI interface |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 350 | func (oo *OpenOLT) Enable_port(ctx context.Context, deviceID string, port *voltha.Port) error { |
divyadesai | 3af43e1 | 2020-08-18 07:10:54 +0000 | [diff] [blame] | 351 | logger.Infow(ctx, "Enable_port", log.Fields{"device-id": deviceID, "port": port}) |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 352 | return oo.enableDisablePort(ctx, deviceID, port, true) |
kesavand | 39e0aa3 | 2020-01-28 20:58:50 -0500 | [diff] [blame] | 353 | } |
| 354 | |
| 355 | // Disable_port to Disable pon/nni interface |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 356 | func (oo *OpenOLT) Disable_port(ctx context.Context, deviceID string, port *voltha.Port) error { |
divyadesai | 3af43e1 | 2020-08-18 07:10:54 +0000 | [diff] [blame] | 357 | logger.Infow(ctx, "Disable_port", log.Fields{"device-id": deviceID, "port": port}) |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 358 | return oo.enableDisablePort(ctx, deviceID, port, false) |
kesavand | 39e0aa3 | 2020-01-28 20:58:50 -0500 | [diff] [blame] | 359 | } |
| 360 | |
| 361 | // enableDisablePort to Disable pon or Enable PON interface |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 362 | func (oo *OpenOLT) enableDisablePort(ctx context.Context, deviceID string, port *voltha.Port, enablePort bool) error { |
divyadesai | 3af43e1 | 2020-08-18 07:10:54 +0000 | [diff] [blame] | 363 | logger.Infow(ctx, "enableDisablePort", log.Fields{"device-id": deviceID, "port": port}) |
kesavand | 39e0aa3 | 2020-01-28 20:58:50 -0500 | [diff] [blame] | 364 | if port == nil { |
Thomas Lee S | 94109f1 | 2020-03-03 16:39:29 +0530 | [diff] [blame] | 365 | return olterrors.NewErrInvalidValue(log.Fields{ |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 366 | "reason": "port cannot be nil", |
| 367 | "device-id": deviceID, |
Girish Kumar | f26e488 | 2020-03-05 06:49:10 +0000 | [diff] [blame] | 368 | "port": nil}, nil) |
kesavand | 39e0aa3 | 2020-01-28 20:58:50 -0500 | [diff] [blame] | 369 | } |
| 370 | if handler := oo.getDeviceHandler(deviceID); handler != nil { |
divyadesai | 3af43e1 | 2020-08-18 07:10:54 +0000 | [diff] [blame] | 371 | logger.Debugw(ctx, "Enable_Disable_Port", log.Fields{"device-id": deviceID, "port": port}) |
kesavand | 39e0aa3 | 2020-01-28 20:58:50 -0500 | [diff] [blame] | 372 | if enablePort { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 373 | if err := handler.EnablePort(ctx, port); err != nil { |
divyadesai | 3af43e1 | 2020-08-18 07:10:54 +0000 | [diff] [blame] | 374 | return olterrors.NewErrAdapter("error-occurred-during-enable-port", log.Fields{"device-id": deviceID, "port": port}, err) |
kesavand | 39e0aa3 | 2020-01-28 20:58:50 -0500 | [diff] [blame] | 375 | } |
| 376 | } else { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 377 | if err := handler.DisablePort(ctx, port); err != nil { |
divyadesai | 3af43e1 | 2020-08-18 07:10:54 +0000 | [diff] [blame] | 378 | return olterrors.NewErrAdapter("error-occurred-during-disable-port", log.Fields{"device-id": deviceID, "port": port}, err) |
kesavand | 39e0aa3 | 2020-01-28 20:58:50 -0500 | [diff] [blame] | 379 | } |
| 380 | } |
| 381 | } |
| 382 | return nil |
| 383 | } |
Chaitrashree G S | 1a55b88 | 2020-02-04 17:35:35 -0500 | [diff] [blame] | 384 | |
| 385 | //Child_device_lost deletes the ONU and its references from PONResources |
Girish Gowdra | a087056 | 2021-03-11 14:30:14 -0800 | [diff] [blame] | 386 | func (oo *OpenOLT) Child_device_lost(ctx context.Context, childDevice *voltha.Device) error { |
| 387 | logger.Infow(ctx, "Child-device-lost", log.Fields{"parent-device-id": childDevice.ParentId, "child-device-id": childDevice.Id}) |
| 388 | if handler := oo.getDeviceHandler(childDevice.ParentId); handler != nil { |
| 389 | return handler.ChildDeviceLost(ctx, childDevice.ParentPortNo, childDevice.ProxyAddress.OnuId, childDevice.SerialNumber) |
Chaitrashree G S | 1a55b88 | 2020-02-04 17:35:35 -0500 | [diff] [blame] | 390 | } |
Girish Gowdra | a087056 | 2021-03-11 14:30:14 -0800 | [diff] [blame] | 391 | return olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": childDevice.ParentId}, nil).Log() |
Chaitrashree G S | 1a55b88 | 2020-02-04 17:35:35 -0500 | [diff] [blame] | 392 | } |
Scott Baker | 24f83e2 | 2020-03-30 16:14:28 -0700 | [diff] [blame] | 393 | |
| 394 | //Start_omci_test not implemented |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 395 | func (oo *OpenOLT) Start_omci_test(ctx context.Context, device *voltha.Device, request *voltha.OmciTestRequest) (*voltha.TestResponse, error) { |
Scott Baker | 24f83e2 | 2020-03-30 16:14:28 -0700 | [diff] [blame] | 396 | return nil, olterrors.ErrNotImplemented |
| 397 | } |
Dinesh Belwalkar | db587af | 2020-02-27 15:37:16 -0800 | [diff] [blame] | 398 | |
Andrea Campanella | 9931ad6 | 2020-04-28 15:11:06 +0200 | [diff] [blame] | 399 | //Get_ext_value retrieves a value on a particular ONU |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 400 | func (oo *OpenOLT) Get_ext_value(ctx context.Context, deviceID string, device *voltha.Device, valueparam voltha.ValueType_Type) (*voltha.ReturnValues, error) { |
Dinesh Belwalkar | db587af | 2020-02-27 15:37:16 -0800 | [diff] [blame] | 401 | var err error |
| 402 | resp := new(voltha.ReturnValues) |
Girish Kumar | a1ea2aa | 2020-08-19 18:14:22 +0000 | [diff] [blame] | 403 | logger.Infow(ctx, "Get_ext_value", log.Fields{"device-id": deviceID, "onu-id": device.Id}) |
Dinesh Belwalkar | db587af | 2020-02-27 15:37:16 -0800 | [diff] [blame] | 404 | if handler := oo.getDeviceHandler(deviceID); handler != nil { |
Neha Sharma | 8f4e432 | 2020-08-06 10:51:53 +0000 | [diff] [blame] | 405 | if resp, err = handler.getExtValue(ctx, device, valueparam); err != nil { |
Girish Kumar | a1ea2aa | 2020-08-19 18:14:22 +0000 | [diff] [blame] | 406 | logger.Errorw(ctx, "error-occurred-during-get-ext-value", log.Fields{"device-id": deviceID, "onu-id": device.Id, |
Dinesh Belwalkar | db587af | 2020-02-27 15:37:16 -0800 | [diff] [blame] | 407 | "error": err}) |
| 408 | return nil, err |
| 409 | } |
| 410 | } |
| 411 | return resp, nil |
| 412 | } |
kesavand | 6212621 | 2021-01-12 04:56:06 -0500 | [diff] [blame] | 413 | |
| 414 | //Single_get_value_request handles get uni status on ONU and ondemand metric on OLT |
| 415 | func (oo *OpenOLT) Single_get_value_request(ctx context.Context, request extension.SingleGetValueRequest) (*extension.SingleGetValueResponse, error) { |
| 416 | logger.Infow(ctx, "Single_get_value_request", log.Fields{"request": request}) |
| 417 | |
| 418 | errResp := func(status extension.GetValueResponse_Status, |
| 419 | reason extension.GetValueResponse_ErrorReason) *extension.SingleGetValueResponse { |
| 420 | return &extension.SingleGetValueResponse{ |
| 421 | Response: &extension.GetValueResponse{ |
| 422 | Status: status, |
| 423 | ErrReason: reason, |
| 424 | }, |
| 425 | } |
| 426 | } |
| 427 | if handler := oo.getDeviceHandler(request.TargetId); handler != nil { |
| 428 | switch reqType := request.GetRequest().GetRequest().(type) { |
| 429 | case *extension.GetValueRequest_OltPortInfo: |
| 430 | return handler.getOltPortCounters(ctx, reqType.OltPortInfo), nil |
| 431 | default: |
| 432 | return errResp(extension.GetValueResponse_ERROR, extension.GetValueResponse_UNSUPPORTED), nil |
| 433 | } |
| 434 | } |
| 435 | |
| 436 | logger.Infow(ctx, "Single_get_value_request failed ", log.Fields{"request": request}) |
| 437 | return errResp(extension.GetValueResponse_ERROR, extension.GetValueResponse_INVALID_DEVICE_ID), nil |
| 438 | } |