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