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 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 27 | conf "github.com/opencord/voltha-lib-go/v4/pkg/config" |
| 28 | |
Holger Hildebrandt | 6c1fb0a | 2020-11-25 15:41:01 +0000 | [diff] [blame] | 29 | "github.com/golang/protobuf/ptypes" |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 30 | "github.com/opencord/voltha-lib-go/v4/pkg/adapters/adapterif" |
| 31 | "github.com/opencord/voltha-lib-go/v4/pkg/db/kvstore" |
Himani Chawla | c07fda0 | 2020-12-09 16:21:21 +0530 | [diff] [blame] | 32 | "github.com/opencord/voltha-lib-go/v4/pkg/events/eventif" |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 33 | "github.com/opencord/voltha-lib-go/v4/pkg/kafka" |
| 34 | "github.com/opencord/voltha-lib-go/v4/pkg/log" |
mpagenko | c8bba41 | 2021-01-15 15:38:44 +0000 | [diff] [blame] | 35 | "github.com/opencord/voltha-protos/v4/go/extension" |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 36 | ic "github.com/opencord/voltha-protos/v4/go/inter_container" |
| 37 | "github.com/opencord/voltha-protos/v4/go/openflow_13" |
| 38 | oop "github.com/opencord/voltha-protos/v4/go/openolt" |
| 39 | "github.com/opencord/voltha-protos/v4/go/voltha" |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 40 | |
Matteo Scandolo | 761f751 | 2020-11-23 15:52:40 -0800 | [diff] [blame] | 41 | "github.com/opencord/voltha-openonu-adapter-go/internal/pkg/config" |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 42 | ) |
| 43 | |
| 44 | //OpenONUAC structure holds the ONU core information |
| 45 | type OpenONUAC struct { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 46 | deviceHandlers map[string]*deviceHandler |
Holger Hildebrandt | f07b44a | 2020-11-10 13:07:54 +0000 | [diff] [blame] | 47 | deviceHandlersCreateChan map[string]chan bool //channels for deviceHandler create events |
Holger Hildebrandt | 61b24d0 | 2020-11-16 13:36:40 +0000 | [diff] [blame] | 48 | lockDeviceHandlersMap sync.RWMutex |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 49 | coreProxy adapterif.CoreProxy |
| 50 | adapterProxy adapterif.AdapterProxy |
Himani Chawla | c07fda0 | 2020-12-09 16:21:21 +0530 | [diff] [blame] | 51 | eventProxy eventif.EventProxy |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 52 | kafkaICProxy kafka.InterContainerProxy |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 53 | kvClient kvstore.Client |
Matteo Scandolo | f1f39a7 | 2020-11-24 12:08:11 -0800 | [diff] [blame] | 54 | cm *conf.ConfigManager |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 55 | config *config.AdapterFlags |
| 56 | numOnus int |
| 57 | KVStoreHost string |
| 58 | KVStorePort int |
| 59 | KVStoreType string |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 60 | KVStoreTimeout time.Duration |
Holger Hildebrandt | 61b24d0 | 2020-11-16 13:36:40 +0000 | [diff] [blame] | 61 | mibTemplatesGenerated map[string]bool |
| 62 | lockMibTemplateGenerated sync.RWMutex |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 63 | exitChannel chan int |
| 64 | HeartbeatCheckInterval time.Duration |
| 65 | HeartbeatFailReportInterval time.Duration |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 66 | AcceptIncrementalEvto bool |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 67 | //GrpcTimeoutInterval time.Duration |
Himani Chawla | d96df18 | 2020-09-28 11:12:02 +0530 | [diff] [blame] | 68 | pSupportedFsms *OmciDeviceFsms |
| 69 | maxTimeoutInterAdapterComm time.Duration |
mpagenko | c8bba41 | 2021-01-15 15:38:44 +0000 | [diff] [blame] | 70 | pDownloadManager *adapterDownloadManager |
Girish Gowdra | af0ad63 | 2021-01-27 13:00:01 -0800 | [diff] [blame] | 71 | metricsEnabled bool |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 72 | } |
| 73 | |
| 74 | //NewOpenONUAC returns a new instance of OpenONU_AC |
| 75 | func NewOpenONUAC(ctx context.Context, kafkaICProxy kafka.InterContainerProxy, |
| 76 | coreProxy adapterif.CoreProxy, adapterProxy adapterif.AdapterProxy, |
Himani Chawla | c07fda0 | 2020-12-09 16:21:21 +0530 | [diff] [blame] | 77 | eventProxy eventif.EventProxy, kvClient kvstore.Client, cfg *config.AdapterFlags, cm *conf.ConfigManager) *OpenONUAC { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 78 | var openOnuAc OpenONUAC |
| 79 | openOnuAc.exitChannel = make(chan int, 1) |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 80 | openOnuAc.deviceHandlers = make(map[string]*deviceHandler) |
Holger Hildebrandt | f07b44a | 2020-11-10 13:07:54 +0000 | [diff] [blame] | 81 | openOnuAc.deviceHandlersCreateChan = make(map[string]chan bool) |
Holger Hildebrandt | 61b24d0 | 2020-11-16 13:36:40 +0000 | [diff] [blame] | 82 | openOnuAc.lockDeviceHandlersMap = sync.RWMutex{} |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 83 | openOnuAc.kafkaICProxy = kafkaICProxy |
| 84 | openOnuAc.config = cfg |
Matteo Scandolo | f1f39a7 | 2020-11-24 12:08:11 -0800 | [diff] [blame] | 85 | openOnuAc.cm = cm |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 86 | openOnuAc.numOnus = cfg.OnuNumber |
| 87 | openOnuAc.coreProxy = coreProxy |
| 88 | openOnuAc.adapterProxy = adapterProxy |
| 89 | openOnuAc.eventProxy = eventProxy |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 90 | openOnuAc.kvClient = kvClient |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 91 | openOnuAc.KVStoreHost = cfg.KVStoreHost |
| 92 | openOnuAc.KVStorePort = cfg.KVStorePort |
| 93 | openOnuAc.KVStoreType = cfg.KVStoreType |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 94 | openOnuAc.KVStoreTimeout = cfg.KVStoreTimeout |
Holger Hildebrandt | 61b24d0 | 2020-11-16 13:36:40 +0000 | [diff] [blame] | 95 | openOnuAc.mibTemplatesGenerated = make(map[string]bool) |
| 96 | openOnuAc.lockMibTemplateGenerated = sync.RWMutex{} |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 97 | openOnuAc.HeartbeatCheckInterval = cfg.HeartbeatCheckInterval |
| 98 | openOnuAc.HeartbeatFailReportInterval = cfg.HeartbeatFailReportInterval |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 99 | openOnuAc.AcceptIncrementalEvto = cfg.AccIncrEvto |
Himani Chawla | d96df18 | 2020-09-28 11:12:02 +0530 | [diff] [blame] | 100 | openOnuAc.maxTimeoutInterAdapterComm = cfg.MaxTimeoutInterAdapterComm |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 101 | //openOnuAc.GrpcTimeoutInterval = cfg.GrpcTimeoutInterval |
Girish Gowdra | af0ad63 | 2021-01-27 13:00:01 -0800 | [diff] [blame] | 102 | openOnuAc.metricsEnabled = cfg.MetricsEnabled |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 103 | |
| 104 | openOnuAc.pSupportedFsms = &OmciDeviceFsms{ |
| 105 | "mib-synchronizer": { |
| 106 | //mibSyncFsm, // Implements the MIB synchronization state machine |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 107 | mibDbVolatileDictImpl, // Implements volatile ME MIB database |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 108 | //true, // Advertise events on OpenOMCI event bus |
| 109 | cMibAuditDelayImpl, // Time to wait between MIB audits. 0 to disable audits. |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 110 | // map[string]func() error{ |
| 111 | // "mib-upload": onuDeviceEntry.MibUploadTask, |
| 112 | // "mib-template": onuDeviceEntry.MibTemplateTask, |
| 113 | // "get-mds": onuDeviceEntry.GetMdsTask, |
| 114 | // "mib-audit": onuDeviceEntry.GetMdsTask, |
| 115 | // "mib-resync": onuDeviceEntry.MibResyncTask, |
| 116 | // "mib-reconcile": onuDeviceEntry.MibReconcileTask, |
| 117 | // }, |
| 118 | }, |
| 119 | } |
| 120 | |
mpagenko | c8bba41 | 2021-01-15 15:38:44 +0000 | [diff] [blame] | 121 | openOnuAc.pDownloadManager = newAdapterDownloadManager(ctx) |
| 122 | |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 123 | return &openOnuAc |
| 124 | } |
| 125 | |
| 126 | //Start starts (logs) the adapter |
| 127 | func (oo *OpenONUAC) Start(ctx context.Context) error { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 128 | logger.Info(ctx, "starting-openonu-adapter") |
mpagenko | c8bba41 | 2021-01-15 15:38:44 +0000 | [diff] [blame] | 129 | |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 130 | return nil |
| 131 | } |
| 132 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 133 | /* |
| 134 | //stop terminates the session |
| 135 | func (oo *OpenONUAC) stop(ctx context.Context) error { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 136 | logger.Info(ctx,"stopping-device-manager") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 137 | oo.exitChannel <- 1 |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 138 | logger.Info(ctx,"device-manager-stopped") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 139 | return nil |
| 140 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 141 | */ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 142 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 143 | func (oo *OpenONUAC) addDeviceHandlerToMap(ctx context.Context, agent *deviceHandler) { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 144 | oo.lockDeviceHandlersMap.Lock() |
| 145 | defer oo.lockDeviceHandlersMap.Unlock() |
| 146 | if _, exist := oo.deviceHandlers[agent.deviceID]; !exist { |
| 147 | oo.deviceHandlers[agent.deviceID] = agent |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 148 | oo.deviceHandlers[agent.deviceID].start(ctx) |
Holger Hildebrandt | f07b44a | 2020-11-10 13:07:54 +0000 | [diff] [blame] | 149 | if _, exist := oo.deviceHandlersCreateChan[agent.deviceID]; exist { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 150 | logger.Debugw(ctx, "deviceHandler created - trigger processing of pending ONU_IND_REQUEST", log.Fields{"device-id": agent.deviceID}) |
Holger Hildebrandt | f07b44a | 2020-11-10 13:07:54 +0000 | [diff] [blame] | 151 | oo.deviceHandlersCreateChan[agent.deviceID] <- true |
| 152 | } |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 153 | } |
| 154 | } |
| 155 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 156 | func (oo *OpenONUAC) deleteDeviceHandlerToMap(agent *deviceHandler) { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 157 | oo.lockDeviceHandlersMap.Lock() |
| 158 | defer oo.lockDeviceHandlersMap.Unlock() |
| 159 | delete(oo.deviceHandlers, agent.deviceID) |
Holger Hildebrandt | f07b44a | 2020-11-10 13:07:54 +0000 | [diff] [blame] | 160 | delete(oo.deviceHandlersCreateChan, agent.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 161 | } |
| 162 | |
Holger Hildebrandt | f07b44a | 2020-11-10 13:07:54 +0000 | [diff] [blame] | 163 | //getDeviceHandler gets the ONU deviceHandler and may wait until it is created |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 164 | func (oo *OpenONUAC) getDeviceHandler(ctx context.Context, deviceID string, aWait bool) *deviceHandler { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 165 | oo.lockDeviceHandlersMap.Lock() |
Holger Hildebrandt | f07b44a | 2020-11-10 13:07:54 +0000 | [diff] [blame] | 166 | agent, ok := oo.deviceHandlers[deviceID] |
| 167 | if aWait && !ok { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 168 | logger.Infow(ctx, "Race condition: deviceHandler not present - wait for creation or timeout", |
Holger Hildebrandt | 6c1fb0a | 2020-11-25 15:41:01 +0000 | [diff] [blame] | 169 | log.Fields{"device-id": deviceID}) |
Holger Hildebrandt | f07b44a | 2020-11-10 13:07:54 +0000 | [diff] [blame] | 170 | if _, exist := oo.deviceHandlersCreateChan[deviceID]; !exist { |
| 171 | oo.deviceHandlersCreateChan[deviceID] = make(chan bool, 1) |
| 172 | } |
Girish Gowdra | 7407a4d | 2020-11-12 12:44:53 -0800 | [diff] [blame] | 173 | deviceCreateChan := oo.deviceHandlersCreateChan[deviceID] |
Holger Hildebrandt | f07b44a | 2020-11-10 13:07:54 +0000 | [diff] [blame] | 174 | //keep the read sema short to allow for subsequent write |
| 175 | oo.lockDeviceHandlersMap.Unlock() |
| 176 | // based on concurrent processing the deviceHandler creation may not yet be finished at his point |
| 177 | // so it might be needed to wait here for that event with some timeout |
| 178 | select { |
| 179 | case <-time.After(1 * time.Second): //timer may be discussed ... |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 180 | logger.Warnw(ctx, "No valid deviceHandler created after max WaitTime", log.Fields{"device-id": deviceID}) |
Holger Hildebrandt | f07b44a | 2020-11-10 13:07:54 +0000 | [diff] [blame] | 181 | return nil |
Girish Gowdra | 7407a4d | 2020-11-12 12:44:53 -0800 | [diff] [blame] | 182 | case <-deviceCreateChan: |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 183 | logger.Debugw(ctx, "deviceHandler is ready now - continue", log.Fields{"device-id": deviceID}) |
Girish Gowdra | 7407a4d | 2020-11-12 12:44:53 -0800 | [diff] [blame] | 184 | oo.lockDeviceHandlersMap.RLock() |
| 185 | defer oo.lockDeviceHandlersMap.RUnlock() |
Holger Hildebrandt | f07b44a | 2020-11-10 13:07:54 +0000 | [diff] [blame] | 186 | return oo.deviceHandlers[deviceID] |
| 187 | } |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 188 | } |
Holger Hildebrandt | f07b44a | 2020-11-10 13:07:54 +0000 | [diff] [blame] | 189 | oo.lockDeviceHandlersMap.Unlock() |
| 190 | return agent |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 191 | } |
| 192 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 193 | func (oo *OpenONUAC) processInterAdapterONUIndReqMessage(ctx context.Context, msg *ic.InterAdapterMessage) error { |
Holger Hildebrandt | 6c1fb0a | 2020-11-25 15:41:01 +0000 | [diff] [blame] | 194 | msgBody := msg.GetBody() |
| 195 | onuIndication := &oop.OnuIndication{} |
| 196 | if err := ptypes.UnmarshalAny(msgBody, onuIndication); err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 197 | logger.Warnw(ctx, "onu-ind-request-cannot-unmarshal-msg-body", log.Fields{"error": err}) |
Holger Hildebrandt | 6c1fb0a | 2020-11-25 15:41:01 +0000 | [diff] [blame] | 198 | return err |
| 199 | } |
| 200 | //ToDeviceId should address a DeviceHandler instance |
| 201 | targetDevice := msg.Header.ToDeviceId |
| 202 | |
| 203 | onuOperstate := onuIndication.GetOperState() |
| 204 | waitForDhInstPresent := false |
| 205 | if onuOperstate == "up" { |
| 206 | //Race condition (relevant in BBSIM-environment only): Due to unsynchronized processing of olt-adapter and rw_core, |
| 207 | //ONU_IND_REQUEST msg by olt-adapter could arrive a little bit earlier than rw_core was able to announce the corresponding |
| 208 | //ONU by RPC of Adopt_device(). Therefore it could be necessary to wait with processing of ONU_IND_REQUEST until call of |
| 209 | //Adopt_device() arrived and DeviceHandler instance was created |
| 210 | waitForDhInstPresent = true |
| 211 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 212 | if handler := oo.getDeviceHandler(ctx, targetDevice, waitForDhInstPresent); handler != nil { |
| 213 | logger.Infow(ctx, "onu-ind-request", log.Fields{"device-id": targetDevice, |
Holger Hildebrandt | 6c1fb0a | 2020-11-25 15:41:01 +0000 | [diff] [blame] | 214 | "OnuId": onuIndication.GetOnuId(), |
| 215 | "AdminState": onuIndication.GetAdminState(), "OperState": onuOperstate, |
| 216 | "SNR": onuIndication.GetSerialNumber()}) |
| 217 | |
| 218 | if onuOperstate == "up" { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 219 | return handler.createInterface(ctx, onuIndication) |
Holger Hildebrandt | 6c1fb0a | 2020-11-25 15:41:01 +0000 | [diff] [blame] | 220 | } else if (onuOperstate == "down") || (onuOperstate == "unreachable") { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 221 | return handler.updateInterface(ctx, onuIndication) |
Holger Hildebrandt | 6c1fb0a | 2020-11-25 15:41:01 +0000 | [diff] [blame] | 222 | } else { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 223 | logger.Errorw(ctx, "unknown-onu-ind-request operState", log.Fields{"OnuId": onuIndication.GetOnuId()}) |
Holger Hildebrandt | 6c1fb0a | 2020-11-25 15:41:01 +0000 | [diff] [blame] | 224 | return fmt.Errorf("invalidOperState: %s, %s", onuOperstate, targetDevice) |
| 225 | } |
| 226 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 227 | logger.Warnw(ctx, "no handler found for received onu-ind-request", log.Fields{ |
Holger Hildebrandt | 6c1fb0a | 2020-11-25 15:41:01 +0000 | [diff] [blame] | 228 | "msgToDeviceId": targetDevice}) |
| 229 | return fmt.Errorf(fmt.Sprintf("handler-not-found-%s", targetDevice)) |
| 230 | } |
| 231 | |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 232 | // Adapter interface required methods ############## begin ######### |
| 233 | // ################################################################# |
| 234 | |
| 235 | // for original content compare: (needs according deviceHandler methods) |
| 236 | // /voltha-openolt-adapter/adaptercore/openolt.go |
| 237 | |
| 238 | // Adopt_device creates a new device handler if not present already and then adopts the device |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 239 | func (oo *OpenONUAC) Adopt_device(ctx context.Context, device *voltha.Device) error { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 240 | if device == nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 241 | logger.Warn(ctx, "voltha-device-is-nil") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 242 | return errors.New("nil-device") |
| 243 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 244 | logger.Infow(ctx, "adopt-device", log.Fields{"device-id": device.Id}) |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 245 | var handler *deviceHandler |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 246 | if handler = oo.getDeviceHandler(ctx, device.Id, false); handler == nil { |
| 247 | handler := newDeviceHandler(ctx, oo.coreProxy, oo.adapterProxy, oo.eventProxy, device, oo) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 248 | oo.addDeviceHandlerToMap(ctx, handler) |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 249 | go handler.adoptOrReconcileDevice(ctx, device) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 250 | // Launch the creation of the device topic |
| 251 | // go oo.createDeviceTopic(device) |
| 252 | } |
| 253 | return nil |
| 254 | } |
| 255 | |
| 256 | //Get_ofp_device_info returns OFP information for the given device |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 257 | func (oo *OpenONUAC) Get_ofp_device_info(ctx context.Context, device *voltha.Device) (*ic.SwitchCapability, error) { |
| 258 | logger.Errorw(ctx, "device-handler-not-set", log.Fields{"device-id": device.Id}) |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 259 | return nil, fmt.Errorf("device-handler-not-set %s", device.Id) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 260 | } |
| 261 | |
| 262 | //Get_ofp_port_info returns OFP port information for the given device |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 263 | //200630: method removed as per [VOL-3202]: OF port info is now to be delivered within UniPort create |
| 264 | // cmp changes in onu_uni_port.go::CreateVolthaPort() |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 265 | |
| 266 | //Process_inter_adapter_message sends messages to a target device (between adapters) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 267 | func (oo *OpenONUAC) Process_inter_adapter_message(ctx context.Context, msg *ic.InterAdapterMessage) error { |
| 268 | logger.Debugw(ctx, "Process_inter_adapter_message", log.Fields{"msgId": msg.Header.Id, |
Holger Hildebrandt | 80129db | 2020-11-23 10:49:32 +0000 | [diff] [blame] | 269 | "msgProxyDeviceId": msg.Header.ProxyDeviceId, "msgToDeviceId": msg.Header.ToDeviceId, "Type": msg.Header.Type}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 270 | |
Holger Hildebrandt | 6c1fb0a | 2020-11-25 15:41:01 +0000 | [diff] [blame] | 271 | if msg.Header.Type == ic.InterAdapterMessageType_ONU_IND_REQUEST { |
| 272 | // we have to handle ONU_IND_REQUEST already here - see comments in processInterAdapterONUIndReqMessage() |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 273 | return oo.processInterAdapterONUIndReqMessage(ctx, msg) |
Holger Hildebrandt | 6c1fb0a | 2020-11-25 15:41:01 +0000 | [diff] [blame] | 274 | } |
Holger Hildebrandt | f07b44a | 2020-11-10 13:07:54 +0000 | [diff] [blame] | 275 | //ToDeviceId should address a DeviceHandler instance |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 276 | targetDevice := msg.Header.ToDeviceId |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 277 | if handler := oo.getDeviceHandler(ctx, targetDevice, false); handler != nil { |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 278 | /* 200724: modification towards synchronous implementation - possible errors within processing shall be |
| 279 | * in the accordingly delayed response, some timing effect might result in Techprofile processing for multiple UNI's |
| 280 | */ |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 281 | return handler.processInterAdapterMessage(ctx, msg) |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 282 | /* 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] | 283 | go handler.ProcessInterAdapterMessage(msg) |
| 284 | // error treatment might be more sophisticated |
| 285 | // by now let's just accept the message on 'communication layer' |
| 286 | // message content problems have to be evaluated then in the handler |
| 287 | // and are by now not reported to the calling party (to force what reaction there?) |
| 288 | return nil |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 289 | */ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 290 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 291 | logger.Warnw(ctx, "no handler found for received Inter-Proxy-message", log.Fields{ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 292 | "msgToDeviceId": targetDevice}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 293 | return fmt.Errorf(fmt.Sprintf("handler-not-found-%s", targetDevice)) |
| 294 | } |
| 295 | |
| 296 | //Adapter_descriptor not implemented |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 297 | func (oo *OpenONUAC) Adapter_descriptor(ctx context.Context) error { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 298 | return errors.New("unImplemented") |
| 299 | } |
| 300 | |
| 301 | //Device_types unimplemented |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 302 | func (oo *OpenONUAC) Device_types(ctx context.Context) (*voltha.DeviceTypes, error) { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 303 | return nil, errors.New("unImplemented") |
| 304 | } |
| 305 | |
| 306 | //Health returns unimplemented |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 307 | func (oo *OpenONUAC) Health(ctx context.Context) (*voltha.HealthStatus, error) { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 308 | return nil, errors.New("unImplemented") |
| 309 | } |
| 310 | |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 311 | //Reconcile_device is called once when the adapter needs to re-create device - usually on core restart |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 312 | func (oo *OpenONUAC) Reconcile_device(ctx context.Context, device *voltha.Device) error { |
Holger Hildebrandt | f41a160 | 2020-08-19 09:52:50 +0000 | [diff] [blame] | 313 | if device == nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 314 | logger.Warn(ctx, "reconcile-device-voltha-device-is-nil") |
Holger Hildebrandt | f41a160 | 2020-08-19 09:52:50 +0000 | [diff] [blame] | 315 | return errors.New("nil-device") |
| 316 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 317 | logger.Infow(ctx, "reconcile-device", log.Fields{"device-id": device.Id}) |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 318 | var handler *deviceHandler |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 319 | if handler = oo.getDeviceHandler(ctx, device.Id, false); handler == nil { |
| 320 | handler := newDeviceHandler(ctx, oo.coreProxy, oo.adapterProxy, oo.eventProxy, device, oo) |
Holger Hildebrandt | f41a160 | 2020-08-19 09:52:50 +0000 | [diff] [blame] | 321 | oo.addDeviceHandlerToMap(ctx, handler) |
| 322 | handler.device = device |
| 323 | handler.reconciling = true |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 324 | go handler.adoptOrReconcileDevice(ctx, handler.device) |
Holger Hildebrandt | f41a160 | 2020-08-19 09:52:50 +0000 | [diff] [blame] | 325 | // reconcilement will be continued after onu-device entry is added |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 326 | } else { |
Holger Hildebrandt | f41a160 | 2020-08-19 09:52:50 +0000 | [diff] [blame] | 327 | 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] | 328 | } |
| 329 | return nil |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 330 | } |
| 331 | |
| 332 | //Abandon_device unimplemented |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 333 | func (oo *OpenONUAC) Abandon_device(ctx context.Context, device *voltha.Device) error { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 334 | return errors.New("unImplemented") |
| 335 | } |
| 336 | |
| 337 | //Disable_device disables the given device |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 338 | func (oo *OpenONUAC) Disable_device(ctx context.Context, device *voltha.Device) error { |
| 339 | logger.Infow(ctx, "disable-device", log.Fields{"device-id": device.Id}) |
| 340 | if handler := oo.getDeviceHandler(ctx, device.Id, false); handler != nil { |
| 341 | go handler.disableDevice(ctx, device) |
ozgecanetsia | fce57b1 | 2020-05-25 14:39:35 +0300 | [diff] [blame] | 342 | return nil |
| 343 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 344 | logger.Warnw(ctx, "no handler found for device-disable", log.Fields{"device-id": device.Id}) |
ozgecanetsia | fce57b1 | 2020-05-25 14:39:35 +0300 | [diff] [blame] | 345 | return fmt.Errorf(fmt.Sprintf("handler-not-found-%s", device.Id)) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 346 | } |
| 347 | |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 348 | //Reenable_device enables the onu device after disable |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 349 | func (oo *OpenONUAC) Reenable_device(ctx context.Context, device *voltha.Device) error { |
| 350 | logger.Infow(ctx, "reenable-device", log.Fields{"device-id": device.Id}) |
| 351 | if handler := oo.getDeviceHandler(ctx, device.Id, false); handler != nil { |
| 352 | go handler.reEnableDevice(ctx, device) |
ozgecanetsia | fce57b1 | 2020-05-25 14:39:35 +0300 | [diff] [blame] | 353 | return nil |
| 354 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 355 | logger.Warnw(ctx, "no handler found for device-reenable", log.Fields{"device-id": device.Id}) |
ozgecanetsia | fce57b1 | 2020-05-25 14:39:35 +0300 | [diff] [blame] | 356 | return fmt.Errorf(fmt.Sprintf("handler-not-found-%s", device.Id)) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 357 | } |
| 358 | |
| 359 | //Reboot_device reboots the given device |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 360 | func (oo *OpenONUAC) Reboot_device(ctx context.Context, device *voltha.Device) error { |
| 361 | logger.Infow(ctx, "reboot-device", log.Fields{"device-id": device.Id}) |
| 362 | if handler := oo.getDeviceHandler(ctx, device.Id, false); handler != nil { |
| 363 | go handler.rebootDevice(ctx, device) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 364 | return nil |
| 365 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 366 | logger.Warnw(ctx, "no handler found for device-reboot", log.Fields{"device-id": device.Id}) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 367 | return fmt.Errorf(fmt.Sprintf("handler-not-found-#{device.Id}")) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 368 | } |
| 369 | |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 370 | //Self_test_device unimplemented |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 371 | func (oo *OpenONUAC) Self_test_device(ctx context.Context, device *voltha.Device) error { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 372 | return errors.New("unImplemented") |
| 373 | } |
| 374 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 375 | // Delete_device deletes the given device |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 376 | func (oo *OpenONUAC) Delete_device(ctx context.Context, device *voltha.Device) error { |
| 377 | logger.Infow(ctx, "delete-device", log.Fields{"device-id": device.Id, "SerialNumber": device.SerialNumber}) |
| 378 | if handler := oo.getDeviceHandler(ctx, device.Id, false); handler != nil { |
| 379 | err := handler.deleteDevicePersistencyData(ctx) |
Holger Hildebrandt | f07b44a | 2020-11-10 13:07:54 +0000 | [diff] [blame] | 380 | //don't leave any garbage - even in error case |
| 381 | oo.deleteDeviceHandlerToMap(handler) |
mpagenko | 2418ab0 | 2020-11-12 12:58:06 +0000 | [diff] [blame] | 382 | return err |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 383 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 384 | logger.Warnw(ctx, "no handler found for device-deletion", log.Fields{"device-id": device.Id}) |
mpagenko | 2418ab0 | 2020-11-12 12:58:06 +0000 | [diff] [blame] | 385 | return fmt.Errorf(fmt.Sprintf("handler-not-found-%s", device.Id)) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 386 | } |
| 387 | |
| 388 | //Get_device_details unimplemented |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 389 | func (oo *OpenONUAC) Get_device_details(ctx context.Context, device *voltha.Device) error { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 390 | return errors.New("unImplemented") |
| 391 | } |
| 392 | |
| 393 | //Update_flows_bulk returns |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 394 | func (oo *OpenONUAC) Update_flows_bulk(ctx context.Context, device *voltha.Device, flows *voltha.Flows, groups *voltha.FlowGroups, flowMetadata *voltha.FlowMetadata) error { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 395 | return errors.New("unImplemented") |
| 396 | } |
| 397 | |
| 398 | //Update_flows_incrementally updates (add/remove) the flows on a given device |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 399 | func (oo *OpenONUAC) Update_flows_incrementally(ctx context.Context, device *voltha.Device, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 400 | flows *openflow_13.FlowChanges, groups *openflow_13.FlowGroupChanges, flowMetadata *voltha.FlowMetadata) error { |
mpagenko | fc4f56e | 2020-11-04 17:17:49 +0000 | [diff] [blame] | 401 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 402 | logger.Infow(ctx, "update-flows-incrementally", log.Fields{"device-id": device.Id}) |
mpagenko | fc4f56e | 2020-11-04 17:17:49 +0000 | [diff] [blame] | 403 | //flow config is relayed to handler even if the device might be in some 'inactive' state |
| 404 | // let the handler or related FSM's decide, what to do with the modified flow state info |
| 405 | // 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] | 406 | |
| 407 | // 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] | 408 | // but processing is continued for flowUpdate possibly also set in the request |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 409 | if groups.ToAdd != nil && groups.ToAdd.Items != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 410 | logger.Warnw(ctx, "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] | 411 | } |
| 412 | if groups.ToRemove != nil && groups.ToRemove.Items != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 413 | logger.Warnw(ctx, "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] | 414 | } |
| 415 | if groups.ToUpdate != nil && groups.ToUpdate.Items != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 416 | logger.Warnw(ctx, "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] | 417 | } |
| 418 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 419 | if handler := oo.getDeviceHandler(ctx, device.Id, false); handler != nil { |
| 420 | err := handler.FlowUpdateIncremental(ctx, flows, groups, flowMetadata) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 421 | return err |
| 422 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 423 | logger.Warnw(ctx, "no handler found for incremental flow update", log.Fields{"device-id": device.Id}) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 424 | return fmt.Errorf(fmt.Sprintf("handler-not-found-%s", device.Id)) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 425 | } |
| 426 | |
| 427 | //Update_pm_config returns PmConfigs nil or error |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 428 | func (oo *OpenONUAC) Update_pm_config(ctx context.Context, device *voltha.Device, pmConfigs *voltha.PmConfigs) error { |
Girish Gowdra | e09a620 | 2021-01-12 18:10:59 -0800 | [diff] [blame] | 429 | logger.Infow(ctx, "update-pm-config", log.Fields{"device-id": device.Id}) |
| 430 | if handler := oo.getDeviceHandler(ctx, device.Id, false); handler != nil { |
Girish Gowdra | 5a7c492 | 2021-01-22 18:33:41 -0800 | [diff] [blame] | 431 | return handler.updatePmConfig(ctx, pmConfigs) |
Girish Gowdra | e09a620 | 2021-01-12 18:10:59 -0800 | [diff] [blame] | 432 | } |
Girish Gowdra | 5a7c492 | 2021-01-22 18:33:41 -0800 | [diff] [blame] | 433 | logger.Warnw(ctx, "no handler found for update-pm-config", log.Fields{"device-id": device.Id}) |
| 434 | return fmt.Errorf(fmt.Sprintf("handler-not-found-%s", device.Id)) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 435 | } |
| 436 | |
| 437 | //Receive_packet_out sends packet out to the device |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 438 | func (oo *OpenONUAC) Receive_packet_out(ctx context.Context, deviceID string, egressPortNo int, packet *openflow_13.OfpPacketOut) error { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 439 | return errors.New("unImplemented") |
| 440 | } |
| 441 | |
| 442 | //Suppress_event unimplemented |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 443 | func (oo *OpenONUAC) Suppress_event(ctx context.Context, filter *voltha.EventFilter) error { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 444 | return errors.New("unImplemented") |
| 445 | } |
| 446 | |
| 447 | //Unsuppress_event unimplemented |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 448 | func (oo *OpenONUAC) Unsuppress_event(ctx context.Context, filter *voltha.EventFilter) error { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 449 | return errors.New("unImplemented") |
| 450 | } |
| 451 | |
mpagenko | 057889c | 2021-01-21 16:51:58 +0000 | [diff] [blame] | 452 | //Download_image requests downloading some image according to indications as given in apRequest |
mpagenko | c8bba41 | 2021-01-15 15:38:44 +0000 | [diff] [blame] | 453 | func (oo *OpenONUAC) Download_image(ctx context.Context, device *voltha.Device, apRequest *voltha.ImageDownload) (*voltha.ImageDownload, error) { |
| 454 | if !oo.pDownloadManager.imageExists(ctx, apRequest) { |
| 455 | logger.Debugw(ctx, "start image download", log.Fields{"image-description": apRequest}) |
| 456 | // Download_image is not supposed to be blocking, anyway let's call the DownloadManager still synchronously to detect 'fast' problems |
| 457 | // the download itself is later done in background |
| 458 | err := oo.pDownloadManager.startDownload(ctx, apRequest) |
| 459 | return apRequest, err |
| 460 | } |
| 461 | // image already exists |
mpagenko | 057889c | 2021-01-21 16:51:58 +0000 | [diff] [blame] | 462 | logger.Debugw(ctx, "image already downloaded", log.Fields{"image-description": apRequest}) |
mpagenko | c8bba41 | 2021-01-15 15:38:44 +0000 | [diff] [blame] | 463 | return apRequest, nil |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 464 | } |
| 465 | |
| 466 | //Get_image_download_status unimplemented |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 467 | func (oo *OpenONUAC) Get_image_download_status(ctx context.Context, device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 468 | return nil, errors.New("unImplemented") |
| 469 | } |
| 470 | |
| 471 | //Cancel_image_download unimplemented |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 472 | func (oo *OpenONUAC) Cancel_image_download(ctx context.Context, device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 473 | return nil, errors.New("unImplemented") |
| 474 | } |
| 475 | |
mpagenko | 057889c | 2021-01-21 16:51:58 +0000 | [diff] [blame] | 476 | //Activate_image_update requests downloading some Onu Software image to the INU via OMCI |
| 477 | // according to indications as given in apRequest and on success activate the image on the ONU |
mpagenko | c8bba41 | 2021-01-15 15:38:44 +0000 | [diff] [blame] | 478 | func (oo *OpenONUAC) Activate_image_update(ctx context.Context, device *voltha.Device, apRequest *voltha.ImageDownload) (*voltha.ImageDownload, error) { |
mpagenko | 057889c | 2021-01-21 16:51:58 +0000 | [diff] [blame] | 479 | if oo.pDownloadManager.imageExists(ctx, apRequest) { |
| 480 | if handler := oo.getDeviceHandler(ctx, device.Id, false); handler != nil { |
| 481 | logger.Debugw(ctx, "image download on omci requested", log.Fields{ |
| 482 | "image-description": apRequest, "device-id": device.Id}) |
| 483 | err := handler.doOnuSwUpgrade(ctx, apRequest) |
| 484 | return apRequest, err |
| 485 | } |
| 486 | logger.Warnw(ctx, "no handler found for image activation", log.Fields{"device-id": device.Id}) |
| 487 | return apRequest, fmt.Errorf(fmt.Sprintf("handler-not-found - device-id: %s", device.Id)) |
mpagenko | c8bba41 | 2021-01-15 15:38:44 +0000 | [diff] [blame] | 488 | } |
mpagenko | 057889c | 2021-01-21 16:51:58 +0000 | [diff] [blame] | 489 | logger.Debugw(ctx, "image not yet downloaded on activate request", log.Fields{"image-description": apRequest}) |
| 490 | return apRequest, fmt.Errorf(fmt.Sprintf("image-not-yet-downloaded - device-id: %s", device.Id)) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 491 | } |
| 492 | |
| 493 | //Revert_image_update unimplemented |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 494 | func (oo *OpenONUAC) Revert_image_update(ctx context.Context, device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 495 | return nil, errors.New("unImplemented") |
| 496 | } |
| 497 | |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 498 | // Enable_port to Enable PON/NNI interface - seems not to be used/required according to python code |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 499 | func (oo *OpenONUAC) Enable_port(ctx context.Context, deviceID string, port *voltha.Port) error { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 500 | return errors.New("unImplemented") |
| 501 | } |
| 502 | |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 503 | // Disable_port to Disable pon/nni interface - seems not to be used/required according to python code |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 504 | func (oo *OpenONUAC) Disable_port(ctx context.Context, deviceID string, port *voltha.Port) error { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 505 | return errors.New("unImplemented") |
| 506 | } |
| 507 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 508 | //Child_device_lost - unimplemented |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 509 | //needed for if update >= 3.1.x |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 510 | func (oo *OpenONUAC) Child_device_lost(ctx context.Context, deviceID string, pPortNo uint32, onuID uint32) error { |
Matteo Scandolo | 2e6f1e3 | 2020-04-15 11:28:45 -0700 | [diff] [blame] | 511 | return errors.New("unImplemented") |
| 512 | } |
| 513 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 514 | // Start_omci_test unimplemented |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 515 | func (oo *OpenONUAC) Start_omci_test(ctx context.Context, device *voltha.Device, request *voltha.OmciTestRequest) (*voltha.TestResponse, error) { |
Matteo Scandolo | 2e6f1e3 | 2020-04-15 11:28:45 -0700 | [diff] [blame] | 516 | return nil, errors.New("unImplemented") |
| 517 | } |
| 518 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 519 | // Get_ext_value - unimplemented |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 520 | func (oo *OpenONUAC) Get_ext_value(ctx context.Context, deviceID string, device *voltha.Device, valueparam voltha.ValueType_Type) (*voltha.ReturnValues, error) { |
Matteo Scandolo | d132c0e | 2020-04-24 17:06:25 -0700 | [diff] [blame] | 521 | return nil, errors.New("unImplemented") |
| 522 | } |
| 523 | |
Girish Gowdra | e09a620 | 2021-01-12 18:10:59 -0800 | [diff] [blame] | 524 | // Single_get_value_request - unimplemented |
mpagenko | c8bba41 | 2021-01-15 15:38:44 +0000 | [diff] [blame] | 525 | func (oo *OpenONUAC) Single_get_value_request(ctx context.Context, request extension.SingleGetValueRequest) (*extension.SingleGetValueResponse, error) { |
| 526 | return nil, errors.New("unImplemented") |
| 527 | } |
| 528 | |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 529 | // Adapter interface required methods ################ end ######### |
| 530 | // ################################################################# |