blob: eeeb437c0939e8ea66bdc4fd581e835f011e4dc3 [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 }
Girish Gowdra7407a4d2020-11-12 12:44:53 -0800155 deviceCreateChan := oo.deviceHandlersCreateChan[deviceID]
Holger Hildebrandtf07b44a2020-11-10 13:07:54 +0000156 //keep the read sema short to allow for subsequent write
157 oo.lockDeviceHandlersMap.Unlock()
158 // based on concurrent processing the deviceHandler creation may not yet be finished at his point
159 // so it might be needed to wait here for that event with some timeout
160 select {
161 case <-time.After(1 * time.Second): //timer may be discussed ...
162 logger.Warnw("No valid deviceHandler created after max WaitTime", log.Fields{"device-id": deviceID})
163 return nil
Girish Gowdra7407a4d2020-11-12 12:44:53 -0800164 case <-deviceCreateChan:
Holger Hildebrandtf07b44a2020-11-10 13:07:54 +0000165 logger.Debugw("deviceHandler is ready now - continue", log.Fields{"device-id": deviceID})
Girish Gowdra7407a4d2020-11-12 12:44:53 -0800166 oo.lockDeviceHandlersMap.RLock()
167 defer oo.lockDeviceHandlersMap.RUnlock()
Holger Hildebrandtf07b44a2020-11-10 13:07:54 +0000168 return oo.deviceHandlers[deviceID]
169 }
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000170 }
Holger Hildebrandtf07b44a2020-11-10 13:07:54 +0000171 oo.lockDeviceHandlersMap.Unlock()
172 return agent
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000173}
174
175// Adapter interface required methods ############## begin #########
176// #################################################################
177
178// for original content compare: (needs according deviceHandler methods)
179// /voltha-openolt-adapter/adaptercore/openolt.go
180
181// Adopt_device creates a new device handler if not present already and then adopts the device
182func (oo *OpenONUAC) Adopt_device(device *voltha.Device) error {
183 if device == nil {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000184 logger.Warn("voltha-device-is-nil")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000185 return errors.New("nil-device")
186 }
187 ctx := context.Background()
divyadesai4d299552020-08-18 07:13:49 +0000188 logger.Infow("adopt-device", log.Fields{"device-id": device.Id})
Himani Chawla6d2ae152020-09-02 13:11:20 +0530189 var handler *deviceHandler
Holger Hildebrandtf07b44a2020-11-10 13:07:54 +0000190 if handler = oo.getDeviceHandler(device.Id, false); handler == nil {
Himani Chawla6d2ae152020-09-02 13:11:20 +0530191 handler := newDeviceHandler(oo.coreProxy, oo.adapterProxy, oo.eventProxy, device, oo)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000192 oo.addDeviceHandlerToMap(ctx, handler)
Himani Chawla6d2ae152020-09-02 13:11:20 +0530193 go handler.adoptOrReconcileDevice(ctx, device)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000194 // Launch the creation of the device topic
195 // go oo.createDeviceTopic(device)
196 }
197 return nil
198}
199
200//Get_ofp_device_info returns OFP information for the given device
201func (oo *OpenONUAC) Get_ofp_device_info(device *voltha.Device) (*ic.SwitchCapability, error) {
divyadesai4d299552020-08-18 07:13:49 +0000202 logger.Errorw("device-handler-not-set", log.Fields{"device-id": device.Id})
Andrea Campanella6515c582020-10-05 11:25:00 +0200203 return nil, fmt.Errorf("device-handler-not-set %s", device.Id)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000204}
205
206//Get_ofp_port_info returns OFP port information for the given device
mpagenkoaf801632020-07-03 10:00:42 +0000207//200630: method removed as per [VOL-3202]: OF port info is now to be delivered within UniPort create
208// cmp changes in onu_uni_port.go::CreateVolthaPort()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000209
210//Process_inter_adapter_message sends messages to a target device (between adapters)
211func (oo *OpenONUAC) Process_inter_adapter_message(msg *ic.InterAdapterMessage) error {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000212 logger.Debugw("Process_inter_adapter_message", log.Fields{"msgId": msg.Header.Id,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000213 "msgProxyDeviceId": msg.Header.ProxyDeviceId, "msgToDeviceId": msg.Header.ToDeviceId})
214
Holger Hildebrandtf07b44a2020-11-10 13:07:54 +0000215 var waitForDhInstPresent bool
216 //ToDeviceId should address a DeviceHandler instance
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000217 targetDevice := msg.Header.ToDeviceId
Holger Hildebrandtf07b44a2020-11-10 13:07:54 +0000218 // As a workaround this handling is only required for the OnuIndication with OperState=Up event.
219 // But we live without that further check and use this processing also for OperState down/unreachable events to avoid
220 // the deeper message processing at this stage. Should do no harm on the other events (except for run time)
221 if msg.Header.Type != ic.InterAdapterMessageType_ONU_IND_REQUEST {
222 waitForDhInstPresent = false
223 } else {
224 //Race condition (relevant in BBSIM-environment only): Due to unsynchronized processing of olt-adapter and rw_core,
225 //ONU_IND_REQUEST msg by olt-adapter could arrive a little bit earlier than rw_core was able to announce the corresponding
226 //ONU by RPC of Adopt_device()
227 logger.Debugw("ONU_IND_REQUEST - potentially wait until DeviceHandler instance is created", log.Fields{"device-id": targetDevice})
228 waitForDhInstPresent = true
229 }
230 if handler := oo.getDeviceHandler(targetDevice, waitForDhInstPresent); handler != nil {
mpagenko1cc3cb42020-07-27 15:24:38 +0000231 /* 200724: modification towards synchronous implementation - possible errors within processing shall be
232 * in the accordingly delayed response, some timing effect might result in Techprofile processing for multiple UNI's
233 */
Himani Chawla6d2ae152020-09-02 13:11:20 +0530234 return handler.processInterAdapterMessage(msg)
mpagenko1cc3cb42020-07-27 15:24:38 +0000235 /* so far the processing has been in background with according commented error treatment restrictions:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000236 go handler.ProcessInterAdapterMessage(msg)
237 // error treatment might be more sophisticated
238 // by now let's just accept the message on 'communication layer'
239 // message content problems have to be evaluated then in the handler
240 // and are by now not reported to the calling party (to force what reaction there?)
241 return nil
mpagenko1cc3cb42020-07-27 15:24:38 +0000242 */
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000243 }
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000244 logger.Warnw("no handler found for received Inter-Proxy-message", log.Fields{
245 "msgToDeviceId": targetDevice})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000246 return fmt.Errorf(fmt.Sprintf("handler-not-found-%s", targetDevice))
247}
248
249//Adapter_descriptor not implemented
250func (oo *OpenONUAC) Adapter_descriptor() error {
251 return errors.New("unImplemented")
252}
253
254//Device_types unimplemented
255func (oo *OpenONUAC) Device_types() (*voltha.DeviceTypes, error) {
256 return nil, errors.New("unImplemented")
257}
258
259//Health returns unimplemented
260func (oo *OpenONUAC) Health() (*voltha.HealthStatus, error) {
261 return nil, errors.New("unImplemented")
262}
263
Holger Hildebrandt9ca8b132020-08-07 14:45:03 +0000264//Reconcile_device is called once when the adapter needs to re-create device - usually on core restart
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000265func (oo *OpenONUAC) Reconcile_device(device *voltha.Device) error {
Holger Hildebrandtf41a1602020-08-19 09:52:50 +0000266 if device == nil {
267 logger.Warn("voltha-device-is-nil")
268 return errors.New("nil-device")
269 }
270 ctx := context.Background()
271 logger.Infow("Reconcile_device", log.Fields{"device-id": device.Id})
Himani Chawla6d2ae152020-09-02 13:11:20 +0530272 var handler *deviceHandler
Holger Hildebrandtf07b44a2020-11-10 13:07:54 +0000273 if handler = oo.getDeviceHandler(device.Id, false); handler == nil {
Himani Chawla6d2ae152020-09-02 13:11:20 +0530274 handler := newDeviceHandler(oo.coreProxy, oo.adapterProxy, oo.eventProxy, device, oo)
Holger Hildebrandtf41a1602020-08-19 09:52:50 +0000275 oo.addDeviceHandlerToMap(ctx, handler)
276 handler.device = device
277 handler.reconciling = true
Himani Chawla6d2ae152020-09-02 13:11:20 +0530278 go handler.adoptOrReconcileDevice(ctx, handler.device)
Holger Hildebrandtf41a1602020-08-19 09:52:50 +0000279 // reconcilement will be continued after onu-device entry is added
Holger Hildebrandt9ca8b132020-08-07 14:45:03 +0000280 } else {
Holger Hildebrandtf41a1602020-08-19 09:52:50 +0000281 return fmt.Errorf(fmt.Sprintf("device-already-reconciled-or-active-%s", device.Id))
Holger Hildebrandt9ca8b132020-08-07 14:45:03 +0000282 }
283 return nil
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000284}
285
286//Abandon_device unimplemented
287func (oo *OpenONUAC) Abandon_device(device *voltha.Device) error {
288 return errors.New("unImplemented")
289}
290
291//Disable_device disables the given device
292func (oo *OpenONUAC) Disable_device(device *voltha.Device) error {
divyadesai4d299552020-08-18 07:13:49 +0000293 logger.Debugw("Disable_device", log.Fields{"device-id": device.Id})
Holger Hildebrandtf07b44a2020-11-10 13:07:54 +0000294 if handler := oo.getDeviceHandler(device.Id, false); handler != nil {
Himani Chawla6d2ae152020-09-02 13:11:20 +0530295 go handler.disableDevice(device)
ozgecanetsiafce57b12020-05-25 14:39:35 +0300296 return nil
297 }
divyadesai4d299552020-08-18 07:13:49 +0000298 logger.Warnw("no handler found for device-disable", log.Fields{"device-id": device.Id})
ozgecanetsiafce57b12020-05-25 14:39:35 +0300299 return fmt.Errorf(fmt.Sprintf("handler-not-found-%s", device.Id))
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000300}
301
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000302//Reenable_device enables the onu device after disable
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000303func (oo *OpenONUAC) Reenable_device(device *voltha.Device) error {
divyadesai4d299552020-08-18 07:13:49 +0000304 logger.Debugw("Reenable_device", log.Fields{"device-id": device.Id})
Holger Hildebrandtf07b44a2020-11-10 13:07:54 +0000305 if handler := oo.getDeviceHandler(device.Id, false); handler != nil {
Himani Chawla6d2ae152020-09-02 13:11:20 +0530306 go handler.reEnableDevice(device)
ozgecanetsiafce57b12020-05-25 14:39:35 +0300307 return nil
308 }
divyadesai4d299552020-08-18 07:13:49 +0000309 logger.Warnw("no handler found for device-reenable", log.Fields{"device-id": device.Id})
ozgecanetsiafce57b12020-05-25 14:39:35 +0300310 return fmt.Errorf(fmt.Sprintf("handler-not-found-%s", device.Id))
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000311}
312
313//Reboot_device reboots the given device
314func (oo *OpenONUAC) Reboot_device(device *voltha.Device) error {
divyadesai4d299552020-08-18 07:13:49 +0000315 logger.Debugw("Reboot-device", log.Fields{"device-id": device.Id})
Holger Hildebrandtf07b44a2020-11-10 13:07:54 +0000316 if handler := oo.getDeviceHandler(device.Id, false); handler != nil {
Himani Chawla6d2ae152020-09-02 13:11:20 +0530317 go handler.rebootDevice(device)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300318 return nil
319 }
divyadesai4d299552020-08-18 07:13:49 +0000320 logger.Warnw("no handler found for device-reboot", log.Fields{"device-id": device.Id})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300321 return fmt.Errorf(fmt.Sprintf("handler-not-found-#{device.Id}"))
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000322}
323
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000324//Self_test_device unimplemented
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000325func (oo *OpenONUAC) Self_test_device(device *voltha.Device) error {
326 return errors.New("unImplemented")
327}
328
Himani Chawla6d2ae152020-09-02 13:11:20 +0530329// Delete_device deletes the given device
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000330func (oo *OpenONUAC) Delete_device(device *voltha.Device) error {
mpagenko2418ab02020-11-12 12:58:06 +0000331 logger.Debugw("Delete_device", log.Fields{"device-id": device.Id, "SerialNumber": device.SerialNumber})
Holger Hildebrandtf07b44a2020-11-10 13:07:54 +0000332 if handler := oo.getDeviceHandler(device.Id, false); handler != nil {
mpagenko2418ab02020-11-12 12:58:06 +0000333 err := handler.deleteDevicePersistencyData()
Holger Hildebrandtf07b44a2020-11-10 13:07:54 +0000334 //don't leave any garbage - even in error case
335 oo.deleteDeviceHandlerToMap(handler)
mpagenko2418ab02020-11-12 12:58:06 +0000336 return err
Holger Hildebrandt9ca8b132020-08-07 14:45:03 +0000337 }
mpagenko2418ab02020-11-12 12:58:06 +0000338 logger.Warnw("no handler found for device-deletion", log.Fields{"device-id": device.Id})
339 return fmt.Errorf(fmt.Sprintf("handler-not-found-%s", device.Id))
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000340}
341
342//Get_device_details unimplemented
343func (oo *OpenONUAC) Get_device_details(device *voltha.Device) error {
344 return errors.New("unImplemented")
345}
346
347//Update_flows_bulk returns
348func (oo *OpenONUAC) Update_flows_bulk(device *voltha.Device, flows *voltha.Flows, groups *voltha.FlowGroups, flowMetadata *voltha.FlowMetadata) error {
349 return errors.New("unImplemented")
350}
351
352//Update_flows_incrementally updates (add/remove) the flows on a given device
mpagenkodff5dda2020-08-28 11:52:01 +0000353func (oo *OpenONUAC) Update_flows_incrementally(device *voltha.Device,
354 flows *openflow_13.FlowChanges, groups *openflow_13.FlowGroupChanges, flowMetadata *voltha.FlowMetadata) error {
mpagenkofc4f56e2020-11-04 17:17:49 +0000355
356 //flow config is relayed to handler even if the device might be in some 'inactive' state
357 // let the handler or related FSM's decide, what to do with the modified flow state info
358 // 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 +0000359
360 // For now, there is no support for group changes (as in the actual Py-adapter code)
mpagenkofc4f56e2020-11-04 17:17:49 +0000361 // but processing is continued for flowUpdate possibly also set in the request
mpagenkodff5dda2020-08-28 11:52:01 +0000362 if groups.ToAdd != nil && groups.ToAdd.Items != nil {
mpagenkofc4f56e2020-11-04 17:17:49 +0000363 logger.Warnw("Update-flow-incr: group add not supported (ignored)", log.Fields{"device-id": device.Id})
mpagenkodff5dda2020-08-28 11:52:01 +0000364 }
365 if groups.ToRemove != nil && groups.ToRemove.Items != nil {
mpagenkofc4f56e2020-11-04 17:17:49 +0000366 logger.Warnw("Update-flow-incr: group remove not supported (ignored)", log.Fields{"device-id": device.Id})
mpagenkodff5dda2020-08-28 11:52:01 +0000367 }
368 if groups.ToUpdate != nil && groups.ToUpdate.Items != nil {
mpagenkofc4f56e2020-11-04 17:17:49 +0000369 logger.Warnw("Update-flow-incr: group update not supported (ignored)", log.Fields{"device-id": device.Id})
mpagenkodff5dda2020-08-28 11:52:01 +0000370 }
371
Holger Hildebrandtf07b44a2020-11-10 13:07:54 +0000372 if handler := oo.getDeviceHandler(device.Id, false); handler != nil {
mpagenkodff5dda2020-08-28 11:52:01 +0000373 err := handler.FlowUpdateIncremental(flows, groups, flowMetadata)
374 return err
375 }
mpagenkofc4f56e2020-11-04 17:17:49 +0000376 logger.Warnw("no handler found for incremental flow update", log.Fields{"device-id": device.Id})
mpagenkodff5dda2020-08-28 11:52:01 +0000377 return fmt.Errorf(fmt.Sprintf("handler-not-found-%s", device.Id))
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000378}
379
380//Update_pm_config returns PmConfigs nil or error
381func (oo *OpenONUAC) Update_pm_config(device *voltha.Device, pmConfigs *voltha.PmConfigs) error {
382 return errors.New("unImplemented")
383}
384
385//Receive_packet_out sends packet out to the device
386func (oo *OpenONUAC) Receive_packet_out(deviceID string, egressPortNo int, packet *openflow_13.OfpPacketOut) error {
387 return errors.New("unImplemented")
388}
389
390//Suppress_event unimplemented
391func (oo *OpenONUAC) Suppress_event(filter *voltha.EventFilter) error {
392 return errors.New("unImplemented")
393}
394
395//Unsuppress_event unimplemented
396func (oo *OpenONUAC) Unsuppress_event(filter *voltha.EventFilter) error {
397 return errors.New("unImplemented")
398}
399
400//Download_image unimplemented
401func (oo *OpenONUAC) Download_image(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {
402 return nil, errors.New("unImplemented")
403}
404
405//Get_image_download_status unimplemented
406func (oo *OpenONUAC) Get_image_download_status(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {
407 return nil, errors.New("unImplemented")
408}
409
410//Cancel_image_download unimplemented
411func (oo *OpenONUAC) Cancel_image_download(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {
412 return nil, errors.New("unImplemented")
413}
414
415//Activate_image_update unimplemented
416func (oo *OpenONUAC) Activate_image_update(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {
417 return nil, errors.New("unImplemented")
418}
419
420//Revert_image_update unimplemented
421func (oo *OpenONUAC) Revert_image_update(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {
422 return nil, errors.New("unImplemented")
423}
424
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000425// Enable_port to Enable PON/NNI interface - seems not to be used/required according to python code
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000426func (oo *OpenONUAC) Enable_port(deviceID string, port *voltha.Port) error {
427 return errors.New("unImplemented")
428}
429
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000430// Disable_port to Disable pon/nni interface - seems not to be used/required according to python code
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000431func (oo *OpenONUAC) Disable_port(deviceID string, port *voltha.Port) error {
432 return errors.New("unImplemented")
433}
434
Himani Chawla6d2ae152020-09-02 13:11:20 +0530435//Child_device_lost - unimplemented
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000436//needed for if update >= 3.1.x
Matteo Scandolo2e6f1e32020-04-15 11:28:45 -0700437func (oo *OpenONUAC) Child_device_lost(deviceID string, pPortNo uint32, onuID uint32) error {
438 return errors.New("unImplemented")
439}
440
Himani Chawla6d2ae152020-09-02 13:11:20 +0530441// Start_omci_test unimplemented
Matteo Scandolo2e6f1e32020-04-15 11:28:45 -0700442func (oo *OpenONUAC) Start_omci_test(device *voltha.Device, request *voltha.OmciTestRequest) (*voltha.TestResponse, error) {
443 return nil, errors.New("unImplemented")
444}
445
Himani Chawla6d2ae152020-09-02 13:11:20 +0530446// Get_ext_value - unimplemented
Matteo Scandolod132c0e2020-04-24 17:06:25 -0700447func (oo *OpenONUAC) Get_ext_value(deviceID string, device *voltha.Device, valueparam voltha.ValueType_Type) (*voltha.ReturnValues, error) {
448 return nil, errors.New("unImplemented")
449}
450
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000451// Adapter interface required methods ################ end #########
452// #################################################################