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 | |
| 17 | //Package adaptercore provides the utility for olt devices, flows and statistics |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 18 | package adaptercore |
| 19 | |
| 20 | import ( |
| 21 | "context" |
| 22 | "errors" |
| 23 | "fmt" |
| 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 | |
Scott Baker | 5129015 | 2019-10-24 14:23:20 -0700 | [diff] [blame] | 27 | "github.com/opencord/voltha-lib-go/v2/pkg/adapters/adapterif" |
| 28 | "github.com/opencord/voltha-lib-go/v2/pkg/kafka" |
| 29 | "github.com/opencord/voltha-lib-go/v2/pkg/log" |
Abhilash Laxmeshwar | f9942e9 | 2020-01-07 15:32:44 +0530 | [diff] [blame] | 30 | "github.com/opencord/voltha-openolt-adapter/config" |
Scott Baker | c6e54cb | 2019-11-04 09:31:25 -0800 | [diff] [blame] | 31 | ic "github.com/opencord/voltha-protos/v2/go/inter_container" |
| 32 | "github.com/opencord/voltha-protos/v2/go/openflow_13" |
| 33 | "github.com/opencord/voltha-protos/v2/go/voltha" |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 34 | ) |
| 35 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 36 | //OpenOLT structure holds the OLT information |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 37 | type OpenOLT struct { |
Abhilash Laxmeshwar | f9942e9 | 2020-01-07 15:32:44 +0530 | [diff] [blame] | 38 | deviceHandlers map[string]*DeviceHandler |
| 39 | coreProxy adapterif.CoreProxy |
| 40 | adapterProxy adapterif.AdapterProxy |
| 41 | eventProxy adapterif.EventProxy |
| 42 | kafkaICProxy *kafka.InterContainerProxy |
| 43 | config *config.AdapterFlags |
| 44 | numOnus int |
| 45 | KVStoreHost string |
| 46 | KVStorePort int |
| 47 | KVStoreType string |
| 48 | exitChannel chan int |
| 49 | HeartbeatCheckInterval time.Duration |
| 50 | HeartbeatFailReportInterval time.Duration |
| 51 | GrpcTimeoutInterval time.Duration |
| 52 | lockDeviceHandlersMap sync.RWMutex |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 53 | } |
| 54 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 55 | //NewOpenOLT returns a new instance of OpenOLT |
kdarapu | 381c690 | 2019-07-31 18:23:16 +0530 | [diff] [blame] | 56 | func NewOpenOLT(ctx context.Context, kafkaICProxy *kafka.InterContainerProxy, |
| 57 | coreProxy adapterif.CoreProxy, adapterProxy adapterif.AdapterProxy, |
Abhilash Laxmeshwar | f9942e9 | 2020-01-07 15:32:44 +0530 | [diff] [blame] | 58 | eventProxy adapterif.EventProxy, cfg *config.AdapterFlags) *OpenOLT { |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 59 | var openOLT OpenOLT |
| 60 | openOLT.exitChannel = make(chan int, 1) |
| 61 | openOLT.deviceHandlers = make(map[string]*DeviceHandler) |
| 62 | openOLT.kafkaICProxy = kafkaICProxy |
Abhilash Laxmeshwar | f9942e9 | 2020-01-07 15:32:44 +0530 | [diff] [blame] | 63 | openOLT.config = cfg |
| 64 | openOLT.numOnus = cfg.OnuNumber |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 65 | openOLT.coreProxy = coreProxy |
| 66 | openOLT.adapterProxy = adapterProxy |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 67 | openOLT.eventProxy = eventProxy |
Abhilash Laxmeshwar | f9942e9 | 2020-01-07 15:32:44 +0530 | [diff] [blame] | 68 | openOLT.KVStoreHost = cfg.KVStoreHost |
| 69 | openOLT.KVStorePort = cfg.KVStorePort |
| 70 | openOLT.KVStoreType = cfg.KVStoreType |
| 71 | openOLT.HeartbeatCheckInterval = cfg.HeartbeatCheckInterval |
| 72 | openOLT.HeartbeatFailReportInterval = cfg.HeartbeatFailReportInterval |
| 73 | openOLT.GrpcTimeoutInterval = cfg.GrpcTimeoutInterval |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 74 | openOLT.lockDeviceHandlersMap = sync.RWMutex{} |
| 75 | return &openOLT |
| 76 | } |
| 77 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 78 | //Start starts (logs) the device manager |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 79 | func (oo *OpenOLT) Start(ctx context.Context) error { |
| 80 | log.Info("starting-device-manager") |
| 81 | log.Info("device-manager-started") |
| 82 | return nil |
| 83 | } |
| 84 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 85 | //Stop terminates the session |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 86 | func (oo *OpenOLT) Stop(ctx context.Context) error { |
| 87 | log.Info("stopping-device-manager") |
| 88 | oo.exitChannel <- 1 |
| 89 | log.Info("device-manager-stopped") |
| 90 | return nil |
| 91 | } |
| 92 | |
| 93 | func sendResponse(ctx context.Context, ch chan interface{}, result interface{}) { |
| 94 | if ctx.Err() == nil { |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 95 | // Returned response only of the ctx has not been canceled/timeout/etc |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 96 | // Channel is automatically closed when a context is Done |
| 97 | ch <- result |
| 98 | log.Debugw("sendResponse", log.Fields{"result": result}) |
| 99 | } else { |
| 100 | // Should the transaction be reverted back? |
| 101 | log.Debugw("sendResponse-context-error", log.Fields{"context-error": ctx.Err()}) |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | func (oo *OpenOLT) addDeviceHandlerToMap(agent *DeviceHandler) { |
| 106 | oo.lockDeviceHandlersMap.Lock() |
| 107 | defer oo.lockDeviceHandlersMap.Unlock() |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 108 | if _, exist := oo.deviceHandlers[agent.deviceID]; !exist { |
| 109 | oo.deviceHandlers[agent.deviceID] = agent |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 110 | } |
| 111 | } |
| 112 | |
| 113 | func (oo *OpenOLT) deleteDeviceHandlerToMap(agent *DeviceHandler) { |
| 114 | oo.lockDeviceHandlersMap.Lock() |
| 115 | defer oo.lockDeviceHandlersMap.Unlock() |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 116 | delete(oo.deviceHandlers, agent.deviceID) |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 117 | } |
| 118 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 119 | func (oo *OpenOLT) getDeviceHandler(deviceID string) *DeviceHandler { |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 120 | oo.lockDeviceHandlersMap.Lock() |
| 121 | defer oo.lockDeviceHandlersMap.Unlock() |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 122 | if agent, ok := oo.deviceHandlers[deviceID]; ok { |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 123 | return agent |
| 124 | } |
| 125 | return nil |
| 126 | } |
| 127 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 128 | //createDeviceTopic returns |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 129 | func (oo *OpenOLT) createDeviceTopic(device *voltha.Device) error { |
| 130 | log.Infow("create-device-topic", log.Fields{"deviceId": device.Id}) |
| 131 | deviceTopic := kafka.Topic{Name: oo.kafkaICProxy.DefaultTopic.Name + "_" + device.Id} |
| 132 | // TODO for the offset |
| 133 | if err := oo.kafkaICProxy.SubscribeWithDefaultRequestHandler(deviceTopic, 0); err != nil { |
| 134 | log.Infow("create-device-topic-failed", log.Fields{"deviceId": device.Id, "error": err}) |
| 135 | return err |
| 136 | } |
| 137 | return nil |
| 138 | } |
| 139 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 140 | // Adopt_device creates a new device handler if not present already and then adopts the device |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 141 | func (oo *OpenOLT) Adopt_device(device *voltha.Device) error { |
| 142 | if device == nil { |
| 143 | log.Warn("device-is-nil") |
| 144 | return errors.New("nil-device") |
| 145 | } |
| 146 | log.Infow("adopt-device", log.Fields{"deviceId": device.Id}) |
| 147 | var handler *DeviceHandler |
| 148 | if handler = oo.getDeviceHandler(device.Id); handler == nil { |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 149 | handler := NewDeviceHandler(oo.coreProxy, oo.adapterProxy, oo.eventProxy, device, oo) |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 150 | oo.addDeviceHandlerToMap(handler) |
| 151 | go handler.AdoptDevice(device) |
| 152 | // Launch the creation of the device topic |
| 153 | // go oo.createDeviceTopic(device) |
| 154 | } |
| 155 | return nil |
| 156 | } |
| 157 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 158 | //Get_ofp_device_info returns OFP information for the given device |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 159 | func (oo *OpenOLT) Get_ofp_device_info(device *voltha.Device) (*ic.SwitchCapability, error) { |
| 160 | log.Infow("Get_ofp_device_info", log.Fields{"deviceId": device.Id}) |
| 161 | if handler := oo.getDeviceHandler(device.Id); handler != nil { |
| 162 | return handler.GetOfpDeviceInfo(device) |
| 163 | } |
| 164 | log.Errorw("device-handler-not-set", log.Fields{"deviceId": device.Id}) |
| 165 | return nil, errors.New("device-handler-not-set") |
| 166 | } |
| 167 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 168 | //Get_ofp_port_info returns OFP port information for the given device |
| 169 | func (oo *OpenOLT) Get_ofp_port_info(device *voltha.Device, portNo int64) (*ic.PortCapability, error) { |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 170 | log.Infow("Get_ofp_port_info", log.Fields{"deviceId": device.Id}) |
| 171 | if handler := oo.getDeviceHandler(device.Id); handler != nil { |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 172 | return handler.GetOfpPortInfo(device, portNo) |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 173 | } |
| 174 | log.Errorw("device-handler-not-set", log.Fields{"deviceId": device.Id}) |
| 175 | return nil, errors.New("device-handler-not-set") |
| 176 | } |
| 177 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 178 | //Process_inter_adapter_message sends messages to a target device (between adapters) |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 179 | func (oo *OpenOLT) Process_inter_adapter_message(msg *ic.InterAdapterMessage) error { |
| 180 | log.Infow("Process_inter_adapter_message", log.Fields{"msgId": msg.Header.Id}) |
| 181 | targetDevice := msg.Header.ProxyDeviceId // Request? |
| 182 | if targetDevice == "" && msg.Header.ToDeviceId != "" { |
| 183 | // Typical response |
| 184 | targetDevice = msg.Header.ToDeviceId |
| 185 | } |
| 186 | if handler := oo.getDeviceHandler(targetDevice); handler != nil { |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 187 | return handler.ProcessInterAdapterMessage(msg) |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 188 | } |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 189 | return fmt.Errorf(fmt.Sprintf("handler-not-found-%s", targetDevice)) |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 190 | } |
| 191 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 192 | //Adapter_descriptor not implemented |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 193 | func (oo *OpenOLT) Adapter_descriptor() error { |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 194 | return errors.New("unImplemented") |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 195 | } |
| 196 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 197 | //Device_types unimplemented |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 198 | func (oo *OpenOLT) Device_types() (*voltha.DeviceTypes, error) { |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 199 | return nil, errors.New("unImplemented") |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 200 | } |
| 201 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 202 | //Health returns unimplemented |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 203 | func (oo *OpenOLT) Health() (*voltha.HealthStatus, error) { |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 204 | return nil, errors.New("unImplemented") |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 205 | } |
| 206 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 207 | //Reconcile_device unimplemented |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 208 | func (oo *OpenOLT) Reconcile_device(device *voltha.Device) error { |
Abhilash Laxmeshwar | ab0bd52 | 2019-10-21 15:05:15 +0530 | [diff] [blame] | 209 | if device == nil { |
| 210 | log.Warn("device-is-nil") |
| 211 | return errors.New("nil-device") |
| 212 | } |
| 213 | log.Infow("reconcile-device", log.Fields{"deviceId": device.Id}) |
| 214 | var handler *DeviceHandler |
| 215 | if handler = oo.getDeviceHandler(device.Id); handler == nil { |
| 216 | handler := NewDeviceHandler(oo.coreProxy, oo.adapterProxy, oo.eventProxy, device, oo) |
| 217 | oo.addDeviceHandlerToMap(handler) |
| 218 | handler.transitionMap = NewTransitionMap(handler) |
| 219 | handler.transitionMap.Handle(DeviceInit) |
| 220 | } |
| 221 | return nil |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 222 | } |
| 223 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 224 | //Abandon_device unimplemented |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 225 | func (oo *OpenOLT) Abandon_device(device *voltha.Device) error { |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 226 | return errors.New("unImplemented") |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 227 | } |
| 228 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 229 | //Disable_device disables the given device |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 230 | func (oo *OpenOLT) Disable_device(device *voltha.Device) error { |
Girish Gowdru | 5ba46c9 | 2019-04-25 05:00:05 -0400 | [diff] [blame] | 231 | log.Infow("disable-device", log.Fields{"deviceId": device.Id}) |
| 232 | if handler := oo.getDeviceHandler(device.Id); handler != nil { |
| 233 | return handler.DisableDevice(device) |
| 234 | } |
| 235 | log.Errorw("device-handler-not-set", log.Fields{"deviceId": device.Id}) |
| 236 | return errors.New("device-handler-not-found") |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 237 | } |
| 238 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 239 | //Reenable_device enables the olt device after disable |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 240 | func (oo *OpenOLT) Reenable_device(device *voltha.Device) error { |
Girish Gowdru | 5ba46c9 | 2019-04-25 05:00:05 -0400 | [diff] [blame] | 241 | log.Infow("reenable-device", log.Fields{"deviceId": device.Id}) |
| 242 | if handler := oo.getDeviceHandler(device.Id); handler != nil { |
| 243 | return handler.ReenableDevice(device) |
| 244 | } |
| 245 | log.Errorw("device-handler-not-set", log.Fields{"deviceId": device.Id}) |
| 246 | return errors.New("device-handler-not-found") |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 247 | } |
| 248 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 249 | //Reboot_device reboots the given device |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 250 | func (oo *OpenOLT) Reboot_device(device *voltha.Device) error { |
Girish Gowdru | 0fe5f7e | 2019-05-28 05:12:27 -0400 | [diff] [blame] | 251 | log.Infow("reboot-device", log.Fields{"deviceId": device.Id}) |
| 252 | if handler := oo.getDeviceHandler(device.Id); handler != nil { |
| 253 | return handler.RebootDevice(device) |
| 254 | } |
| 255 | log.Errorw("device-handler-not-set", log.Fields{"deviceId": device.Id}) |
| 256 | return errors.New("device-handler-not-found") |
| 257 | |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 258 | } |
| 259 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 260 | //Self_test_device unimplented |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 261 | func (oo *OpenOLT) Self_test_device(device *voltha.Device) error { |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 262 | return errors.New("unImplemented") |
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 | //Delete_device unimplemented |
manikkaraj k | 9eb6cac | 2019-05-09 12:32:03 -0400 | [diff] [blame] | 266 | func (oo *OpenOLT) Delete_device(device *voltha.Device) error { |
Devmalya Paul | 495b94a | 2019-08-27 19:42:00 -0400 | [diff] [blame] | 267 | log.Infow("delete-device", log.Fields{"deviceId": device.Id}) |
| 268 | if handler := oo.getDeviceHandler(device.Id); handler != nil { |
| 269 | if err := handler.DeleteDevice(device); err != nil { |
| 270 | log.Errorw("failed-to-handle-delete-device", log.Fields{"device-id": device.Id}) |
| 271 | } |
| 272 | oo.deleteDeviceHandlerToMap(handler) |
| 273 | return nil |
| 274 | } |
| 275 | log.Errorw("device-handler-not-set", log.Fields{"deviceId": device.Id}) |
| 276 | return errors.New("device-handler-not-found") |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 277 | } |
| 278 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 279 | //Get_device_details unimplemented |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 280 | func (oo *OpenOLT) Get_device_details(device *voltha.Device) error { |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 281 | return errors.New("unImplemented") |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 282 | } |
| 283 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 284 | //Update_flows_bulk returns |
Manikkaraj k | b1d5144 | 2019-07-23 10:41:02 -0400 | [diff] [blame] | 285 | func (oo *OpenOLT) Update_flows_bulk(device *voltha.Device, flows *voltha.Flows, groups *voltha.FlowGroups, flowMetadata *voltha.FlowMetadata) error { |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 286 | return errors.New("unImplemented") |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 287 | } |
| 288 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 289 | //Update_flows_incrementally updates (add/remove) the flows on a given device |
Manikkaraj k | b1d5144 | 2019-07-23 10:41:02 -0400 | [diff] [blame] | 290 | func (oo *OpenOLT) Update_flows_incrementally(device *voltha.Device, flows *openflow_13.FlowChanges, groups *openflow_13.FlowGroupChanges, flowMetadata *voltha.FlowMetadata) error { |
| 291 | log.Debugw("Update_flows_incrementally", log.Fields{"deviceId": device.Id, "flows": flows, "flowMetadata": flowMetadata}) |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 292 | if handler := oo.getDeviceHandler(device.Id); handler != nil { |
Manikkaraj k | b1d5144 | 2019-07-23 10:41:02 -0400 | [diff] [blame] | 293 | return handler.UpdateFlowsIncrementally(device, flows, groups, flowMetadata) |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 294 | } |
| 295 | log.Errorw("Update_flows_incrementally failed-device-handler-not-set", log.Fields{"deviceId": device.Id}) |
| 296 | return errors.New("device-handler-not-set") |
| 297 | } |
| 298 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 299 | //Update_pm_config returns PmConfigs nil or error |
| 300 | func (oo *OpenOLT) Update_pm_config(device *voltha.Device, pmConfigs *voltha.PmConfigs) error { |
| 301 | return errors.New("unImplemented") |
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 | //Receive_packet_out sends packet out to the device |
| 305 | func (oo *OpenOLT) Receive_packet_out(deviceID string, egressPortNo int, packet *openflow_13.OfpPacketOut) error { |
| 306 | log.Debugw("Receive_packet_out", log.Fields{"deviceId": deviceID, "egress_port_no": egressPortNo, "pkt": packet}) |
| 307 | if handler := oo.getDeviceHandler(deviceID); handler != nil { |
| 308 | return handler.PacketOut(egressPortNo, packet) |
manikkaraj k | 9eb6cac | 2019-05-09 12:32:03 -0400 | [diff] [blame] | 309 | } |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 310 | log.Errorw("Receive_packet_out failed-device-handler-not-set", log.Fields{"deviceId": deviceID, "egressport": egressPortNo, "packet": packet}) |
manikkaraj k | 9eb6cac | 2019-05-09 12:32:03 -0400 | [diff] [blame] | 311 | return errors.New("device-handler-not-set") |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 312 | } |
| 313 | |
Devmalya Paul | dd23a99 | 2019-11-14 07:06:31 +0000 | [diff] [blame] | 314 | //Suppress_event unimplemented |
| 315 | func (oo *OpenOLT) Suppress_event(filter *voltha.EventFilter) error { |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 316 | return errors.New("unImplemented") |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 317 | } |
| 318 | |
Devmalya Paul | dd23a99 | 2019-11-14 07:06:31 +0000 | [diff] [blame] | 319 | //Unsuppress_event unimplemented |
| 320 | func (oo *OpenOLT) Unsuppress_event(filter *voltha.EventFilter) error { |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 321 | return errors.New("unImplemented") |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 322 | } |
| 323 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 324 | //Download_image unimplemented |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 325 | func (oo *OpenOLT) Download_image(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) { |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 326 | return nil, errors.New("unImplemented") |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 327 | } |
| 328 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 329 | //Get_image_download_status unimplemented |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 330 | func (oo *OpenOLT) Get_image_download_status(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) { |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 331 | return nil, errors.New("unImplemented") |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 332 | } |
| 333 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 334 | //Cancel_image_download unimplemented |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 335 | func (oo *OpenOLT) Cancel_image_download(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) { |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 336 | return nil, errors.New("unImplemented") |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 337 | } |
| 338 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 339 | //Activate_image_update unimplemented |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 340 | func (oo *OpenOLT) Activate_image_update(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) { |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 341 | return nil, errors.New("unImplemented") |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 342 | } |
| 343 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 344 | //Revert_image_update unimplemented |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 345 | func (oo *OpenOLT) Revert_image_update(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) { |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 346 | return nil, errors.New("unImplemented") |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 347 | } |