Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 1 | /* |
| 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 Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 17 | //Package adaptercoreonu provides the utility for onu devices, flows and statistics |
| 18 | package adaptercoreonu |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 19 | |
| 20 | import ( |
| 21 | "context" |
| 22 | "errors" |
| 23 | "fmt" |
| 24 | "sync" |
| 25 | "time" |
| 26 | |
| 27 | "github.com/opencord/voltha-lib-go/v3/pkg/adapters/adapterif" |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 28 | "github.com/opencord/voltha-lib-go/v3/pkg/db/kvstore" |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 29 | "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 Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 35 | "test.internal/openadapter/internal/pkg/config" |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 36 | ) |
| 37 | |
| 38 | //OpenONUAC structure holds the ONU core information |
| 39 | type OpenONUAC struct { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 40 | deviceHandlers map[string]*deviceHandler |
Holger Hildebrandt | f07b44a | 2020-11-10 13:07:54 +0000 | [diff] [blame] | 41 | deviceHandlersCreateChan map[string]chan bool //channels for deviceHandler create events |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 42 | coreProxy adapterif.CoreProxy |
| 43 | adapterProxy adapterif.AdapterProxy |
| 44 | eventProxy adapterif.EventProxy |
| 45 | kafkaICProxy kafka.InterContainerProxy |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 46 | kvClient kvstore.Client |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 47 | config *config.AdapterFlags |
| 48 | numOnus int |
| 49 | KVStoreHost string |
| 50 | KVStorePort int |
| 51 | KVStoreType string |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 52 | KVStoreTimeout time.Duration |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 53 | exitChannel chan int |
| 54 | HeartbeatCheckInterval time.Duration |
| 55 | HeartbeatFailReportInterval time.Duration |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 56 | AcceptIncrementalEvto bool |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 57 | //GrpcTimeoutInterval time.Duration |
Himani Chawla | d96df18 | 2020-09-28 11:12:02 +0530 | [diff] [blame] | 58 | lockDeviceHandlersMap sync.RWMutex |
| 59 | pSupportedFsms *OmciDeviceFsms |
| 60 | maxTimeoutInterAdapterComm time.Duration |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 61 | } |
| 62 | |
| 63 | //NewOpenONUAC returns a new instance of OpenONU_AC |
| 64 | func NewOpenONUAC(ctx context.Context, kafkaICProxy kafka.InterContainerProxy, |
| 65 | coreProxy adapterif.CoreProxy, adapterProxy adapterif.AdapterProxy, |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 66 | eventProxy adapterif.EventProxy, kvClient kvstore.Client, cfg *config.AdapterFlags) *OpenONUAC { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 67 | var openOnuAc OpenONUAC |
| 68 | openOnuAc.exitChannel = make(chan int, 1) |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 69 | openOnuAc.deviceHandlers = make(map[string]*deviceHandler) |
Holger Hildebrandt | f07b44a | 2020-11-10 13:07:54 +0000 | [diff] [blame] | 70 | openOnuAc.deviceHandlersCreateChan = make(map[string]chan bool) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 71 | openOnuAc.kafkaICProxy = kafkaICProxy |
| 72 | openOnuAc.config = cfg |
| 73 | openOnuAc.numOnus = cfg.OnuNumber |
| 74 | openOnuAc.coreProxy = coreProxy |
| 75 | openOnuAc.adapterProxy = adapterProxy |
| 76 | openOnuAc.eventProxy = eventProxy |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 77 | openOnuAc.kvClient = kvClient |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 78 | openOnuAc.KVStoreHost = cfg.KVStoreHost |
| 79 | openOnuAc.KVStorePort = cfg.KVStorePort |
| 80 | openOnuAc.KVStoreType = cfg.KVStoreType |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 81 | openOnuAc.KVStoreTimeout = cfg.KVStoreTimeout |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 82 | openOnuAc.HeartbeatCheckInterval = cfg.HeartbeatCheckInterval |
| 83 | openOnuAc.HeartbeatFailReportInterval = cfg.HeartbeatFailReportInterval |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 84 | openOnuAc.AcceptIncrementalEvto = cfg.AccIncrEvto |
Himani Chawla | d96df18 | 2020-09-28 11:12:02 +0530 | [diff] [blame] | 85 | openOnuAc.maxTimeoutInterAdapterComm = cfg.MaxTimeoutInterAdapterComm |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 86 | //openOnuAc.GrpcTimeoutInterval = cfg.GrpcTimeoutInterval |
| 87 | openOnuAc.lockDeviceHandlersMap = sync.RWMutex{} |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 88 | |
| 89 | openOnuAc.pSupportedFsms = &OmciDeviceFsms{ |
| 90 | "mib-synchronizer": { |
| 91 | //mibSyncFsm, // Implements the MIB synchronization state machine |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 92 | mibDbVolatileDictImpl, // Implements volatile ME MIB database |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 93 | //true, // Advertise events on OpenOMCI event bus |
| 94 | cMibAuditDelayImpl, // Time to wait between MIB audits. 0 to disable audits. |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 95 | // 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 Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 106 | return &openOnuAc |
| 107 | } |
| 108 | |
| 109 | //Start starts (logs) the adapter |
| 110 | func (oo *OpenONUAC) Start(ctx context.Context) error { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 111 | logger.Info("starting-openonu-adapter") |
| 112 | logger.Info("openonu-adapter-started") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 113 | return nil |
| 114 | } |
| 115 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 116 | /* |
| 117 | //stop terminates the session |
| 118 | func (oo *OpenONUAC) stop(ctx context.Context) error { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 119 | logger.Info("stopping-device-manager") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 120 | oo.exitChannel <- 1 |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 121 | logger.Info("device-manager-stopped") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 122 | return nil |
| 123 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 124 | */ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 125 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 126 | func (oo *OpenONUAC) addDeviceHandlerToMap(ctx context.Context, agent *deviceHandler) { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 127 | oo.lockDeviceHandlersMap.Lock() |
| 128 | defer oo.lockDeviceHandlersMap.Unlock() |
| 129 | if _, exist := oo.deviceHandlers[agent.deviceID]; !exist { |
| 130 | oo.deviceHandlers[agent.deviceID] = agent |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 131 | oo.deviceHandlers[agent.deviceID].start(ctx) |
Holger Hildebrandt | f07b44a | 2020-11-10 13:07:54 +0000 | [diff] [blame] | 132 | 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 Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 136 | } |
| 137 | } |
| 138 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 139 | func (oo *OpenONUAC) deleteDeviceHandlerToMap(agent *deviceHandler) { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 140 | oo.lockDeviceHandlersMap.Lock() |
| 141 | defer oo.lockDeviceHandlersMap.Unlock() |
| 142 | delete(oo.deviceHandlers, agent.deviceID) |
Holger Hildebrandt | f07b44a | 2020-11-10 13:07:54 +0000 | [diff] [blame] | 143 | delete(oo.deviceHandlersCreateChan, agent.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 144 | } |
| 145 | |
Holger Hildebrandt | f07b44a | 2020-11-10 13:07:54 +0000 | [diff] [blame] | 146 | //getDeviceHandler gets the ONU deviceHandler and may wait until it is created |
| 147 | func (oo *OpenONUAC) getDeviceHandler(deviceID string, aWait bool) *deviceHandler { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 148 | oo.lockDeviceHandlersMap.Lock() |
Holger Hildebrandt | f07b44a | 2020-11-10 13:07:54 +0000 | [diff] [blame] | 149 | 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 Gowdra | 7407a4d | 2020-11-12 12:44:53 -0800 | [diff] [blame^] | 155 | deviceCreateChan := oo.deviceHandlersCreateChan[deviceID] |
Holger Hildebrandt | f07b44a | 2020-11-10 13:07:54 +0000 | [diff] [blame] | 156 | //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 Gowdra | 7407a4d | 2020-11-12 12:44:53 -0800 | [diff] [blame^] | 164 | case <-deviceCreateChan: |
Holger Hildebrandt | f07b44a | 2020-11-10 13:07:54 +0000 | [diff] [blame] | 165 | logger.Debugw("deviceHandler is ready now - continue", log.Fields{"device-id": deviceID}) |
Girish Gowdra | 7407a4d | 2020-11-12 12:44:53 -0800 | [diff] [blame^] | 166 | oo.lockDeviceHandlersMap.RLock() |
| 167 | defer oo.lockDeviceHandlersMap.RUnlock() |
Holger Hildebrandt | f07b44a | 2020-11-10 13:07:54 +0000 | [diff] [blame] | 168 | return oo.deviceHandlers[deviceID] |
| 169 | } |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 170 | } |
Holger Hildebrandt | f07b44a | 2020-11-10 13:07:54 +0000 | [diff] [blame] | 171 | oo.lockDeviceHandlersMap.Unlock() |
| 172 | return agent |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 173 | } |
| 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 |
| 182 | func (oo *OpenONUAC) Adopt_device(device *voltha.Device) error { |
| 183 | if device == nil { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 184 | logger.Warn("voltha-device-is-nil") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 185 | return errors.New("nil-device") |
| 186 | } |
| 187 | ctx := context.Background() |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 188 | logger.Infow("adopt-device", log.Fields{"device-id": device.Id}) |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 189 | var handler *deviceHandler |
Holger Hildebrandt | f07b44a | 2020-11-10 13:07:54 +0000 | [diff] [blame] | 190 | if handler = oo.getDeviceHandler(device.Id, false); handler == nil { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 191 | handler := newDeviceHandler(oo.coreProxy, oo.adapterProxy, oo.eventProxy, device, oo) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 192 | oo.addDeviceHandlerToMap(ctx, handler) |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 193 | go handler.adoptOrReconcileDevice(ctx, device) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 194 | // 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 |
| 201 | func (oo *OpenONUAC) Get_ofp_device_info(device *voltha.Device) (*ic.SwitchCapability, error) { |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 202 | logger.Errorw("device-handler-not-set", log.Fields{"device-id": device.Id}) |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 203 | return nil, fmt.Errorf("device-handler-not-set %s", device.Id) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 204 | } |
| 205 | |
| 206 | //Get_ofp_port_info returns OFP port information for the given device |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 207 | //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 Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 209 | |
| 210 | //Process_inter_adapter_message sends messages to a target device (between adapters) |
| 211 | func (oo *OpenONUAC) Process_inter_adapter_message(msg *ic.InterAdapterMessage) error { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 212 | logger.Debugw("Process_inter_adapter_message", log.Fields{"msgId": msg.Header.Id, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 213 | "msgProxyDeviceId": msg.Header.ProxyDeviceId, "msgToDeviceId": msg.Header.ToDeviceId}) |
| 214 | |
Holger Hildebrandt | f07b44a | 2020-11-10 13:07:54 +0000 | [diff] [blame] | 215 | var waitForDhInstPresent bool |
| 216 | //ToDeviceId should address a DeviceHandler instance |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 217 | targetDevice := msg.Header.ToDeviceId |
Holger Hildebrandt | f07b44a | 2020-11-10 13:07:54 +0000 | [diff] [blame] | 218 | // 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 { |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 231 | /* 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 Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 234 | return handler.processInterAdapterMessage(msg) |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 235 | /* so far the processing has been in background with according commented error treatment restrictions: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 236 | 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 |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 242 | */ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 243 | } |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 244 | logger.Warnw("no handler found for received Inter-Proxy-message", log.Fields{ |
| 245 | "msgToDeviceId": targetDevice}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 246 | return fmt.Errorf(fmt.Sprintf("handler-not-found-%s", targetDevice)) |
| 247 | } |
| 248 | |
| 249 | //Adapter_descriptor not implemented |
| 250 | func (oo *OpenONUAC) Adapter_descriptor() error { |
| 251 | return errors.New("unImplemented") |
| 252 | } |
| 253 | |
| 254 | //Device_types unimplemented |
| 255 | func (oo *OpenONUAC) Device_types() (*voltha.DeviceTypes, error) { |
| 256 | return nil, errors.New("unImplemented") |
| 257 | } |
| 258 | |
| 259 | //Health returns unimplemented |
| 260 | func (oo *OpenONUAC) Health() (*voltha.HealthStatus, error) { |
| 261 | return nil, errors.New("unImplemented") |
| 262 | } |
| 263 | |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 264 | //Reconcile_device is called once when the adapter needs to re-create device - usually on core restart |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 265 | func (oo *OpenONUAC) Reconcile_device(device *voltha.Device) error { |
Holger Hildebrandt | f41a160 | 2020-08-19 09:52:50 +0000 | [diff] [blame] | 266 | 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 Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 272 | var handler *deviceHandler |
Holger Hildebrandt | f07b44a | 2020-11-10 13:07:54 +0000 | [diff] [blame] | 273 | if handler = oo.getDeviceHandler(device.Id, false); handler == nil { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 274 | handler := newDeviceHandler(oo.coreProxy, oo.adapterProxy, oo.eventProxy, device, oo) |
Holger Hildebrandt | f41a160 | 2020-08-19 09:52:50 +0000 | [diff] [blame] | 275 | oo.addDeviceHandlerToMap(ctx, handler) |
| 276 | handler.device = device |
| 277 | handler.reconciling = true |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 278 | go handler.adoptOrReconcileDevice(ctx, handler.device) |
Holger Hildebrandt | f41a160 | 2020-08-19 09:52:50 +0000 | [diff] [blame] | 279 | // reconcilement will be continued after onu-device entry is added |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 280 | } else { |
Holger Hildebrandt | f41a160 | 2020-08-19 09:52:50 +0000 | [diff] [blame] | 281 | return fmt.Errorf(fmt.Sprintf("device-already-reconciled-or-active-%s", device.Id)) |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 282 | } |
| 283 | return nil |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 284 | } |
| 285 | |
| 286 | //Abandon_device unimplemented |
| 287 | func (oo *OpenONUAC) Abandon_device(device *voltha.Device) error { |
| 288 | return errors.New("unImplemented") |
| 289 | } |
| 290 | |
| 291 | //Disable_device disables the given device |
| 292 | func (oo *OpenONUAC) Disable_device(device *voltha.Device) error { |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 293 | logger.Debugw("Disable_device", log.Fields{"device-id": device.Id}) |
Holger Hildebrandt | f07b44a | 2020-11-10 13:07:54 +0000 | [diff] [blame] | 294 | if handler := oo.getDeviceHandler(device.Id, false); handler != nil { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 295 | go handler.disableDevice(device) |
ozgecanetsia | fce57b1 | 2020-05-25 14:39:35 +0300 | [diff] [blame] | 296 | return nil |
| 297 | } |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 298 | logger.Warnw("no handler found for device-disable", log.Fields{"device-id": device.Id}) |
ozgecanetsia | fce57b1 | 2020-05-25 14:39:35 +0300 | [diff] [blame] | 299 | return fmt.Errorf(fmt.Sprintf("handler-not-found-%s", device.Id)) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 300 | } |
| 301 | |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 302 | //Reenable_device enables the onu device after disable |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 303 | func (oo *OpenONUAC) Reenable_device(device *voltha.Device) error { |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 304 | logger.Debugw("Reenable_device", log.Fields{"device-id": device.Id}) |
Holger Hildebrandt | f07b44a | 2020-11-10 13:07:54 +0000 | [diff] [blame] | 305 | if handler := oo.getDeviceHandler(device.Id, false); handler != nil { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 306 | go handler.reEnableDevice(device) |
ozgecanetsia | fce57b1 | 2020-05-25 14:39:35 +0300 | [diff] [blame] | 307 | return nil |
| 308 | } |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 309 | logger.Warnw("no handler found for device-reenable", log.Fields{"device-id": device.Id}) |
ozgecanetsia | fce57b1 | 2020-05-25 14:39:35 +0300 | [diff] [blame] | 310 | return fmt.Errorf(fmt.Sprintf("handler-not-found-%s", device.Id)) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 311 | } |
| 312 | |
| 313 | //Reboot_device reboots the given device |
| 314 | func (oo *OpenONUAC) Reboot_device(device *voltha.Device) error { |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 315 | logger.Debugw("Reboot-device", log.Fields{"device-id": device.Id}) |
Holger Hildebrandt | f07b44a | 2020-11-10 13:07:54 +0000 | [diff] [blame] | 316 | if handler := oo.getDeviceHandler(device.Id, false); handler != nil { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 317 | go handler.rebootDevice(device) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 318 | return nil |
| 319 | } |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 320 | logger.Warnw("no handler found for device-reboot", log.Fields{"device-id": device.Id}) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 321 | return fmt.Errorf(fmt.Sprintf("handler-not-found-#{device.Id}")) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 322 | } |
| 323 | |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 324 | //Self_test_device unimplemented |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 325 | func (oo *OpenONUAC) Self_test_device(device *voltha.Device) error { |
| 326 | return errors.New("unImplemented") |
| 327 | } |
| 328 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 329 | // Delete_device deletes the given device |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 330 | func (oo *OpenONUAC) Delete_device(device *voltha.Device) error { |
mpagenko | 2418ab0 | 2020-11-12 12:58:06 +0000 | [diff] [blame] | 331 | logger.Debugw("Delete_device", log.Fields{"device-id": device.Id, "SerialNumber": device.SerialNumber}) |
Holger Hildebrandt | f07b44a | 2020-11-10 13:07:54 +0000 | [diff] [blame] | 332 | if handler := oo.getDeviceHandler(device.Id, false); handler != nil { |
mpagenko | 2418ab0 | 2020-11-12 12:58:06 +0000 | [diff] [blame] | 333 | err := handler.deleteDevicePersistencyData() |
Holger Hildebrandt | f07b44a | 2020-11-10 13:07:54 +0000 | [diff] [blame] | 334 | //don't leave any garbage - even in error case |
| 335 | oo.deleteDeviceHandlerToMap(handler) |
mpagenko | 2418ab0 | 2020-11-12 12:58:06 +0000 | [diff] [blame] | 336 | return err |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 337 | } |
mpagenko | 2418ab0 | 2020-11-12 12:58:06 +0000 | [diff] [blame] | 338 | 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 Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 340 | } |
| 341 | |
| 342 | //Get_device_details unimplemented |
| 343 | func (oo *OpenONUAC) Get_device_details(device *voltha.Device) error { |
| 344 | return errors.New("unImplemented") |
| 345 | } |
| 346 | |
| 347 | //Update_flows_bulk returns |
| 348 | func (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 |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 353 | func (oo *OpenONUAC) Update_flows_incrementally(device *voltha.Device, |
| 354 | flows *openflow_13.FlowChanges, groups *openflow_13.FlowGroupChanges, flowMetadata *voltha.FlowMetadata) error { |
mpagenko | fc4f56e | 2020-11-04 17:17:49 +0000 | [diff] [blame] | 355 | |
| 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 |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 359 | |
| 360 | // For now, there is no support for group changes (as in the actual Py-adapter code) |
mpagenko | fc4f56e | 2020-11-04 17:17:49 +0000 | [diff] [blame] | 361 | // but processing is continued for flowUpdate possibly also set in the request |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 362 | if groups.ToAdd != nil && groups.ToAdd.Items != nil { |
mpagenko | fc4f56e | 2020-11-04 17:17:49 +0000 | [diff] [blame] | 363 | logger.Warnw("Update-flow-incr: group add not supported (ignored)", log.Fields{"device-id": device.Id}) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 364 | } |
| 365 | if groups.ToRemove != nil && groups.ToRemove.Items != nil { |
mpagenko | fc4f56e | 2020-11-04 17:17:49 +0000 | [diff] [blame] | 366 | logger.Warnw("Update-flow-incr: group remove not supported (ignored)", log.Fields{"device-id": device.Id}) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 367 | } |
| 368 | if groups.ToUpdate != nil && groups.ToUpdate.Items != nil { |
mpagenko | fc4f56e | 2020-11-04 17:17:49 +0000 | [diff] [blame] | 369 | logger.Warnw("Update-flow-incr: group update not supported (ignored)", log.Fields{"device-id": device.Id}) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 370 | } |
| 371 | |
Holger Hildebrandt | f07b44a | 2020-11-10 13:07:54 +0000 | [diff] [blame] | 372 | if handler := oo.getDeviceHandler(device.Id, false); handler != nil { |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 373 | err := handler.FlowUpdateIncremental(flows, groups, flowMetadata) |
| 374 | return err |
| 375 | } |
mpagenko | fc4f56e | 2020-11-04 17:17:49 +0000 | [diff] [blame] | 376 | logger.Warnw("no handler found for incremental flow update", log.Fields{"device-id": device.Id}) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 377 | return fmt.Errorf(fmt.Sprintf("handler-not-found-%s", device.Id)) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 378 | } |
| 379 | |
| 380 | //Update_pm_config returns PmConfigs nil or error |
| 381 | func (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 |
| 386 | func (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 |
| 391 | func (oo *OpenONUAC) Suppress_event(filter *voltha.EventFilter) error { |
| 392 | return errors.New("unImplemented") |
| 393 | } |
| 394 | |
| 395 | //Unsuppress_event unimplemented |
| 396 | func (oo *OpenONUAC) Unsuppress_event(filter *voltha.EventFilter) error { |
| 397 | return errors.New("unImplemented") |
| 398 | } |
| 399 | |
| 400 | //Download_image unimplemented |
| 401 | func (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 |
| 406 | func (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 |
| 411 | func (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 |
| 416 | func (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 |
| 421 | func (oo *OpenONUAC) Revert_image_update(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) { |
| 422 | return nil, errors.New("unImplemented") |
| 423 | } |
| 424 | |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 425 | // Enable_port to Enable PON/NNI interface - seems not to be used/required according to python code |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 426 | func (oo *OpenONUAC) Enable_port(deviceID string, port *voltha.Port) error { |
| 427 | return errors.New("unImplemented") |
| 428 | } |
| 429 | |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 430 | // Disable_port to Disable pon/nni interface - seems not to be used/required according to python code |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 431 | func (oo *OpenONUAC) Disable_port(deviceID string, port *voltha.Port) error { |
| 432 | return errors.New("unImplemented") |
| 433 | } |
| 434 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 435 | //Child_device_lost - unimplemented |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 436 | //needed for if update >= 3.1.x |
Matteo Scandolo | 2e6f1e3 | 2020-04-15 11:28:45 -0700 | [diff] [blame] | 437 | func (oo *OpenONUAC) Child_device_lost(deviceID string, pPortNo uint32, onuID uint32) error { |
| 438 | return errors.New("unImplemented") |
| 439 | } |
| 440 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 441 | // Start_omci_test unimplemented |
Matteo Scandolo | 2e6f1e3 | 2020-04-15 11:28:45 -0700 | [diff] [blame] | 442 | func (oo *OpenONUAC) Start_omci_test(device *voltha.Device, request *voltha.OmciTestRequest) (*voltha.TestResponse, error) { |
| 443 | return nil, errors.New("unImplemented") |
| 444 | } |
| 445 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 446 | // Get_ext_value - unimplemented |
Matteo Scandolo | d132c0e | 2020-04-24 17:06:25 -0700 | [diff] [blame] | 447 | func (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 Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 451 | // Adapter interface required methods ################ end ######### |
| 452 | // ################################################################# |