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" |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 22 | "errors" |
khenaidoo | efff76e | 2021-12-15 16:51:30 -0500 | [diff] [blame] | 23 | "fmt" |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 24 | "sync" |
Abhilash Laxmeshwar | f9942e9 | 2020-01-07 15:32:44 +0530 | [diff] [blame] | 25 | "time" |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 26 | |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 27 | "github.com/golang/protobuf/ptypes/empty" |
| 28 | conf "github.com/opencord/voltha-lib-go/v7/pkg/config" |
| 29 | "github.com/opencord/voltha-lib-go/v7/pkg/events/eventif" |
| 30 | vgrpc "github.com/opencord/voltha-lib-go/v7/pkg/grpc" |
| 31 | "github.com/opencord/voltha-lib-go/v7/pkg/log" |
Scott Baker | dbd960e | 2020-02-28 08:57:51 -0800 | [diff] [blame] | 32 | "github.com/opencord/voltha-openolt-adapter/internal/pkg/config" |
Thomas Lee S | 94109f1 | 2020-03-03 16:39:29 +0530 | [diff] [blame] | 33 | "github.com/opencord/voltha-openolt-adapter/internal/pkg/olterrors" |
khenaidoo | efff76e | 2021-12-15 16:51:30 -0500 | [diff] [blame] | 34 | "github.com/opencord/voltha-protos/v5/go/adapter_service" |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 35 | "github.com/opencord/voltha-protos/v5/go/common" |
khenaidoo | dc2116e | 2021-10-19 17:33:19 -0400 | [diff] [blame] | 36 | ca "github.com/opencord/voltha-protos/v5/go/core_adapter" |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 37 | "github.com/opencord/voltha-protos/v5/go/extension" |
khenaidoo | dc2116e | 2021-10-19 17:33:19 -0400 | [diff] [blame] | 38 | "github.com/opencord/voltha-protos/v5/go/health" |
| 39 | ia "github.com/opencord/voltha-protos/v5/go/inter_adapter" |
| 40 | "github.com/opencord/voltha-protos/v5/go/omci" |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 41 | "github.com/opencord/voltha-protos/v5/go/voltha" |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 42 | ) |
| 43 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 44 | //OpenOLT structure holds the OLT information |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 45 | type OpenOLT struct { |
Matteo Scandolo | dfa7a97 | 2020-11-06 13:03:40 -0800 | [diff] [blame] | 46 | configManager *conf.ConfigManager |
Abhilash Laxmeshwar | f9942e9 | 2020-01-07 15:32:44 +0530 | [diff] [blame] | 47 | deviceHandlers map[string]*DeviceHandler |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 48 | coreClient *vgrpc.Client |
Himani Chawla | cd40780 | 2020-12-10 12:08:59 +0530 | [diff] [blame] | 49 | eventProxy eventif.EventProxy |
Abhilash Laxmeshwar | f9942e9 | 2020-01-07 15:32:44 +0530 | [diff] [blame] | 50 | config *config.AdapterFlags |
| 51 | numOnus int |
Neha Sharma | 3f221ae | 2020-04-29 19:02:12 +0000 | [diff] [blame] | 52 | KVStoreAddress string |
Abhilash Laxmeshwar | f9942e9 | 2020-01-07 15:32:44 +0530 | [diff] [blame] | 53 | KVStoreType string |
khenaidoo | efff76e | 2021-12-15 16:51:30 -0500 | [diff] [blame] | 54 | exitChannel chan struct{} |
Abhilash Laxmeshwar | f9942e9 | 2020-01-07 15:32:44 +0530 | [diff] [blame] | 55 | HeartbeatCheckInterval time.Duration |
| 56 | HeartbeatFailReportInterval time.Duration |
| 57 | GrpcTimeoutInterval time.Duration |
| 58 | lockDeviceHandlersMap sync.RWMutex |
Gamze Abaka | fcbd6e7 | 2020-12-17 13:25:16 +0000 | [diff] [blame] | 59 | enableONUStats bool |
| 60 | enableGemStats bool |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 61 | rpcTimeout time.Duration |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 62 | } |
| 63 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 64 | //NewOpenOLT returns a new instance of OpenOLT |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 65 | func NewOpenOLT(ctx context.Context, |
| 66 | coreClient *vgrpc.Client, |
Himani Chawla | cd40780 | 2020-12-10 12:08:59 +0530 | [diff] [blame] | 67 | eventProxy eventif.EventProxy, cfg *config.AdapterFlags, cm *conf.ConfigManager) *OpenOLT { |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 68 | var openOLT OpenOLT |
khenaidoo | efff76e | 2021-12-15 16:51:30 -0500 | [diff] [blame] | 69 | openOLT.exitChannel = make(chan struct{}) |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 70 | openOLT.deviceHandlers = make(map[string]*DeviceHandler) |
Abhilash Laxmeshwar | f9942e9 | 2020-01-07 15:32:44 +0530 | [diff] [blame] | 71 | openOLT.config = cfg |
| 72 | openOLT.numOnus = cfg.OnuNumber |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 73 | openOLT.coreClient = coreClient |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 74 | openOLT.eventProxy = eventProxy |
Neha Sharma | 3f221ae | 2020-04-29 19:02:12 +0000 | [diff] [blame] | 75 | openOLT.KVStoreAddress = cfg.KVStoreAddress |
Abhilash Laxmeshwar | f9942e9 | 2020-01-07 15:32:44 +0530 | [diff] [blame] | 76 | openOLT.KVStoreType = cfg.KVStoreType |
| 77 | openOLT.HeartbeatCheckInterval = cfg.HeartbeatCheckInterval |
| 78 | openOLT.HeartbeatFailReportInterval = cfg.HeartbeatFailReportInterval |
| 79 | openOLT.GrpcTimeoutInterval = cfg.GrpcTimeoutInterval |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 80 | openOLT.lockDeviceHandlersMap = sync.RWMutex{} |
Matteo Scandolo | dfa7a97 | 2020-11-06 13:03:40 -0800 | [diff] [blame] | 81 | openOLT.configManager = cm |
Gamze Abaka | fcbd6e7 | 2020-12-17 13:25:16 +0000 | [diff] [blame] | 82 | openOLT.enableONUStats = cfg.EnableONUStats |
| 83 | openOLT.enableGemStats = cfg.EnableGEMStats |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 84 | openOLT.rpcTimeout = cfg.RPCTimeout |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 85 | return &openOLT |
| 86 | } |
| 87 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 88 | //Start starts (logs) the device manager |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 89 | func (oo *OpenOLT) Start(ctx context.Context) error { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 90 | logger.Info(ctx, "starting-device-manager") |
| 91 | logger.Info(ctx, "device-manager-started") |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 92 | return nil |
| 93 | } |
| 94 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 95 | //Stop terminates the session |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 96 | func (oo *OpenOLT) Stop(ctx context.Context) error { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 97 | logger.Info(ctx, "stopping-device-manager") |
khenaidoo | efff76e | 2021-12-15 16:51:30 -0500 | [diff] [blame] | 98 | close(oo.exitChannel) |
| 99 | // Stop the device handlers |
| 100 | oo.stopAllDeviceHandlers(ctx) |
| 101 | |
| 102 | // Stop the core grpc client connection |
| 103 | if oo.coreClient != nil { |
| 104 | oo.coreClient.Stop(ctx) |
| 105 | } |
| 106 | |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 107 | logger.Info(ctx, "device-manager-stopped") |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 108 | return nil |
| 109 | } |
| 110 | |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 111 | func (oo *OpenOLT) addDeviceHandlerToMap(agent *DeviceHandler) { |
| 112 | oo.lockDeviceHandlersMap.Lock() |
| 113 | defer oo.lockDeviceHandlersMap.Unlock() |
Thomas Lee S | 985938d | 2020-05-04 11:40:41 +0530 | [diff] [blame] | 114 | if _, exist := oo.deviceHandlers[agent.device.Id]; !exist { |
| 115 | oo.deviceHandlers[agent.device.Id] = agent |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 116 | } |
| 117 | } |
| 118 | |
| 119 | func (oo *OpenOLT) deleteDeviceHandlerToMap(agent *DeviceHandler) { |
| 120 | oo.lockDeviceHandlersMap.Lock() |
| 121 | defer oo.lockDeviceHandlersMap.Unlock() |
Thomas Lee S | 985938d | 2020-05-04 11:40:41 +0530 | [diff] [blame] | 122 | delete(oo.deviceHandlers, agent.device.Id) |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 123 | } |
| 124 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 125 | func (oo *OpenOLT) getDeviceHandler(deviceID string) *DeviceHandler { |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 126 | oo.lockDeviceHandlersMap.Lock() |
| 127 | defer oo.lockDeviceHandlersMap.Unlock() |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 128 | if agent, ok := oo.deviceHandlers[deviceID]; ok { |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 129 | return agent |
| 130 | } |
| 131 | return nil |
| 132 | } |
| 133 | |
khenaidoo | efff76e | 2021-12-15 16:51:30 -0500 | [diff] [blame] | 134 | func (oo *OpenOLT) stopAllDeviceHandlers(ctx context.Context) { |
| 135 | oo.lockDeviceHandlersMap.Lock() |
| 136 | defer oo.lockDeviceHandlersMap.Unlock() |
| 137 | for _, handler := range oo.deviceHandlers { |
| 138 | handler.Stop(ctx) |
| 139 | } |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 140 | } |
| 141 | |
| 142 | // AdoptDevice creates a new device handler if not present already and then adopts the device |
| 143 | func (oo *OpenOLT) AdoptDevice(ctx context.Context, device *voltha.Device) (*empty.Empty, error) { |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 144 | if device == nil { |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 145 | return nil, olterrors.NewErrInvalidValue(log.Fields{"device": nil}, nil).Log() |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 146 | } |
divyadesai | 3af43e1 | 2020-08-18 07:10:54 +0000 | [diff] [blame] | 147 | logger.Infow(ctx, "adopt-device", log.Fields{"device-id": device.Id}) |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 148 | var handler *DeviceHandler |
| 149 | if handler = oo.getDeviceHandler(device.Id); handler == nil { |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 150 | handler := NewDeviceHandler(oo.coreClient, oo.eventProxy, device, oo, oo.configManager, oo.config) |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 151 | oo.addDeviceHandlerToMap(handler) |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 152 | go handler.AdoptDevice(log.WithSpanFromContext(context.Background(), ctx), device) |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 153 | } |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 154 | return &empty.Empty{}, nil |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 155 | } |
| 156 | |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 157 | //GetOfpDeviceInfo returns OFP information for the given device |
khenaidoo | dc2116e | 2021-10-19 17:33:19 -0400 | [diff] [blame] | 158 | func (oo *OpenOLT) GetOfpDeviceInfo(ctx context.Context, device *voltha.Device) (*ca.SwitchCapability, error) { |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 159 | 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] | 160 | if handler := oo.getDeviceHandler(device.Id); handler != nil { |
| 161 | return handler.GetOfpDeviceInfo(device) |
| 162 | } |
Girish Kumar | f26e488 | 2020-03-05 06:49:10 +0000 | [diff] [blame] | 163 | 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] | 164 | } |
| 165 | |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 166 | //ReconcileDevice unimplemented |
| 167 | func (oo *OpenOLT) ReconcileDevice(ctx context.Context, device *voltha.Device) (*empty.Empty, error) { |
Abhilash Laxmeshwar | ab0bd52 | 2019-10-21 15:05:15 +0530 | [diff] [blame] | 168 | if device == nil { |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 169 | return nil, olterrors.NewErrInvalidValue(log.Fields{"device": nil}, nil) |
Abhilash Laxmeshwar | ab0bd52 | 2019-10-21 15:05:15 +0530 | [diff] [blame] | 170 | } |
divyadesai | 3af43e1 | 2020-08-18 07:10:54 +0000 | [diff] [blame] | 171 | logger.Infow(ctx, "reconcile-device", log.Fields{"device-id": device.Id}) |
Abhilash Laxmeshwar | ab0bd52 | 2019-10-21 15:05:15 +0530 | [diff] [blame] | 172 | var handler *DeviceHandler |
| 173 | if handler = oo.getDeviceHandler(device.Id); handler == nil { |
Maninder | e49938d | 2021-03-19 00:23:24 +0530 | [diff] [blame] | 174 | //Setting state to RECONCILING |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 175 | cgClient, err := oo.coreClient.GetCoreServiceClient() |
Maninder | e49938d | 2021-03-19 00:23:24 +0530 | [diff] [blame] | 176 | if err != nil { |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 177 | return nil, err |
Maninder | e49938d | 2021-03-19 00:23:24 +0530 | [diff] [blame] | 178 | } |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 179 | subCtx, cancel := context.WithTimeout(log.WithSpanFromContext(context.Background(), ctx), oo.rpcTimeout) |
| 180 | defer cancel() |
khenaidoo | dc2116e | 2021-10-19 17:33:19 -0400 | [diff] [blame] | 181 | if _, err := cgClient.DeviceStateUpdate(subCtx, &ca.DeviceStateFilter{ |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 182 | DeviceId: device.Id, |
| 183 | OperStatus: voltha.OperStatus_RECONCILING, |
| 184 | ConnStatus: device.ConnectStatus, |
| 185 | }); err != nil { |
| 186 | return nil, olterrors.NewErrAdapter("device-update-failed", log.Fields{"device-id": device.Id}, err) |
| 187 | } |
| 188 | |
Girish Gowdra | 0fb24a3 | 2021-10-27 15:15:27 -0700 | [diff] [blame] | 189 | // The OperState of the device is set to RECONCILING in the previous section. This also needs to be set on the |
| 190 | // locally cached copy of the device struct. |
| 191 | device.OperStatus = voltha.OperStatus_RECONCILING |
| 192 | handler := NewDeviceHandler(oo.coreClient, oo.eventProxy, device, oo, oo.configManager, oo.config) |
| 193 | handler.adapterPreviouslyConnected = true |
| 194 | oo.addDeviceHandlerToMap(handler) |
| 195 | handler.transitionMap = NewTransitionMap(handler) |
| 196 | |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 197 | handler.transitionMap.Handle(log.WithSpanFromContext(context.Background(), ctx), DeviceInit) |
Abhilash Laxmeshwar | ab0bd52 | 2019-10-21 15:05:15 +0530 | [diff] [blame] | 198 | } |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 199 | return &empty.Empty{}, nil |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 200 | } |
| 201 | |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 202 | //DisableDevice disables the given device |
| 203 | func (oo *OpenOLT) DisableDevice(ctx context.Context, device *voltha.Device) (*empty.Empty, error) { |
divyadesai | 3af43e1 | 2020-08-18 07:10:54 +0000 | [diff] [blame] | 204 | logger.Infow(ctx, "disable-device", log.Fields{"device-id": device.Id}) |
Girish Gowdru | 5ba46c9 | 2019-04-25 05:00:05 -0400 | [diff] [blame] | 205 | if handler := oo.getDeviceHandler(device.Id); handler != nil { |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 206 | if err := handler.DisableDevice(log.WithSpanFromContext(context.Background(), ctx), device); err != nil { |
| 207 | return nil, err |
| 208 | } |
| 209 | return &empty.Empty{}, nil |
Girish Gowdru | 5ba46c9 | 2019-04-25 05:00:05 -0400 | [diff] [blame] | 210 | } |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 211 | 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] | 212 | } |
| 213 | |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 214 | //ReEnableDevice enables the olt device after disable |
| 215 | func (oo *OpenOLT) ReEnableDevice(ctx context.Context, device *voltha.Device) (*empty.Empty, error) { |
divyadesai | 3af43e1 | 2020-08-18 07:10:54 +0000 | [diff] [blame] | 216 | logger.Infow(ctx, "reenable-device", log.Fields{"device-id": device.Id}) |
Girish Gowdru | 5ba46c9 | 2019-04-25 05:00:05 -0400 | [diff] [blame] | 217 | if handler := oo.getDeviceHandler(device.Id); handler != nil { |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 218 | if err := handler.ReenableDevice(log.WithSpanFromContext(context.Background(), ctx), device); err != nil { |
| 219 | return nil, err |
| 220 | } |
| 221 | return &empty.Empty{}, nil |
Girish Gowdru | 5ba46c9 | 2019-04-25 05:00:05 -0400 | [diff] [blame] | 222 | } |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 223 | 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] | 224 | } |
| 225 | |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 226 | //RebootDevice reboots the given device |
| 227 | func (oo *OpenOLT) RebootDevice(ctx context.Context, device *voltha.Device) (*empty.Empty, error) { |
divyadesai | 3af43e1 | 2020-08-18 07:10:54 +0000 | [diff] [blame] | 228 | logger.Infow(ctx, "reboot-device", log.Fields{"device-id": device.Id}) |
Girish Gowdru | 0fe5f7e | 2019-05-28 05:12:27 -0400 | [diff] [blame] | 229 | if handler := oo.getDeviceHandler(device.Id); handler != nil { |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 230 | if err := handler.RebootDevice(log.WithSpanFromContext(context.Background(), ctx), device); err != nil { |
| 231 | return nil, err |
| 232 | } |
| 233 | return &empty.Empty{}, nil |
Girish Gowdru | 0fe5f7e | 2019-05-28 05:12:27 -0400 | [diff] [blame] | 234 | } |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 235 | return nil, olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": device.Id}, nil) |
| 236 | |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 237 | } |
| 238 | |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 239 | //DeleteDevice deletes a device |
| 240 | func (oo *OpenOLT) DeleteDevice(ctx context.Context, device *voltha.Device) (*empty.Empty, error) { |
divyadesai | 3af43e1 | 2020-08-18 07:10:54 +0000 | [diff] [blame] | 241 | logger.Infow(ctx, "delete-device", log.Fields{"device-id": device.Id}) |
Devmalya Paul | 495b94a | 2019-08-27 19:42:00 -0400 | [diff] [blame] | 242 | if handler := oo.getDeviceHandler(device.Id); handler != nil { |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 243 | if err := handler.DeleteDevice(log.WithSpanFromContext(context.Background(), ctx), device); err != nil { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 244 | 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] | 245 | } |
| 246 | oo.deleteDeviceHandlerToMap(handler) |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 247 | return &empty.Empty{}, nil |
Devmalya Paul | 495b94a | 2019-08-27 19:42:00 -0400 | [diff] [blame] | 248 | } |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 249 | 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] | 250 | } |
| 251 | |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 252 | //UpdateFlowsIncrementally updates (add/remove) the flows on a given device |
khenaidoo | dc2116e | 2021-10-19 17:33:19 -0400 | [diff] [blame] | 253 | func (oo *OpenOLT) UpdateFlowsIncrementally(ctx context.Context, incrFlows *ca.IncrementalFlows) (*empty.Empty, error) { |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 254 | logger.Infow(ctx, "update_flows_incrementally", log.Fields{"device-id": incrFlows.Device.Id, "flows": incrFlows.Flows, "flowMetadata": incrFlows.FlowMetadata}) |
| 255 | if handler := oo.getDeviceHandler(incrFlows.Device.Id); handler != nil { |
| 256 | if err := handler.UpdateFlowsIncrementally(log.WithSpanFromContext(context.Background(), ctx), incrFlows.Device, incrFlows.Flows, incrFlows.Groups, incrFlows.FlowMetadata); err != nil { |
| 257 | return nil, err |
| 258 | } |
| 259 | return &empty.Empty{}, nil |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 260 | } |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 261 | return nil, olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": incrFlows.Device.Id}, nil) |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 262 | } |
| 263 | |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 264 | //UpdatePmConfig returns PmConfigs nil or error |
khenaidoo | dc2116e | 2021-10-19 17:33:19 -0400 | [diff] [blame] | 265 | func (oo *OpenOLT) UpdatePmConfig(ctx context.Context, configs *ca.PmConfigsInfo) (*empty.Empty, error) { |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 266 | logger.Debugw(ctx, "update_pm_config", log.Fields{"device-id": configs.DeviceId, "pm-configs": configs.PmConfigs}) |
| 267 | if handler := oo.getDeviceHandler(configs.DeviceId); handler != nil { |
| 268 | handler.UpdatePmConfig(log.WithSpanFromContext(context.Background(), ctx), configs.PmConfigs) |
| 269 | return &empty.Empty{}, nil |
Rohan Agrawal | da5e0b2 | 2020-05-20 11:10:26 +0000 | [diff] [blame] | 270 | } |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 271 | return nil, olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": configs.DeviceId}, nil) |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 272 | } |
| 273 | |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 274 | //SendPacketOut sends packet out to the device |
khenaidoo | dc2116e | 2021-10-19 17:33:19 -0400 | [diff] [blame] | 275 | func (oo *OpenOLT) SendPacketOut(ctx context.Context, packet *ca.PacketOut) (*empty.Empty, error) { |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 276 | logger.Debugw(ctx, "send_packet_out", log.Fields{"device-id": packet.DeviceId, "egress_port_no": packet.EgressPortNo, "pkt": packet.Packet}) |
| 277 | if handler := oo.getDeviceHandler(packet.DeviceId); handler != nil { |
| 278 | if err := handler.PacketOut(log.WithSpanFromContext(context.Background(), ctx), packet.EgressPortNo, packet.Packet); err != nil { |
| 279 | return nil, err |
| 280 | } |
| 281 | return &empty.Empty{}, nil |
manikkaraj k | 9eb6cac | 2019-05-09 12:32:03 -0400 | [diff] [blame] | 282 | } |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 283 | return nil, olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": packet.DeviceId}, nil) |
| 284 | |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 285 | } |
| 286 | |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 287 | // EnablePort to Enable PON/NNI interface |
| 288 | func (oo *OpenOLT) EnablePort(ctx context.Context, port *voltha.Port) (*empty.Empty, error) { |
| 289 | logger.Infow(ctx, "enable_port", log.Fields{"device-id": port.DeviceId, "port": port}) |
| 290 | if err := oo.enableDisablePort(log.WithSpanFromContext(context.Background(), ctx), port.DeviceId, port, true); err != nil { |
| 291 | return nil, err |
| 292 | } |
| 293 | return &empty.Empty{}, nil |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 294 | } |
| 295 | |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 296 | // DisablePort to Disable pon/nni interface |
| 297 | func (oo *OpenOLT) DisablePort(ctx context.Context, port *voltha.Port) (*empty.Empty, error) { |
| 298 | logger.Infow(ctx, "disable_port", log.Fields{"device-id": port.DeviceId, "port": port}) |
| 299 | if err := oo.enableDisablePort(log.WithSpanFromContext(context.Background(), ctx), port.DeviceId, port, false); err != nil { |
| 300 | return nil, err |
| 301 | } |
| 302 | return &empty.Empty{}, nil |
kesavand | 39e0aa3 | 2020-01-28 20:58:50 -0500 | [diff] [blame] | 303 | } |
| 304 | |
| 305 | // enableDisablePort to Disable pon or Enable PON interface |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 306 | 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] | 307 | logger.Infow(ctx, "enableDisablePort", log.Fields{"device-id": deviceID, "port": port}) |
kesavand | 39e0aa3 | 2020-01-28 20:58:50 -0500 | [diff] [blame] | 308 | if port == nil { |
Thomas Lee S | 94109f1 | 2020-03-03 16:39:29 +0530 | [diff] [blame] | 309 | return olterrors.NewErrInvalidValue(log.Fields{ |
David K. Bainbridge | 794735f | 2020-02-11 21:01:37 -0800 | [diff] [blame] | 310 | "reason": "port cannot be nil", |
| 311 | "device-id": deviceID, |
Girish Kumar | f26e488 | 2020-03-05 06:49:10 +0000 | [diff] [blame] | 312 | "port": nil}, nil) |
kesavand | 39e0aa3 | 2020-01-28 20:58:50 -0500 | [diff] [blame] | 313 | } |
| 314 | if handler := oo.getDeviceHandler(deviceID); handler != nil { |
divyadesai | 3af43e1 | 2020-08-18 07:10:54 +0000 | [diff] [blame] | 315 | logger.Debugw(ctx, "Enable_Disable_Port", log.Fields{"device-id": deviceID, "port": port}) |
kesavand | 39e0aa3 | 2020-01-28 20:58:50 -0500 | [diff] [blame] | 316 | if enablePort { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 317 | if err := handler.EnablePort(ctx, port); err != nil { |
divyadesai | 3af43e1 | 2020-08-18 07:10:54 +0000 | [diff] [blame] | 318 | 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] | 319 | } |
| 320 | } else { |
Neha Sharma | 96b7bf2 | 2020-06-15 10:37:32 +0000 | [diff] [blame] | 321 | if err := handler.DisablePort(ctx, port); err != nil { |
divyadesai | 3af43e1 | 2020-08-18 07:10:54 +0000 | [diff] [blame] | 322 | 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] | 323 | } |
| 324 | } |
| 325 | } |
| 326 | return nil |
| 327 | } |
Chaitrashree G S | 1a55b88 | 2020-02-04 17:35:35 -0500 | [diff] [blame] | 328 | |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 329 | //ChildDeviceLost deletes the ONU and its references from PONResources |
| 330 | func (oo *OpenOLT) ChildDeviceLost(ctx context.Context, childDevice *voltha.Device) (*empty.Empty, error) { |
Girish Gowdra | a087056 | 2021-03-11 14:30:14 -0800 | [diff] [blame] | 331 | logger.Infow(ctx, "Child-device-lost", log.Fields{"parent-device-id": childDevice.ParentId, "child-device-id": childDevice.Id}) |
| 332 | if handler := oo.getDeviceHandler(childDevice.ParentId); handler != nil { |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 333 | if err := handler.ChildDeviceLost(log.WithSpanFromContext(context.Background(), ctx), childDevice.ParentPortNo, childDevice.ProxyAddress.OnuId, childDevice.SerialNumber); err != nil { |
| 334 | return nil, err |
| 335 | } |
| 336 | return &empty.Empty{}, nil |
Chaitrashree G S | 1a55b88 | 2020-02-04 17:35:35 -0500 | [diff] [blame] | 337 | } |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 338 | return nil, olterrors.NewErrNotFound("device-handler", log.Fields{"parent-device-id": childDevice.ParentId}, nil).Log() |
Chaitrashree G S | 1a55b88 | 2020-02-04 17:35:35 -0500 | [diff] [blame] | 339 | } |
Scott Baker | 24f83e2 | 2020-03-30 16:14:28 -0700 | [diff] [blame] | 340 | |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 341 | // GetExtValue retrieves a value on a particular ONU |
khenaidoo | dc2116e | 2021-10-19 17:33:19 -0400 | [diff] [blame] | 342 | func (oo *OpenOLT) GetExtValue(ctx context.Context, extInfo *ca.GetExtValueMessage) (*extension.ReturnValues, error) { |
Dinesh Belwalkar | db587af | 2020-02-27 15:37:16 -0800 | [diff] [blame] | 343 | var err error |
khenaidoo | dc2116e | 2021-10-19 17:33:19 -0400 | [diff] [blame] | 344 | resp := new(extension.ReturnValues) |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 345 | logger.Infow(ctx, "get_ext_value", log.Fields{"parent-device-id": extInfo.ParentDevice.Id, "onu-id": extInfo.ChildDevice.Id}) |
| 346 | if handler := oo.getDeviceHandler(extInfo.ParentDevice.Id); handler != nil { |
| 347 | if resp, err = handler.getExtValue(ctx, extInfo.ChildDevice, extInfo.ValueType); err != nil { |
| 348 | logger.Errorw(ctx, "error-occurred-during-get-ext-value", |
| 349 | log.Fields{"parent-device-id": extInfo.ParentDevice.Id, "onu-id": extInfo.ChildDevice.Id, "error": err}) |
Dinesh Belwalkar | db587af | 2020-02-27 15:37:16 -0800 | [diff] [blame] | 350 | return nil, err |
| 351 | } |
| 352 | } |
| 353 | return resp, nil |
| 354 | } |
kesavand | 6212621 | 2021-01-12 04:56:06 -0500 | [diff] [blame] | 355 | |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 356 | //GetSingleValue handles get uni status on ONU and ondemand metric on OLT |
| 357 | func (oo *OpenOLT) GetSingleValue(ctx context.Context, request *extension.SingleGetValueRequest) (*extension.SingleGetValueResponse, error) { |
| 358 | logger.Infow(ctx, "single_get_value_request", log.Fields{"request": request}) |
kesavand | 6212621 | 2021-01-12 04:56:06 -0500 | [diff] [blame] | 359 | |
| 360 | errResp := func(status extension.GetValueResponse_Status, |
| 361 | reason extension.GetValueResponse_ErrorReason) *extension.SingleGetValueResponse { |
| 362 | return &extension.SingleGetValueResponse{ |
| 363 | Response: &extension.GetValueResponse{ |
| 364 | Status: status, |
| 365 | ErrReason: reason, |
| 366 | }, |
| 367 | } |
| 368 | } |
| 369 | if handler := oo.getDeviceHandler(request.TargetId); handler != nil { |
| 370 | switch reqType := request.GetRequest().GetRequest().(type) { |
| 371 | case *extension.GetValueRequest_OltPortInfo: |
| 372 | return handler.getOltPortCounters(ctx, reqType.OltPortInfo), nil |
Himani Chawla | 2c8ae0f | 2021-05-18 23:27:00 +0530 | [diff] [blame] | 373 | case *extension.GetValueRequest_OnuPonInfo: |
| 374 | return handler.getOnuPonCounters(ctx, reqType.OnuPonInfo), nil |
Gamze Abaka | 85e9a14 | 2021-05-26 13:41:39 +0000 | [diff] [blame] | 375 | case *extension.GetValueRequest_RxPower: |
| 376 | return handler.getRxPower(ctx, reqType.RxPower), nil |
kesavand | 6212621 | 2021-01-12 04:56:06 -0500 | [diff] [blame] | 377 | default: |
| 378 | return errResp(extension.GetValueResponse_ERROR, extension.GetValueResponse_UNSUPPORTED), nil |
| 379 | } |
| 380 | } |
| 381 | |
| 382 | logger.Infow(ctx, "Single_get_value_request failed ", log.Fields{"request": request}) |
| 383 | return errResp(extension.GetValueResponse_ERROR, extension.GetValueResponse_INVALID_DEVICE_ID), nil |
| 384 | } |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 385 | |
| 386 | /* |
| 387 | * OLT Inter-adapter service |
| 388 | */ |
| 389 | |
kesavand | b9f54fd | 2021-11-25 20:08:04 +0530 | [diff] [blame] | 390 | // ProxyOmciRequests proxies an onu sw download OMCI request from the child adapter |
| 391 | func (oo *OpenOLT) ProxyOmciRequests(ctx context.Context, request *ia.OmciMessages) (*empty.Empty, error) { |
| 392 | if handler := oo.getDeviceHandler(request.ParentDeviceId); handler != nil { |
| 393 | if err := handler.ProxyOmciRequests(ctx, request); err != nil { |
| 394 | return nil, errors.New(err.Error()) |
| 395 | } |
| 396 | return &empty.Empty{}, nil |
| 397 | } |
| 398 | return nil, olterrors.NewErrNotFound("no-device-handler", log.Fields{"parent-device-id": request.ParentDeviceId, "child-device-id": request.ChildDeviceId}, nil).Log() |
| 399 | } |
| 400 | |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 401 | // ProxyOmciRequest proxies an OMCI request from the child adapter |
khenaidoo | dc2116e | 2021-10-19 17:33:19 -0400 | [diff] [blame] | 402 | func (oo *OpenOLT) ProxyOmciRequest(ctx context.Context, request *ia.OmciMessage) (*empty.Empty, error) { |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 403 | logger.Debugw(ctx, "proxy-omci-request", log.Fields{"request": request}) |
| 404 | |
| 405 | if handler := oo.getDeviceHandler(request.ParentDeviceId); handler != nil { |
| 406 | if err := handler.ProxyOmciMessage(ctx, request); err != nil { |
| 407 | return nil, errors.New(err.Error()) |
| 408 | } |
| 409 | return &empty.Empty{}, nil |
| 410 | } |
| 411 | return nil, olterrors.NewErrNotFound("no-device-handler", log.Fields{"parent-device-id": request.ParentDeviceId, "child-device-id": request.ChildDeviceId}, nil).Log() |
| 412 | } |
| 413 | |
| 414 | // GetTechProfileInstance returns an instance of a tech profile |
khenaidoo | dc2116e | 2021-10-19 17:33:19 -0400 | [diff] [blame] | 415 | func (oo *OpenOLT) GetTechProfileInstance(ctx context.Context, request *ia.TechProfileInstanceRequestMessage) (*ia.TechProfileDownloadMessage, error) { |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 416 | logger.Debugw(ctx, "getting-tech-profile-request", log.Fields{"request": request}) |
| 417 | |
| 418 | targetDeviceID := request.ParentDeviceId |
| 419 | if targetDeviceID == "" { |
| 420 | return nil, olterrors.NewErrNotFound("parent-id-empty", log.Fields{"parent-device-id": request.ParentDeviceId, "child-device-id": request.DeviceId}, nil).Log() |
| 421 | } |
| 422 | if handler := oo.getDeviceHandler(targetDeviceID); handler != nil { |
| 423 | return handler.GetTechProfileDownloadMessage(ctx, request) |
| 424 | } |
| 425 | return nil, olterrors.NewErrNotFound("no-device-handler", log.Fields{"parent-device-id": request.ParentDeviceId, "child-device-id": request.DeviceId}, nil).Log() |
| 426 | |
| 427 | } |
| 428 | |
khenaidoo | efff76e | 2021-12-15 16:51:30 -0500 | [diff] [blame] | 429 | // GetHealthStatus is used by a OltAdapterService client to detect a connection |
| 430 | // lost with the gRPC server hosting the OltAdapterService service |
| 431 | func (oo *OpenOLT) GetHealthStatus(stream adapter_service.AdapterService_GetHealthStatusServer) error { |
| 432 | ctx := context.Background() |
| 433 | logger.Debugw(ctx, "receive-stream-connection", log.Fields{"stream": stream}) |
| 434 | |
| 435 | if stream == nil { |
| 436 | return fmt.Errorf("conn-is-nil %v", stream) |
| 437 | } |
| 438 | initialRequestTime := time.Now() |
| 439 | var remoteClient *common.Connection |
| 440 | var tempClient *common.Connection |
| 441 | var err error |
| 442 | loop: |
| 443 | for { |
| 444 | tempClient, err = stream.Recv() |
| 445 | if err != nil { |
| 446 | logger.Warnw(ctx, "received-stream-error", log.Fields{"remote-client": remoteClient, "error": err}) |
| 447 | break loop |
| 448 | } |
| 449 | // Send a response back |
| 450 | err = stream.Send(&health.HealthStatus{State: health.HealthStatus_HEALTHY}) |
| 451 | if err != nil { |
| 452 | logger.Warnw(ctx, "sending-stream-error", log.Fields{"remote-client": remoteClient, "error": err}) |
| 453 | break loop |
| 454 | } |
| 455 | |
| 456 | remoteClient = tempClient |
| 457 | logger.Debugw(ctx, "received-keep-alive", log.Fields{"remote-client": remoteClient}) |
| 458 | |
| 459 | select { |
| 460 | case <-stream.Context().Done(): |
| 461 | logger.Infow(ctx, "stream-keep-alive-context-done", log.Fields{"remote-client": remoteClient, "error": stream.Context().Err()}) |
| 462 | break loop |
| 463 | case <-oo.exitChannel: |
| 464 | logger.Warnw(ctx, "received-stop", log.Fields{"remote-client": remoteClient, "initial-conn-time": initialRequestTime}) |
| 465 | break loop |
| 466 | default: |
| 467 | } |
| 468 | } |
| 469 | logger.Errorw(ctx, "connection-down", log.Fields{"remote-client": remoteClient, "error": err, "initial-conn-time": initialRequestTime}) |
| 470 | return err |
| 471 | } |
| 472 | |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 473 | /* |
| 474 | * |
| 475 | * Unimplemented APIs |
| 476 | * |
| 477 | */ |
| 478 | |
| 479 | //SimulateAlarm is unimplemented |
khenaidoo | dc2116e | 2021-10-19 17:33:19 -0400 | [diff] [blame] | 480 | func (oo *OpenOLT) SimulateAlarm(context.Context, *ca.SimulateAlarmMessage) (*voltha.OperationResp, error) { |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 481 | return nil, olterrors.ErrNotImplemented |
| 482 | } |
| 483 | |
| 484 | //SetExtValue is unimplemented |
khenaidoo | dc2116e | 2021-10-19 17:33:19 -0400 | [diff] [blame] | 485 | func (oo *OpenOLT) SetExtValue(context.Context, *ca.SetExtValueMessage) (*empty.Empty, error) { |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 486 | return nil, olterrors.ErrNotImplemented |
| 487 | } |
| 488 | |
| 489 | //SetSingleValue is unimplemented |
| 490 | func (oo *OpenOLT) SetSingleValue(context.Context, *extension.SingleSetValueRequest) (*extension.SingleSetValueResponse, error) { |
| 491 | return nil, olterrors.ErrNotImplemented |
| 492 | } |
| 493 | |
| 494 | //StartOmciTest not implemented |
khenaidoo | dc2116e | 2021-10-19 17:33:19 -0400 | [diff] [blame] | 495 | func (oo *OpenOLT) StartOmciTest(ctx context.Context, test *ca.OMCITest) (*omci.TestResponse, error) { |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 496 | return nil, olterrors.ErrNotImplemented |
| 497 | } |
| 498 | |
| 499 | //SuppressEvent unimplemented |
| 500 | func (oo *OpenOLT) SuppressEvent(ctx context.Context, filter *voltha.EventFilter) (*empty.Empty, error) { |
| 501 | return nil, olterrors.ErrNotImplemented |
| 502 | } |
| 503 | |
| 504 | //UnSuppressEvent unimplemented |
| 505 | func (oo *OpenOLT) UnSuppressEvent(ctx context.Context, filter *voltha.EventFilter) (*empty.Empty, error) { |
| 506 | return nil, olterrors.ErrNotImplemented |
| 507 | } |
| 508 | |
| 509 | //DownloadImage is unimplemented |
khenaidoo | dc2116e | 2021-10-19 17:33:19 -0400 | [diff] [blame] | 510 | func (oo *OpenOLT) DownloadImage(ctx context.Context, imageInfo *ca.ImageDownloadMessage) (*voltha.ImageDownload, error) { |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 511 | return nil, olterrors.ErrNotImplemented |
| 512 | } |
| 513 | |
| 514 | //GetImageDownloadStatus is unimplemented |
khenaidoo | dc2116e | 2021-10-19 17:33:19 -0400 | [diff] [blame] | 515 | func (oo *OpenOLT) GetImageDownloadStatus(ctx context.Context, imageInfo *ca.ImageDownloadMessage) (*voltha.ImageDownload, error) { |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 516 | return nil, olterrors.ErrNotImplemented |
| 517 | } |
| 518 | |
| 519 | //CancelImageDownload is unimplemented |
khenaidoo | dc2116e | 2021-10-19 17:33:19 -0400 | [diff] [blame] | 520 | func (oo *OpenOLT) CancelImageDownload(ctx context.Context, imageInfo *ca.ImageDownloadMessage) (*voltha.ImageDownload, error) { |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 521 | return nil, olterrors.ErrNotImplemented |
| 522 | } |
| 523 | |
| 524 | //ActivateImageUpdate is unimplemented |
khenaidoo | dc2116e | 2021-10-19 17:33:19 -0400 | [diff] [blame] | 525 | func (oo *OpenOLT) ActivateImageUpdate(ctx context.Context, imageInfo *ca.ImageDownloadMessage) (*voltha.ImageDownload, error) { |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 526 | return nil, olterrors.ErrNotImplemented |
| 527 | } |
| 528 | |
| 529 | //RevertImageUpdate is unimplemented |
khenaidoo | dc2116e | 2021-10-19 17:33:19 -0400 | [diff] [blame] | 530 | func (oo *OpenOLT) RevertImageUpdate(ctx context.Context, imageInfo *ca.ImageDownloadMessage) (*voltha.ImageDownload, error) { |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 531 | return nil, olterrors.ErrNotImplemented |
| 532 | } |
| 533 | |
| 534 | //DownloadOnuImage unimplemented |
| 535 | func (oo *OpenOLT) DownloadOnuImage(ctx context.Context, request *voltha.DeviceImageDownloadRequest) (*voltha.DeviceImageResponse, error) { |
| 536 | return nil, olterrors.ErrNotImplemented |
| 537 | } |
| 538 | |
| 539 | //GetOnuImageStatus unimplemented |
| 540 | func (oo *OpenOLT) GetOnuImageStatus(ctx context.Context, in *voltha.DeviceImageRequest) (*voltha.DeviceImageResponse, error) { |
| 541 | return nil, olterrors.ErrNotImplemented |
| 542 | } |
| 543 | |
| 544 | //AbortOnuImageUpgrade unimplemented |
| 545 | func (oo *OpenOLT) AbortOnuImageUpgrade(ctx context.Context, in *voltha.DeviceImageRequest) (*voltha.DeviceImageResponse, error) { |
| 546 | return nil, olterrors.ErrNotImplemented |
| 547 | } |
| 548 | |
| 549 | //GetOnuImages unimplemented |
| 550 | func (oo *OpenOLT) GetOnuImages(ctx context.Context, deviceID *common.ID) (*voltha.OnuImages, error) { |
| 551 | return nil, olterrors.ErrNotImplemented |
| 552 | } |
| 553 | |
| 554 | //ActivateOnuImage unimplemented |
| 555 | func (oo *OpenOLT) ActivateOnuImage(ctx context.Context, in *voltha.DeviceImageRequest) (*voltha.DeviceImageResponse, error) { |
| 556 | return nil, olterrors.ErrNotImplemented |
| 557 | } |
| 558 | |
| 559 | //CommitOnuImage unimplemented |
| 560 | func (oo *OpenOLT) CommitOnuImage(ctx context.Context, in *voltha.DeviceImageRequest) (*voltha.DeviceImageResponse, error) { |
| 561 | return nil, olterrors.ErrNotImplemented |
| 562 | } |
| 563 | |
| 564 | // UpdateFlowsBulk is unimplemented |
khenaidoo | dc2116e | 2021-10-19 17:33:19 -0400 | [diff] [blame] | 565 | func (oo *OpenOLT) UpdateFlowsBulk(ctx context.Context, flows *ca.BulkFlows) (*empty.Empty, error) { |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 566 | return nil, olterrors.ErrNotImplemented |
| 567 | } |
| 568 | |
| 569 | //SelfTestDevice unimplemented |
| 570 | func (oo *OpenOLT) SelfTestDevice(ctx context.Context, device *voltha.Device) (*empty.Empty, error) { |
| 571 | return nil, olterrors.ErrNotImplemented |
| 572 | } |