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 { |
| 40 | deviceHandlers map[string]*DeviceHandler |
| 41 | coreProxy adapterif.CoreProxy |
| 42 | adapterProxy adapterif.AdapterProxy |
| 43 | eventProxy adapterif.EventProxy |
| 44 | kafkaICProxy kafka.InterContainerProxy |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 45 | kvClient kvstore.Client |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 46 | config *config.AdapterFlags |
| 47 | numOnus int |
| 48 | KVStoreHost string |
| 49 | KVStorePort int |
| 50 | KVStoreType string |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 51 | KVStoreTimeout time.Duration |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 52 | exitChannel chan int |
| 53 | HeartbeatCheckInterval time.Duration |
| 54 | HeartbeatFailReportInterval time.Duration |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame^] | 55 | AcceptIncrementalEvto bool |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 56 | //GrpcTimeoutInterval time.Duration |
| 57 | lockDeviceHandlersMap sync.RWMutex |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 58 | pSupportedFsms *OmciDeviceFsms |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 59 | } |
| 60 | |
| 61 | //NewOpenONUAC returns a new instance of OpenONU_AC |
| 62 | func NewOpenONUAC(ctx context.Context, kafkaICProxy kafka.InterContainerProxy, |
| 63 | coreProxy adapterif.CoreProxy, adapterProxy adapterif.AdapterProxy, |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 64 | eventProxy adapterif.EventProxy, kvClient kvstore.Client, cfg *config.AdapterFlags) *OpenONUAC { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 65 | var openOnuAc OpenONUAC |
| 66 | openOnuAc.exitChannel = make(chan int, 1) |
| 67 | openOnuAc.deviceHandlers = make(map[string]*DeviceHandler) |
| 68 | openOnuAc.kafkaICProxy = kafkaICProxy |
| 69 | openOnuAc.config = cfg |
| 70 | openOnuAc.numOnus = cfg.OnuNumber |
| 71 | openOnuAc.coreProxy = coreProxy |
| 72 | openOnuAc.adapterProxy = adapterProxy |
| 73 | openOnuAc.eventProxy = eventProxy |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 74 | openOnuAc.kvClient = kvClient |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 75 | openOnuAc.KVStoreHost = cfg.KVStoreHost |
| 76 | openOnuAc.KVStorePort = cfg.KVStorePort |
| 77 | openOnuAc.KVStoreType = cfg.KVStoreType |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 78 | openOnuAc.KVStoreTimeout = cfg.KVStoreTimeout |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 79 | openOnuAc.HeartbeatCheckInterval = cfg.HeartbeatCheckInterval |
| 80 | openOnuAc.HeartbeatFailReportInterval = cfg.HeartbeatFailReportInterval |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame^] | 81 | openOnuAc.AcceptIncrementalEvto = cfg.AccIncrEvto |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 82 | //openOnuAc.GrpcTimeoutInterval = cfg.GrpcTimeoutInterval |
| 83 | openOnuAc.lockDeviceHandlersMap = sync.RWMutex{} |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 84 | |
| 85 | openOnuAc.pSupportedFsms = &OmciDeviceFsms{ |
| 86 | "mib-synchronizer": { |
| 87 | //mibSyncFsm, // Implements the MIB synchronization state machine |
| 88 | MibDbVolatileDictImpl, // Implements volatile ME MIB database |
| 89 | true, // Advertise events on OpenOMCI event bus |
| 90 | cMibAuditDelayImpl, // Time to wait between MIB audits. 0 to disable audits. |
| 91 | // map[string]func() error{ |
| 92 | // "mib-upload": onuDeviceEntry.MibUploadTask, |
| 93 | // "mib-template": onuDeviceEntry.MibTemplateTask, |
| 94 | // "get-mds": onuDeviceEntry.GetMdsTask, |
| 95 | // "mib-audit": onuDeviceEntry.GetMdsTask, |
| 96 | // "mib-resync": onuDeviceEntry.MibResyncTask, |
| 97 | // "mib-reconcile": onuDeviceEntry.MibReconcileTask, |
| 98 | // }, |
| 99 | }, |
| 100 | } |
| 101 | |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 102 | return &openOnuAc |
| 103 | } |
| 104 | |
| 105 | //Start starts (logs) the adapter |
| 106 | func (oo *OpenONUAC) Start(ctx context.Context) error { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 107 | logger.Info("starting-openonu-adapter") |
| 108 | logger.Info("openonu-adapter-started") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 109 | return nil |
| 110 | } |
| 111 | |
| 112 | //Stop terminates the session |
| 113 | func (oo *OpenONUAC) Stop(ctx context.Context) error { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 114 | logger.Info("stopping-device-manager") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 115 | oo.exitChannel <- 1 |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 116 | logger.Info("device-manager-stopped") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 117 | return nil |
| 118 | } |
| 119 | |
| 120 | func (oo *OpenONUAC) addDeviceHandlerToMap(ctx context.Context, agent *DeviceHandler) { |
| 121 | oo.lockDeviceHandlersMap.Lock() |
| 122 | defer oo.lockDeviceHandlersMap.Unlock() |
| 123 | if _, exist := oo.deviceHandlers[agent.deviceID]; !exist { |
| 124 | oo.deviceHandlers[agent.deviceID] = agent |
| 125 | oo.deviceHandlers[agent.deviceID].Start(ctx) |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | func (oo *OpenONUAC) deleteDeviceHandlerToMap(agent *DeviceHandler) { |
| 130 | oo.lockDeviceHandlersMap.Lock() |
| 131 | defer oo.lockDeviceHandlersMap.Unlock() |
| 132 | delete(oo.deviceHandlers, agent.deviceID) |
| 133 | } |
| 134 | |
| 135 | func (oo *OpenONUAC) getDeviceHandler(deviceID string) *DeviceHandler { |
| 136 | oo.lockDeviceHandlersMap.Lock() |
| 137 | defer oo.lockDeviceHandlersMap.Unlock() |
| 138 | if agent, ok := oo.deviceHandlers[deviceID]; ok { |
| 139 | return agent |
| 140 | } |
| 141 | return nil |
| 142 | } |
| 143 | |
| 144 | // Adapter interface required methods ############## begin ######### |
| 145 | // ################################################################# |
| 146 | |
| 147 | // for original content compare: (needs according deviceHandler methods) |
| 148 | // /voltha-openolt-adapter/adaptercore/openolt.go |
| 149 | |
| 150 | // Adopt_device creates a new device handler if not present already and then adopts the device |
| 151 | func (oo *OpenONUAC) Adopt_device(device *voltha.Device) error { |
| 152 | if device == nil { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 153 | logger.Warn("voltha-device-is-nil") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 154 | return errors.New("nil-device") |
| 155 | } |
| 156 | ctx := context.Background() |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 157 | logger.Infow("adopt-device", log.Fields{"device-id": device.Id}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 158 | var handler *DeviceHandler |
| 159 | if handler = oo.getDeviceHandler(device.Id); handler == nil { |
| 160 | handler := NewDeviceHandler(oo.coreProxy, oo.adapterProxy, oo.eventProxy, device, oo) |
| 161 | oo.addDeviceHandlerToMap(ctx, handler) |
Holger Hildebrandt | f41a160 | 2020-08-19 09:52:50 +0000 | [diff] [blame] | 162 | go handler.AdoptOrReconcileDevice(ctx, device) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 163 | // Launch the creation of the device topic |
| 164 | // go oo.createDeviceTopic(device) |
| 165 | } |
| 166 | return nil |
| 167 | } |
| 168 | |
| 169 | //Get_ofp_device_info returns OFP information for the given device |
| 170 | func (oo *OpenONUAC) Get_ofp_device_info(device *voltha.Device) (*ic.SwitchCapability, error) { |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 171 | logger.Errorw("device-handler-not-set", log.Fields{"device-id": device.Id}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 172 | return nil, errors.New("device-handler-not-set") |
| 173 | } |
| 174 | |
| 175 | //Get_ofp_port_info returns OFP port information for the given device |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 176 | //200630: method removed as per [VOL-3202]: OF port info is now to be delivered within UniPort create |
| 177 | // cmp changes in onu_uni_port.go::CreateVolthaPort() |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 178 | |
| 179 | //Process_inter_adapter_message sends messages to a target device (between adapters) |
| 180 | func (oo *OpenONUAC) Process_inter_adapter_message(msg *ic.InterAdapterMessage) error { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 181 | logger.Debugw("Process_inter_adapter_message", log.Fields{"msgId": msg.Header.Id, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 182 | "msgProxyDeviceId": msg.Header.ProxyDeviceId, "msgToDeviceId": msg.Header.ToDeviceId}) |
| 183 | |
| 184 | targetDevice := msg.Header.ToDeviceId |
| 185 | //ToDeviceId should address an DeviceHandler instance |
| 186 | if handler := oo.getDeviceHandler(targetDevice); handler != nil { |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 187 | /* 200724: modification towards synchronous implementation - possible errors within processing shall be |
| 188 | * in the accordingly delayed response, some timing effect might result in Techprofile processing for multiple UNI's |
| 189 | */ |
| 190 | return handler.ProcessInterAdapterMessage(msg) |
| 191 | /* 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] | 192 | go handler.ProcessInterAdapterMessage(msg) |
| 193 | // error treatment might be more sophisticated |
| 194 | // by now let's just accept the message on 'communication layer' |
| 195 | // message content problems have to be evaluated then in the handler |
| 196 | // and are by now not reported to the calling party (to force what reaction there?) |
| 197 | return nil |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 198 | */ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 199 | } |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 200 | logger.Warnw("no handler found for received Inter-Proxy-message", log.Fields{ |
| 201 | "msgToDeviceId": targetDevice}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 202 | return fmt.Errorf(fmt.Sprintf("handler-not-found-%s", targetDevice)) |
| 203 | } |
| 204 | |
| 205 | //Adapter_descriptor not implemented |
| 206 | func (oo *OpenONUAC) Adapter_descriptor() error { |
| 207 | return errors.New("unImplemented") |
| 208 | } |
| 209 | |
| 210 | //Device_types unimplemented |
| 211 | func (oo *OpenONUAC) Device_types() (*voltha.DeviceTypes, error) { |
| 212 | return nil, errors.New("unImplemented") |
| 213 | } |
| 214 | |
| 215 | //Health returns unimplemented |
| 216 | func (oo *OpenONUAC) Health() (*voltha.HealthStatus, error) { |
| 217 | return nil, errors.New("unImplemented") |
| 218 | } |
| 219 | |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 220 | //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] | 221 | func (oo *OpenONUAC) Reconcile_device(device *voltha.Device) error { |
Holger Hildebrandt | f41a160 | 2020-08-19 09:52:50 +0000 | [diff] [blame] | 222 | if device == nil { |
| 223 | logger.Warn("voltha-device-is-nil") |
| 224 | return errors.New("nil-device") |
| 225 | } |
| 226 | ctx := context.Background() |
| 227 | logger.Infow("Reconcile_device", log.Fields{"device-id": device.Id}) |
| 228 | var handler *DeviceHandler |
| 229 | if handler = oo.getDeviceHandler(device.Id); handler == nil { |
| 230 | handler := NewDeviceHandler(oo.coreProxy, oo.adapterProxy, oo.eventProxy, device, oo) |
| 231 | oo.addDeviceHandlerToMap(ctx, handler) |
| 232 | handler.device = device |
| 233 | handler.reconciling = true |
| 234 | go handler.AdoptOrReconcileDevice(ctx, handler.device) |
| 235 | // reconcilement will be continued after onu-device entry is added |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 236 | } else { |
Holger Hildebrandt | f41a160 | 2020-08-19 09:52:50 +0000 | [diff] [blame] | 237 | 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] | 238 | } |
| 239 | return nil |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 240 | } |
| 241 | |
| 242 | //Abandon_device unimplemented |
| 243 | func (oo *OpenONUAC) Abandon_device(device *voltha.Device) error { |
| 244 | return errors.New("unImplemented") |
| 245 | } |
| 246 | |
| 247 | //Disable_device disables the given device |
| 248 | func (oo *OpenONUAC) Disable_device(device *voltha.Device) error { |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 249 | logger.Debugw("Disable_device", log.Fields{"device-id": device.Id}) |
ozgecanetsia | fce57b1 | 2020-05-25 14:39:35 +0300 | [diff] [blame] | 250 | if handler := oo.getDeviceHandler(device.Id); handler != nil { |
| 251 | go handler.DisableDevice(device) |
| 252 | return nil |
| 253 | } |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 254 | 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] | 255 | return fmt.Errorf(fmt.Sprintf("handler-not-found-%s", device.Id)) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 256 | } |
| 257 | |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 258 | //Reenable_device enables the onu device after disable |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 259 | func (oo *OpenONUAC) Reenable_device(device *voltha.Device) error { |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 260 | logger.Debugw("Reenable_device", log.Fields{"device-id": device.Id}) |
ozgecanetsia | fce57b1 | 2020-05-25 14:39:35 +0300 | [diff] [blame] | 261 | if handler := oo.getDeviceHandler(device.Id); handler != nil { |
| 262 | go handler.ReenableDevice(device) |
| 263 | return nil |
| 264 | } |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 265 | 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] | 266 | return fmt.Errorf(fmt.Sprintf("handler-not-found-%s", device.Id)) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 267 | } |
| 268 | |
| 269 | //Reboot_device reboots the given device |
| 270 | func (oo *OpenONUAC) Reboot_device(device *voltha.Device) error { |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 271 | logger.Debugw("Reboot-device", log.Fields{"device-id": device.Id}) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 272 | if handler := oo.getDeviceHandler(device.Id); handler != nil { |
| 273 | go handler.RebootDevice(device) |
| 274 | return nil |
| 275 | } |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 276 | 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] | 277 | return fmt.Errorf(fmt.Sprintf("handler-not-found-#{device.Id}")) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 278 | } |
| 279 | |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 280 | //Self_test_device unimplemented |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 281 | func (oo *OpenONUAC) Self_test_device(device *voltha.Device) error { |
| 282 | return errors.New("unImplemented") |
| 283 | } |
| 284 | |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 285 | func (oo *OpenONUAC) Delete_device(device *voltha.Device) error { |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 286 | logger.Debugw("Delete_device", log.Fields{"device-id": device.Id}) |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 287 | if handler := oo.getDeviceHandler(device.Id); handler != nil { |
| 288 | if err := handler.DeleteDevice(device); err != nil { |
| 289 | return err |
| 290 | } |
| 291 | } else { |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 292 | logger.Warnw("no handler found for device-reconcilement", log.Fields{"device-id": device.Id}) |
Holger Hildebrandt | 9ca8b13 | 2020-08-07 14:45:03 +0000 | [diff] [blame] | 293 | return fmt.Errorf(fmt.Sprintf("handler-not-found-%s", device.Id)) |
| 294 | } |
| 295 | return nil |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 296 | } |
| 297 | |
| 298 | //Get_device_details unimplemented |
| 299 | func (oo *OpenONUAC) Get_device_details(device *voltha.Device) error { |
| 300 | return errors.New("unImplemented") |
| 301 | } |
| 302 | |
| 303 | //Update_flows_bulk returns |
| 304 | func (oo *OpenONUAC) Update_flows_bulk(device *voltha.Device, flows *voltha.Flows, groups *voltha.FlowGroups, flowMetadata *voltha.FlowMetadata) error { |
| 305 | return errors.New("unImplemented") |
| 306 | } |
| 307 | |
| 308 | //Update_flows_incrementally updates (add/remove) the flows on a given device |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame^] | 309 | func (oo *OpenONUAC) Update_flows_incrementally(device *voltha.Device, |
| 310 | flows *openflow_13.FlowChanges, groups *openflow_13.FlowGroupChanges, flowMetadata *voltha.FlowMetadata) error { |
| 311 | // no point in pushing omci flows if the device isn't reachable |
| 312 | if device.ConnectStatus != voltha.ConnectStatus_REACHABLE || |
| 313 | device.AdminState != voltha.AdminState_ENABLED { |
| 314 | logger.Warnw("device disabled or offline - skipping flow-update", log.Fields{"deviceId": device.Id}) |
| 315 | return errors.New("non-matching device state") |
| 316 | } |
| 317 | |
| 318 | // For now, there is no support for group changes (as in the actual Py-adapter code) |
| 319 | if groups.ToAdd != nil && groups.ToAdd.Items != nil { |
| 320 | logger.Debugw("Update-flow-incr: group add not supported (ignored)", log.Fields{"deviceId": device.Id}) |
| 321 | } |
| 322 | if groups.ToRemove != nil && groups.ToRemove.Items != nil { |
| 323 | logger.Debugw("Update-flow-incr: group remove not supported (ignored)", log.Fields{"deviceId": device.Id}) |
| 324 | } |
| 325 | if groups.ToUpdate != nil && groups.ToUpdate.Items != nil { |
| 326 | logger.Debugw("Update-flow-incr: group update not supported (ignored)", log.Fields{"deviceId": device.Id}) |
| 327 | } |
| 328 | |
| 329 | if handler := oo.getDeviceHandler(device.Id); handler != nil { |
| 330 | err := handler.FlowUpdateIncremental(flows, groups, flowMetadata) |
| 331 | return err |
| 332 | } |
| 333 | logger.Warnw("no handler found for incremental flow update", log.Fields{"deviceId": device.Id}) |
| 334 | return fmt.Errorf(fmt.Sprintf("handler-not-found-%s", device.Id)) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 335 | } |
| 336 | |
| 337 | //Update_pm_config returns PmConfigs nil or error |
| 338 | func (oo *OpenONUAC) Update_pm_config(device *voltha.Device, pmConfigs *voltha.PmConfigs) error { |
| 339 | return errors.New("unImplemented") |
| 340 | } |
| 341 | |
| 342 | //Receive_packet_out sends packet out to the device |
| 343 | func (oo *OpenONUAC) Receive_packet_out(deviceID string, egressPortNo int, packet *openflow_13.OfpPacketOut) error { |
| 344 | return errors.New("unImplemented") |
| 345 | } |
| 346 | |
| 347 | //Suppress_event unimplemented |
| 348 | func (oo *OpenONUAC) Suppress_event(filter *voltha.EventFilter) error { |
| 349 | return errors.New("unImplemented") |
| 350 | } |
| 351 | |
| 352 | //Unsuppress_event unimplemented |
| 353 | func (oo *OpenONUAC) Unsuppress_event(filter *voltha.EventFilter) error { |
| 354 | return errors.New("unImplemented") |
| 355 | } |
| 356 | |
| 357 | //Download_image unimplemented |
| 358 | func (oo *OpenONUAC) Download_image(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) { |
| 359 | return nil, errors.New("unImplemented") |
| 360 | } |
| 361 | |
| 362 | //Get_image_download_status unimplemented |
| 363 | func (oo *OpenONUAC) Get_image_download_status(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) { |
| 364 | return nil, errors.New("unImplemented") |
| 365 | } |
| 366 | |
| 367 | //Cancel_image_download unimplemented |
| 368 | func (oo *OpenONUAC) Cancel_image_download(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) { |
| 369 | return nil, errors.New("unImplemented") |
| 370 | } |
| 371 | |
| 372 | //Activate_image_update unimplemented |
| 373 | func (oo *OpenONUAC) Activate_image_update(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) { |
| 374 | return nil, errors.New("unImplemented") |
| 375 | } |
| 376 | |
| 377 | //Revert_image_update unimplemented |
| 378 | func (oo *OpenONUAC) Revert_image_update(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) { |
| 379 | return nil, errors.New("unImplemented") |
| 380 | } |
| 381 | |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 382 | // 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] | 383 | func (oo *OpenONUAC) Enable_port(deviceID string, port *voltha.Port) error { |
| 384 | return errors.New("unImplemented") |
| 385 | } |
| 386 | |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 387 | // 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] | 388 | func (oo *OpenONUAC) Disable_port(deviceID string, port *voltha.Port) error { |
| 389 | return errors.New("unImplemented") |
| 390 | } |
| 391 | |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 392 | //needed for if update >= 3.1.x |
Matteo Scandolo | 2e6f1e3 | 2020-04-15 11:28:45 -0700 | [diff] [blame] | 393 | func (oo *OpenONUAC) Child_device_lost(deviceID string, pPortNo uint32, onuID uint32) error { |
| 394 | return errors.New("unImplemented") |
| 395 | } |
| 396 | |
| 397 | func (oo *OpenONUAC) Start_omci_test(device *voltha.Device, request *voltha.OmciTestRequest) (*voltha.TestResponse, error) { |
| 398 | return nil, errors.New("unImplemented") |
| 399 | } |
| 400 | |
Matteo Scandolo | d132c0e | 2020-04-24 17:06:25 -0700 | [diff] [blame] | 401 | func (oo *OpenONUAC) Get_ext_value(deviceID string, device *voltha.Device, valueparam voltha.ValueType_Type) (*voltha.ReturnValues, error) { |
| 402 | return nil, errors.New("unImplemented") |
| 403 | } |
| 404 | |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 405 | // Adapter interface required methods ################ end ######### |
| 406 | // ################################################################# |