blob: cdce427cd33c20f0d2333ba3026a2bbc940d65dc [file] [log] [blame]
Holger Hildebrandtfa074992020-03-27 15:42:06 +00001/*
2 * Copyright 2020-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 */
16
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +000017//Package adaptercoreonu provides the utility for onu devices, flows and statistics
18package adaptercoreonu
Holger Hildebrandtfa074992020-03-27 15:42:06 +000019
20import (
21 "context"
22 "errors"
23 "fmt"
24 "sync"
25 "time"
26
27 "github.com/opencord/voltha-lib-go/v3/pkg/adapters/adapterif"
mpagenkoaf801632020-07-03 10:00:42 +000028 "github.com/opencord/voltha-lib-go/v3/pkg/db/kvstore"
Holger Hildebrandtfa074992020-03-27 15:42:06 +000029 "github.com/opencord/voltha-lib-go/v3/pkg/kafka"
30 "github.com/opencord/voltha-lib-go/v3/pkg/log"
31 ic "github.com/opencord/voltha-protos/v3/go/inter_container"
32 "github.com/opencord/voltha-protos/v3/go/openflow_13"
33 "github.com/opencord/voltha-protos/v3/go/voltha"
34
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +000035 "test.internal/openadapter/internal/pkg/config"
Holger Hildebrandtfa074992020-03-27 15:42:06 +000036)
37
38//OpenONUAC structure holds the ONU core information
39type OpenONUAC struct {
Himani Chawla6d2ae152020-09-02 13:11:20 +053040 deviceHandlers map[string]*deviceHandler
Holger Hildebrandtf07b44a2020-11-10 13:07:54 +000041 deviceHandlersCreateChan map[string]chan bool //channels for deviceHandler create events
Holger Hildebrandtfa074992020-03-27 15:42:06 +000042 coreProxy adapterif.CoreProxy
43 adapterProxy adapterif.AdapterProxy
44 eventProxy adapterif.EventProxy
45 kafkaICProxy kafka.InterContainerProxy
mpagenkoaf801632020-07-03 10:00:42 +000046 kvClient kvstore.Client
Holger Hildebrandtfa074992020-03-27 15:42:06 +000047 config *config.AdapterFlags
48 numOnus int
49 KVStoreHost string
50 KVStorePort int
51 KVStoreType string
mpagenkoaf801632020-07-03 10:00:42 +000052 KVStoreTimeout time.Duration
Holger Hildebrandtfa074992020-03-27 15:42:06 +000053 exitChannel chan int
54 HeartbeatCheckInterval time.Duration
55 HeartbeatFailReportInterval time.Duration
mpagenkodff5dda2020-08-28 11:52:01 +000056 AcceptIncrementalEvto bool
Holger Hildebrandtfa074992020-03-27 15:42:06 +000057 //GrpcTimeoutInterval time.Duration
Himani Chawlad96df182020-09-28 11:12:02 +053058 lockDeviceHandlersMap sync.RWMutex
59 pSupportedFsms *OmciDeviceFsms
60 maxTimeoutInterAdapterComm time.Duration
Holger Hildebrandtfa074992020-03-27 15:42:06 +000061}
62
63//NewOpenONUAC returns a new instance of OpenONU_AC
64func NewOpenONUAC(ctx context.Context, kafkaICProxy kafka.InterContainerProxy,
65 coreProxy adapterif.CoreProxy, adapterProxy adapterif.AdapterProxy,
mpagenkoaf801632020-07-03 10:00:42 +000066 eventProxy adapterif.EventProxy, kvClient kvstore.Client, cfg *config.AdapterFlags) *OpenONUAC {
Holger Hildebrandtfa074992020-03-27 15:42:06 +000067 var openOnuAc OpenONUAC
68 openOnuAc.exitChannel = make(chan int, 1)
Himani Chawla6d2ae152020-09-02 13:11:20 +053069 openOnuAc.deviceHandlers = make(map[string]*deviceHandler)
Holger Hildebrandtf07b44a2020-11-10 13:07:54 +000070 openOnuAc.deviceHandlersCreateChan = make(map[string]chan bool)
Holger Hildebrandtfa074992020-03-27 15:42:06 +000071 openOnuAc.kafkaICProxy = kafkaICProxy
72 openOnuAc.config = cfg
73 openOnuAc.numOnus = cfg.OnuNumber
74 openOnuAc.coreProxy = coreProxy
75 openOnuAc.adapterProxy = adapterProxy
76 openOnuAc.eventProxy = eventProxy
mpagenkoaf801632020-07-03 10:00:42 +000077 openOnuAc.kvClient = kvClient
Holger Hildebrandtfa074992020-03-27 15:42:06 +000078 openOnuAc.KVStoreHost = cfg.KVStoreHost
79 openOnuAc.KVStorePort = cfg.KVStorePort
80 openOnuAc.KVStoreType = cfg.KVStoreType
mpagenkoaf801632020-07-03 10:00:42 +000081 openOnuAc.KVStoreTimeout = cfg.KVStoreTimeout
Holger Hildebrandtfa074992020-03-27 15:42:06 +000082 openOnuAc.HeartbeatCheckInterval = cfg.HeartbeatCheckInterval
83 openOnuAc.HeartbeatFailReportInterval = cfg.HeartbeatFailReportInterval
mpagenkodff5dda2020-08-28 11:52:01 +000084 openOnuAc.AcceptIncrementalEvto = cfg.AccIncrEvto
Himani Chawlad96df182020-09-28 11:12:02 +053085 openOnuAc.maxTimeoutInterAdapterComm = cfg.MaxTimeoutInterAdapterComm
Holger Hildebrandtfa074992020-03-27 15:42:06 +000086 //openOnuAc.GrpcTimeoutInterval = cfg.GrpcTimeoutInterval
87 openOnuAc.lockDeviceHandlersMap = sync.RWMutex{}
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +000088
89 openOnuAc.pSupportedFsms = &OmciDeviceFsms{
90 "mib-synchronizer": {
91 //mibSyncFsm, // Implements the MIB synchronization state machine
Himani Chawla6d2ae152020-09-02 13:11:20 +053092 mibDbVolatileDictImpl, // Implements volatile ME MIB database
Himani Chawla4d908332020-08-31 12:30:20 +053093 //true, // Advertise events on OpenOMCI event bus
94 cMibAuditDelayImpl, // Time to wait between MIB audits. 0 to disable audits.
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +000095 // map[string]func() error{
96 // "mib-upload": onuDeviceEntry.MibUploadTask,
97 // "mib-template": onuDeviceEntry.MibTemplateTask,
98 // "get-mds": onuDeviceEntry.GetMdsTask,
99 // "mib-audit": onuDeviceEntry.GetMdsTask,
100 // "mib-resync": onuDeviceEntry.MibResyncTask,
101 // "mib-reconcile": onuDeviceEntry.MibReconcileTask,
102 // },
103 },
104 }
105
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000106 return &openOnuAc
107}
108
109//Start starts (logs) the adapter
110func (oo *OpenONUAC) Start(ctx context.Context) error {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000111 logger.Info("starting-openonu-adapter")
112 logger.Info("openonu-adapter-started")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000113 return nil
114}
115
Himani Chawla6d2ae152020-09-02 13:11:20 +0530116/*
117//stop terminates the session
118func (oo *OpenONUAC) stop(ctx context.Context) error {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000119 logger.Info("stopping-device-manager")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000120 oo.exitChannel <- 1
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000121 logger.Info("device-manager-stopped")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000122 return nil
123}
Himani Chawla6d2ae152020-09-02 13:11:20 +0530124*/
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000125
Himani Chawla6d2ae152020-09-02 13:11:20 +0530126func (oo *OpenONUAC) addDeviceHandlerToMap(ctx context.Context, agent *deviceHandler) {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000127 oo.lockDeviceHandlersMap.Lock()
128 defer oo.lockDeviceHandlersMap.Unlock()
129 if _, exist := oo.deviceHandlers[agent.deviceID]; !exist {
130 oo.deviceHandlers[agent.deviceID] = agent
Himani Chawla6d2ae152020-09-02 13:11:20 +0530131 oo.deviceHandlers[agent.deviceID].start(ctx)
Holger Hildebrandtf07b44a2020-11-10 13:07:54 +0000132 if _, exist := oo.deviceHandlersCreateChan[agent.deviceID]; exist {
133 logger.Debugw("deviceHandler created - trigger processing of pending ONU_IND_REQUEST", log.Fields{"device-id": agent.deviceID})
134 oo.deviceHandlersCreateChan[agent.deviceID] <- true
135 }
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000136 }
137}
138
Himani Chawla6d2ae152020-09-02 13:11:20 +0530139func (oo *OpenONUAC) deleteDeviceHandlerToMap(agent *deviceHandler) {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000140 oo.lockDeviceHandlersMap.Lock()
141 defer oo.lockDeviceHandlersMap.Unlock()
142 delete(oo.deviceHandlers, agent.deviceID)
Holger Hildebrandtf07b44a2020-11-10 13:07:54 +0000143 delete(oo.deviceHandlersCreateChan, agent.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000144}
145
Holger Hildebrandtf07b44a2020-11-10 13:07:54 +0000146//getDeviceHandler gets the ONU deviceHandler and may wait until it is created
147func (oo *OpenONUAC) getDeviceHandler(deviceID string, aWait bool) *deviceHandler {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000148 oo.lockDeviceHandlersMap.Lock()
Holger Hildebrandtf07b44a2020-11-10 13:07:54 +0000149 agent, ok := oo.deviceHandlers[deviceID]
150 if aWait && !ok {
151 logger.Debugw("deviceHandler not present - wait for creation or timeout", log.Fields{"device-id": deviceID})
152 if _, exist := oo.deviceHandlersCreateChan[deviceID]; !exist {
153 oo.deviceHandlersCreateChan[deviceID] = make(chan bool, 1)
154 }
155 //keep the read sema short to allow for subsequent write
156 oo.lockDeviceHandlersMap.Unlock()
157 // based on concurrent processing the deviceHandler creation may not yet be finished at his point
158 // so it might be needed to wait here for that event with some timeout
159 select {
160 case <-time.After(1 * time.Second): //timer may be discussed ...
161 logger.Warnw("No valid deviceHandler created after max WaitTime", log.Fields{"device-id": deviceID})
162 return nil
163 case <-oo.deviceHandlersCreateChan[deviceID]:
164 logger.Debugw("deviceHandler is ready now - continue", log.Fields{"device-id": deviceID})
165 // if written now, we can return the written value without sema
166 return oo.deviceHandlers[deviceID]
167 }
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000168 }
Holger Hildebrandtf07b44a2020-11-10 13:07:54 +0000169 oo.lockDeviceHandlersMap.Unlock()
170 return agent
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000171}
172
173// Adapter interface required methods ############## begin #########
174// #################################################################
175
176// for original content compare: (needs according deviceHandler methods)
177// /voltha-openolt-adapter/adaptercore/openolt.go
178
179// Adopt_device creates a new device handler if not present already and then adopts the device
180func (oo *OpenONUAC) Adopt_device(device *voltha.Device) error {
181 if device == nil {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000182 logger.Warn("voltha-device-is-nil")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000183 return errors.New("nil-device")
184 }
185 ctx := context.Background()
divyadesai4d299552020-08-18 07:13:49 +0000186 logger.Infow("adopt-device", log.Fields{"device-id": device.Id})
Himani Chawla6d2ae152020-09-02 13:11:20 +0530187 var handler *deviceHandler
Holger Hildebrandtf07b44a2020-11-10 13:07:54 +0000188 if handler = oo.getDeviceHandler(device.Id, false); handler == nil {
Himani Chawla6d2ae152020-09-02 13:11:20 +0530189 handler := newDeviceHandler(oo.coreProxy, oo.adapterProxy, oo.eventProxy, device, oo)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000190 oo.addDeviceHandlerToMap(ctx, handler)
Himani Chawla6d2ae152020-09-02 13:11:20 +0530191 go handler.adoptOrReconcileDevice(ctx, device)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000192 // Launch the creation of the device topic
193 // go oo.createDeviceTopic(device)
194 }
195 return nil
196}
197
198//Get_ofp_device_info returns OFP information for the given device
199func (oo *OpenONUAC) Get_ofp_device_info(device *voltha.Device) (*ic.SwitchCapability, error) {
divyadesai4d299552020-08-18 07:13:49 +0000200 logger.Errorw("device-handler-not-set", log.Fields{"device-id": device.Id})
Andrea Campanella6515c582020-10-05 11:25:00 +0200201 return nil, fmt.Errorf("device-handler-not-set %s", device.Id)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000202}
203
204//Get_ofp_port_info returns OFP port information for the given device
mpagenkoaf801632020-07-03 10:00:42 +0000205//200630: method removed as per [VOL-3202]: OF port info is now to be delivered within UniPort create
206// cmp changes in onu_uni_port.go::CreateVolthaPort()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000207
208//Process_inter_adapter_message sends messages to a target device (between adapters)
209func (oo *OpenONUAC) Process_inter_adapter_message(msg *ic.InterAdapterMessage) error {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000210 logger.Debugw("Process_inter_adapter_message", log.Fields{"msgId": msg.Header.Id,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000211 "msgProxyDeviceId": msg.Header.ProxyDeviceId, "msgToDeviceId": msg.Header.ToDeviceId})
212
Holger Hildebrandtf07b44a2020-11-10 13:07:54 +0000213 var waitForDhInstPresent bool
214 //ToDeviceId should address a DeviceHandler instance
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000215 targetDevice := msg.Header.ToDeviceId
Holger Hildebrandtf07b44a2020-11-10 13:07:54 +0000216 // As a workaround this handling is only required for the OnuIndication with OperState=Up event.
217 // But we live without that further check and use this processing also for OperState down/unreachable events to avoid
218 // the deeper message processing at this stage. Should do no harm on the other events (except for run time)
219 if msg.Header.Type != ic.InterAdapterMessageType_ONU_IND_REQUEST {
220 waitForDhInstPresent = false
221 } else {
222 //Race condition (relevant in BBSIM-environment only): Due to unsynchronized processing of olt-adapter and rw_core,
223 //ONU_IND_REQUEST msg by olt-adapter could arrive a little bit earlier than rw_core was able to announce the corresponding
224 //ONU by RPC of Adopt_device()
225 logger.Debugw("ONU_IND_REQUEST - potentially wait until DeviceHandler instance is created", log.Fields{"device-id": targetDevice})
226 waitForDhInstPresent = true
227 }
228 if handler := oo.getDeviceHandler(targetDevice, waitForDhInstPresent); handler != nil {
mpagenko1cc3cb42020-07-27 15:24:38 +0000229 /* 200724: modification towards synchronous implementation - possible errors within processing shall be
230 * in the accordingly delayed response, some timing effect might result in Techprofile processing for multiple UNI's
231 */
Himani Chawla6d2ae152020-09-02 13:11:20 +0530232 return handler.processInterAdapterMessage(msg)
mpagenko1cc3cb42020-07-27 15:24:38 +0000233 /* so far the processing has been in background with according commented error treatment restrictions:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000234 go handler.ProcessInterAdapterMessage(msg)
235 // error treatment might be more sophisticated
236 // by now let's just accept the message on 'communication layer'
237 // message content problems have to be evaluated then in the handler
238 // and are by now not reported to the calling party (to force what reaction there?)
239 return nil
mpagenko1cc3cb42020-07-27 15:24:38 +0000240 */
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000241 }
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000242 logger.Warnw("no handler found for received Inter-Proxy-message", log.Fields{
243 "msgToDeviceId": targetDevice})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000244 return fmt.Errorf(fmt.Sprintf("handler-not-found-%s", targetDevice))
245}
246
247//Adapter_descriptor not implemented
248func (oo *OpenONUAC) Adapter_descriptor() error {
249 return errors.New("unImplemented")
250}
251
252//Device_types unimplemented
253func (oo *OpenONUAC) Device_types() (*voltha.DeviceTypes, error) {
254 return nil, errors.New("unImplemented")
255}
256
257//Health returns unimplemented
258func (oo *OpenONUAC) Health() (*voltha.HealthStatus, error) {
259 return nil, errors.New("unImplemented")
260}
261
Holger Hildebrandt9ca8b132020-08-07 14:45:03 +0000262//Reconcile_device is called once when the adapter needs to re-create device - usually on core restart
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000263func (oo *OpenONUAC) Reconcile_device(device *voltha.Device) error {
Holger Hildebrandtf41a1602020-08-19 09:52:50 +0000264 if device == nil {
265 logger.Warn("voltha-device-is-nil")
266 return errors.New("nil-device")
267 }
268 ctx := context.Background()
269 logger.Infow("Reconcile_device", log.Fields{"device-id": device.Id})
Himani Chawla6d2ae152020-09-02 13:11:20 +0530270 var handler *deviceHandler
Holger Hildebrandtf07b44a2020-11-10 13:07:54 +0000271 if handler = oo.getDeviceHandler(device.Id, false); handler == nil {
Himani Chawla6d2ae152020-09-02 13:11:20 +0530272 handler := newDeviceHandler(oo.coreProxy, oo.adapterProxy, oo.eventProxy, device, oo)
Holger Hildebrandtf41a1602020-08-19 09:52:50 +0000273 oo.addDeviceHandlerToMap(ctx, handler)
274 handler.device = device
275 handler.reconciling = true
Himani Chawla6d2ae152020-09-02 13:11:20 +0530276 go handler.adoptOrReconcileDevice(ctx, handler.device)
Holger Hildebrandtf41a1602020-08-19 09:52:50 +0000277 // reconcilement will be continued after onu-device entry is added
Holger Hildebrandt9ca8b132020-08-07 14:45:03 +0000278 } else {
Holger Hildebrandtf41a1602020-08-19 09:52:50 +0000279 return fmt.Errorf(fmt.Sprintf("device-already-reconciled-or-active-%s", device.Id))
Holger Hildebrandt9ca8b132020-08-07 14:45:03 +0000280 }
281 return nil
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000282}
283
284//Abandon_device unimplemented
285func (oo *OpenONUAC) Abandon_device(device *voltha.Device) error {
286 return errors.New("unImplemented")
287}
288
289//Disable_device disables the given device
290func (oo *OpenONUAC) Disable_device(device *voltha.Device) error {
divyadesai4d299552020-08-18 07:13:49 +0000291 logger.Debugw("Disable_device", log.Fields{"device-id": device.Id})
Holger Hildebrandtf07b44a2020-11-10 13:07:54 +0000292 if handler := oo.getDeviceHandler(device.Id, false); handler != nil {
Himani Chawla6d2ae152020-09-02 13:11:20 +0530293 go handler.disableDevice(device)
ozgecanetsiafce57b12020-05-25 14:39:35 +0300294 return nil
295 }
divyadesai4d299552020-08-18 07:13:49 +0000296 logger.Warnw("no handler found for device-disable", log.Fields{"device-id": device.Id})
ozgecanetsiafce57b12020-05-25 14:39:35 +0300297 return fmt.Errorf(fmt.Sprintf("handler-not-found-%s", device.Id))
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000298}
299
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000300//Reenable_device enables the onu device after disable
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000301func (oo *OpenONUAC) Reenable_device(device *voltha.Device) error {
divyadesai4d299552020-08-18 07:13:49 +0000302 logger.Debugw("Reenable_device", log.Fields{"device-id": device.Id})
Holger Hildebrandtf07b44a2020-11-10 13:07:54 +0000303 if handler := oo.getDeviceHandler(device.Id, false); handler != nil {
Himani Chawla6d2ae152020-09-02 13:11:20 +0530304 go handler.reEnableDevice(device)
ozgecanetsiafce57b12020-05-25 14:39:35 +0300305 return nil
306 }
divyadesai4d299552020-08-18 07:13:49 +0000307 logger.Warnw("no handler found for device-reenable", log.Fields{"device-id": device.Id})
ozgecanetsiafce57b12020-05-25 14:39:35 +0300308 return fmt.Errorf(fmt.Sprintf("handler-not-found-%s", device.Id))
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000309}
310
311//Reboot_device reboots the given device
312func (oo *OpenONUAC) Reboot_device(device *voltha.Device) error {
divyadesai4d299552020-08-18 07:13:49 +0000313 logger.Debugw("Reboot-device", log.Fields{"device-id": device.Id})
Holger Hildebrandtf07b44a2020-11-10 13:07:54 +0000314 if handler := oo.getDeviceHandler(device.Id, false); handler != nil {
Himani Chawla6d2ae152020-09-02 13:11:20 +0530315 go handler.rebootDevice(device)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300316 return nil
317 }
divyadesai4d299552020-08-18 07:13:49 +0000318 logger.Warnw("no handler found for device-reboot", log.Fields{"device-id": device.Id})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300319 return fmt.Errorf(fmt.Sprintf("handler-not-found-#{device.Id}"))
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000320}
321
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000322//Self_test_device unimplemented
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000323func (oo *OpenONUAC) Self_test_device(device *voltha.Device) error {
324 return errors.New("unImplemented")
325}
326
Himani Chawla6d2ae152020-09-02 13:11:20 +0530327// Delete_device deletes the given device
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000328func (oo *OpenONUAC) Delete_device(device *voltha.Device) error {
mpagenko2418ab02020-11-12 12:58:06 +0000329 logger.Debugw("Delete_device", log.Fields{"device-id": device.Id, "SerialNumber": device.SerialNumber})
Holger Hildebrandtf07b44a2020-11-10 13:07:54 +0000330 if handler := oo.getDeviceHandler(device.Id, false); handler != nil {
mpagenko2418ab02020-11-12 12:58:06 +0000331 err := handler.deleteDevicePersistencyData()
Holger Hildebrandtf07b44a2020-11-10 13:07:54 +0000332 //don't leave any garbage - even in error case
333 oo.deleteDeviceHandlerToMap(handler)
mpagenko2418ab02020-11-12 12:58:06 +0000334 return err
Holger Hildebrandt9ca8b132020-08-07 14:45:03 +0000335 }
mpagenko2418ab02020-11-12 12:58:06 +0000336 logger.Warnw("no handler found for device-deletion", log.Fields{"device-id": device.Id})
337 return fmt.Errorf(fmt.Sprintf("handler-not-found-%s", device.Id))
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000338}
339
340//Get_device_details unimplemented
341func (oo *OpenONUAC) Get_device_details(device *voltha.Device) error {
342 return errors.New("unImplemented")
343}
344
345//Update_flows_bulk returns
346func (oo *OpenONUAC) Update_flows_bulk(device *voltha.Device, flows *voltha.Flows, groups *voltha.FlowGroups, flowMetadata *voltha.FlowMetadata) error {
347 return errors.New("unImplemented")
348}
349
350//Update_flows_incrementally updates (add/remove) the flows on a given device
mpagenkodff5dda2020-08-28 11:52:01 +0000351func (oo *OpenONUAC) Update_flows_incrementally(device *voltha.Device,
352 flows *openflow_13.FlowChanges, groups *openflow_13.FlowGroupChanges, flowMetadata *voltha.FlowMetadata) error {
mpagenkofc4f56e2020-11-04 17:17:49 +0000353
354 //flow config is relayed to handler even if the device might be in some 'inactive' state
355 // let the handler or related FSM's decide, what to do with the modified flow state info
356 // at least the flow-remove must be done in respect to internal data, while OMCI activity might not be needed here
mpagenkodff5dda2020-08-28 11:52:01 +0000357
358 // For now, there is no support for group changes (as in the actual Py-adapter code)
mpagenkofc4f56e2020-11-04 17:17:49 +0000359 // but processing is continued for flowUpdate possibly also set in the request
mpagenkodff5dda2020-08-28 11:52:01 +0000360 if groups.ToAdd != nil && groups.ToAdd.Items != nil {
mpagenkofc4f56e2020-11-04 17:17:49 +0000361 logger.Warnw("Update-flow-incr: group add not supported (ignored)", log.Fields{"device-id": device.Id})
mpagenkodff5dda2020-08-28 11:52:01 +0000362 }
363 if groups.ToRemove != nil && groups.ToRemove.Items != nil {
mpagenkofc4f56e2020-11-04 17:17:49 +0000364 logger.Warnw("Update-flow-incr: group remove not supported (ignored)", log.Fields{"device-id": device.Id})
mpagenkodff5dda2020-08-28 11:52:01 +0000365 }
366 if groups.ToUpdate != nil && groups.ToUpdate.Items != nil {
mpagenkofc4f56e2020-11-04 17:17:49 +0000367 logger.Warnw("Update-flow-incr: group update not supported (ignored)", log.Fields{"device-id": device.Id})
mpagenkodff5dda2020-08-28 11:52:01 +0000368 }
369
Holger Hildebrandtf07b44a2020-11-10 13:07:54 +0000370 if handler := oo.getDeviceHandler(device.Id, false); handler != nil {
mpagenkodff5dda2020-08-28 11:52:01 +0000371 err := handler.FlowUpdateIncremental(flows, groups, flowMetadata)
372 return err
373 }
mpagenkofc4f56e2020-11-04 17:17:49 +0000374 logger.Warnw("no handler found for incremental flow update", log.Fields{"device-id": device.Id})
mpagenkodff5dda2020-08-28 11:52:01 +0000375 return fmt.Errorf(fmt.Sprintf("handler-not-found-%s", device.Id))
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000376}
377
378//Update_pm_config returns PmConfigs nil or error
379func (oo *OpenONUAC) Update_pm_config(device *voltha.Device, pmConfigs *voltha.PmConfigs) error {
380 return errors.New("unImplemented")
381}
382
383//Receive_packet_out sends packet out to the device
384func (oo *OpenONUAC) Receive_packet_out(deviceID string, egressPortNo int, packet *openflow_13.OfpPacketOut) error {
385 return errors.New("unImplemented")
386}
387
388//Suppress_event unimplemented
389func (oo *OpenONUAC) Suppress_event(filter *voltha.EventFilter) error {
390 return errors.New("unImplemented")
391}
392
393//Unsuppress_event unimplemented
394func (oo *OpenONUAC) Unsuppress_event(filter *voltha.EventFilter) error {
395 return errors.New("unImplemented")
396}
397
398//Download_image unimplemented
399func (oo *OpenONUAC) Download_image(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {
400 return nil, errors.New("unImplemented")
401}
402
403//Get_image_download_status unimplemented
404func (oo *OpenONUAC) Get_image_download_status(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {
405 return nil, errors.New("unImplemented")
406}
407
408//Cancel_image_download unimplemented
409func (oo *OpenONUAC) Cancel_image_download(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {
410 return nil, errors.New("unImplemented")
411}
412
413//Activate_image_update unimplemented
414func (oo *OpenONUAC) Activate_image_update(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {
415 return nil, errors.New("unImplemented")
416}
417
418//Revert_image_update unimplemented
419func (oo *OpenONUAC) Revert_image_update(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {
420 return nil, errors.New("unImplemented")
421}
422
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000423// Enable_port to Enable PON/NNI interface - seems not to be used/required according to python code
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000424func (oo *OpenONUAC) Enable_port(deviceID string, port *voltha.Port) error {
425 return errors.New("unImplemented")
426}
427
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000428// Disable_port to Disable pon/nni interface - seems not to be used/required according to python code
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000429func (oo *OpenONUAC) Disable_port(deviceID string, port *voltha.Port) error {
430 return errors.New("unImplemented")
431}
432
Himani Chawla6d2ae152020-09-02 13:11:20 +0530433//Child_device_lost - unimplemented
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000434//needed for if update >= 3.1.x
Matteo Scandolo2e6f1e32020-04-15 11:28:45 -0700435func (oo *OpenONUAC) Child_device_lost(deviceID string, pPortNo uint32, onuID uint32) error {
436 return errors.New("unImplemented")
437}
438
Himani Chawla6d2ae152020-09-02 13:11:20 +0530439// Start_omci_test unimplemented
Matteo Scandolo2e6f1e32020-04-15 11:28:45 -0700440func (oo *OpenONUAC) Start_omci_test(device *voltha.Device, request *voltha.OmciTestRequest) (*voltha.TestResponse, error) {
441 return nil, errors.New("unImplemented")
442}
443
Himani Chawla6d2ae152020-09-02 13:11:20 +0530444// Get_ext_value - unimplemented
Matteo Scandolod132c0e2020-04-24 17:06:25 -0700445func (oo *OpenONUAC) Get_ext_value(deviceID string, device *voltha.Device, valueparam voltha.ValueType_Type) (*voltha.ReturnValues, error) {
446 return nil, errors.New("unImplemented")
447}
448
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000449// Adapter interface required methods ################ end #########
450// #################################################################