blob: 3b505847eeba87c2d45bbd1863c8d32a49b82ef0 [file] [log] [blame]
Matteo Scandolo11006992019-08-28 11:29:46 -07001/*
2 * Copyright 2018-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
Matteo Scandolo4747d292019-08-05 11:50:18 -070017package devices
18
19import (
20 "context"
21 "errors"
22 "fmt"
Matteo Scandolod54283a2019-08-13 16:22:31 -070023 "github.com/opencord/voltha-protos/go/openolt"
Matteo Scandolo4747d292019-08-05 11:50:18 -070024 "github.com/looplab/fsm"
Matteo Scandolod54283a2019-08-13 16:22:31 -070025 "github.com/opencord/voltha-protos/go/tech_profile"
Matteo Scandolo4747d292019-08-05 11:50:18 -070026 log "github.com/sirupsen/logrus"
27 "google.golang.org/grpc"
28 "net"
Matteo Scandolo9a3518c2019-08-13 14:36:01 -070029 "os"
Matteo Scandolo4747d292019-08-05 11:50:18 -070030 "sync"
31)
32
Matteo Scandolo9a3518c2019-08-13 14:36:01 -070033var oltLogger = log.WithFields(log.Fields{
Matteo Scandolo84f7d482019-08-08 19:00:47 -070034 "module": "OLT",
35})
36
Matteo Scandolo4747d292019-08-05 11:50:18 -070037func init() {
38 //log.SetReportCaller(true)
39 log.SetLevel(log.DebugLevel)
40}
41
Matteo Scandolo84f7d482019-08-08 19:00:47 -070042var olt = OltDevice{}
43
44func GetOLT() OltDevice {
45 return olt
46}
47
Matteo Scandolo4747d292019-08-05 11:50:18 -070048func CreateOLT(seq int, nni int, pon int, onuPerPon int) OltDevice {
Matteo Scandolo9a3518c2019-08-13 14:36:01 -070049 oltLogger.WithFields(log.Fields{
Matteo Scandolo4747d292019-08-05 11:50:18 -070050 "ID": seq,
51 "NumNni":nni,
52 "NumPon":pon,
53 "NumOnuPerPon":onuPerPon,
54 }).Debug("CreateOLT")
55
Matteo Scandolo84f7d482019-08-08 19:00:47 -070056 olt = OltDevice{
Matteo Scandolo4747d292019-08-05 11:50:18 -070057 ID: seq,
Matteo Scandolo9a3518c2019-08-13 14:36:01 -070058 OperState: getOperStateFSM(func(e *fsm.Event) {
59 oltLogger.Debugf("Changing OLT OperState from %s to %s", e.Src, e.Dst)
60 }),
Matteo Scandolo4747d292019-08-05 11:50:18 -070061 NumNni:nni,
62 NumPon:pon,
63 NumOnuPerPon:onuPerPon,
64 Pons: []PonPort{},
65 Nnis: []NniPort{},
Matteo Scandolo9a3518c2019-08-13 14:36:01 -070066 channel: make(chan Message),
Matteo Scandolo4747d292019-08-05 11:50:18 -070067 }
68
69 // OLT State machine
Matteo Scandolo9a3518c2019-08-13 14:36:01 -070070 // NOTE do we need 2 state machines for the OLT? (InternalState and OperState)
Matteo Scandolo4747d292019-08-05 11:50:18 -070071 olt.InternalState = fsm.NewFSM(
72 "created",
73 fsm.Events{
74 {Name: "enable", Src: []string{"created"}, Dst: "enabled"},
75 {Name: "disable", Src: []string{"enabled"}, Dst: "disabled"},
76 },
77 fsm.Callbacks{
78 "enter_state": func(e *fsm.Event) {
Matteo Scandolo9a3518c2019-08-13 14:36:01 -070079 oltLogger.Debugf("Changing OLT InternalState from %s to %s", e.Src, e.Dst)
Matteo Scandolo4747d292019-08-05 11:50:18 -070080 },
81 },
82 )
83
84 // create NNI Port
85 nniPort := NniPort{
86 ID: uint32(0),
Matteo Scandolo9a3518c2019-08-13 14:36:01 -070087 OperState: getOperStateFSM(func(e *fsm.Event) {
88 oltLogger.Debugf("Changing NNI OperState from %s to %s", e.Src, e.Dst)
89 }),
Matteo Scandolo4747d292019-08-05 11:50:18 -070090 Type: "nni",
91 }
92 olt.Nnis = append(olt.Nnis, nniPort)
93
94 // create PON ports
Matteo Scandolo3bc73742019-08-20 14:04:04 -070095 //onuId := 1
Matteo Scandolo4747d292019-08-05 11:50:18 -070096 for i := 0; i < pon; i++ {
97 p := PonPort{
98 NumOnu: olt.NumOnuPerPon,
99 ID: uint32(i),
Matteo Scandolo4747d292019-08-05 11:50:18 -0700100 Type: "pon",
101 }
Matteo Scandolo9a3518c2019-08-13 14:36:01 -0700102 p.OperState = getOperStateFSM(func(e *fsm.Event) {
103 oltLogger.WithFields(log.Fields{
104 "ID": p.ID,
105 }).Debugf("Changing PON Port OperState from %s to %s", e.Src, e.Dst)
106 })
Matteo Scandolo4747d292019-08-05 11:50:18 -0700107
108 // create ONU devices
109 for j := 0; j < onuPerPon; j++ {
Matteo Scandolo3bc73742019-08-20 14:04:04 -0700110 //o := CreateONU(olt, p, uint32(onuId))
111 o := CreateONU(olt, p, uint32(j + 1))
Matteo Scandolo4747d292019-08-05 11:50:18 -0700112 p.Onus = append(p.Onus, o)
Matteo Scandolo3bc73742019-08-20 14:04:04 -0700113 //onuId = onuId + 1
Matteo Scandolo4747d292019-08-05 11:50:18 -0700114 }
115
116 olt.Pons = append(olt.Pons, p)
117 }
118
119 wg := sync.WaitGroup{}
120
121 wg.Add(1)
122 go newOltServer(olt)
123 wg.Wait()
124 return olt
125}
126
127func newOltServer(o OltDevice) error {
128 // TODO make configurable
129 address := "0.0.0.0:50060"
Matteo Scandolo4747d292019-08-05 11:50:18 -0700130 lis, err := net.Listen("tcp", address)
131 if err != nil {
Matteo Scandolo9a3518c2019-08-13 14:36:01 -0700132 oltLogger.Fatalf("OLT failed to listen: %v", err)
Matteo Scandolo4747d292019-08-05 11:50:18 -0700133 }
134 grpcServer := grpc.NewServer()
135 openolt.RegisterOpenoltServer(grpcServer, o)
136
137 go grpcServer.Serve(lis)
Matteo Scandolo9a3518c2019-08-13 14:36:01 -0700138 oltLogger.Debugf("OLT Listening on: %v", address)
Matteo Scandolo4747d292019-08-05 11:50:18 -0700139
140 return nil
141}
142
143// Device Methods
144
145func (o OltDevice) Enable (stream openolt.Openolt_EnableIndicationServer) error {
146
Matteo Scandolo9a3518c2019-08-13 14:36:01 -0700147 oltLogger.Debug("Enable OLT called")
Matteo Scandolo84f7d482019-08-08 19:00:47 -0700148
Matteo Scandolo4747d292019-08-05 11:50:18 -0700149 wg := sync.WaitGroup{}
150 wg.Add(1)
151
152 // create a channel for all the OLT events
Matteo Scandolo9a3518c2019-08-13 14:36:01 -0700153 go o.processOltMessages(stream)
Matteo Scandolo4747d292019-08-05 11:50:18 -0700154
155 // enable the OLT
156 olt_msg := Message{
157 Type: OltIndication,
158 Data: OltIndicationMessage{
159 OperState: UP,
160 },
161 }
162 o.channel <- olt_msg
163
164 // send NNI Port Indications
165 for _, nni := range o.Nnis {
166 msg := Message{
167 Type: NniIndication,
168 Data: NniIndicationMessage{
169 OperState: UP,
170 NniPortID: nni.ID,
171 },
172 }
173 o.channel <- msg
174 }
175
176 // send PON Port indications
177 for _, pon := range o.Pons {
178 msg := Message{
179 Type: PonIndication,
180 Data: PonIndicationMessage{
181 OperState: UP,
182 PonPortID: pon.ID,
183 },
184 }
185 o.channel <- msg
186
187 for _, onu := range pon.Onus {
Matteo Scandolo9a3518c2019-08-13 14:36:01 -0700188 go onu.processOnuMessages(stream)
Matteo Scandolo3bc73742019-08-20 14:04:04 -0700189 go onu.processOmciMessages(stream)
Matteo Scandolo4747d292019-08-05 11:50:18 -0700190 msg := Message{
191 Type: OnuDiscIndication,
192 Data: OnuDiscIndicationMessage{
193 Onu: onu,
194 OperState: UP,
195 },
196 }
Matteo Scandolo9a3518c2019-08-13 14:36:01 -0700197 onu.channel <- msg
Matteo Scandolo4747d292019-08-05 11:50:18 -0700198 }
199 }
200
201 wg.Wait()
202 return nil
203}
204
205// Helpers method
206
207func (o OltDevice) getPonById(id uint32) (*PonPort, error) {
208 for _, pon := range o.Pons {
209 if pon.ID == id {
210 return &pon, nil
211 }
212 }
213 return nil, errors.New(fmt.Sprintf("Cannot find PonPort with id %d in OLT %d", id, o.ID))
214}
215
216func (o OltDevice) getNniById(id uint32) (*NniPort, error) {
217 for _, nni := range o.Nnis {
218 if nni.ID == id {
219 return &nni, nil
220 }
221 }
222 return nil, errors.New(fmt.Sprintf("Cannot find NniPort with id %d in OLT %d", id, o.ID))
223}
224
Matteo Scandolo4747d292019-08-05 11:50:18 -0700225func (o OltDevice) sendOltIndication(msg OltIndicationMessage, stream openolt.Openolt_EnableIndicationServer) {
226 data := &openolt.Indication_OltInd{OltInd: &openolt.OltIndication{OperState: msg.OperState.String()}}
227 if err := stream.Send(&openolt.Indication{Data: data}); err != nil {
Matteo Scandolo11006992019-08-28 11:29:46 -0700228 oltLogger.Errorf("Failed to send Indication_OltInd: %v", err)
Matteo Scandolo4747d292019-08-05 11:50:18 -0700229 }
230
Matteo Scandolo9a3518c2019-08-13 14:36:01 -0700231 oltLogger.WithFields(log.Fields{
Matteo Scandolo4747d292019-08-05 11:50:18 -0700232 "OperState": msg.OperState,
233 }).Debug("Sent Indication_OltInd")
234}
235
236func (o OltDevice) sendNniIndication(msg NniIndicationMessage, stream openolt.Openolt_EnableIndicationServer) {
237 nni, _ := o.getNniById(msg.NniPortID)
Matteo Scandolo9a3518c2019-08-13 14:36:01 -0700238 nni.OperState.Event("enable")
239 // NOTE Operstate may need to be an integer
Matteo Scandolo4747d292019-08-05 11:50:18 -0700240 operData := &openolt.Indication_IntfOperInd{IntfOperInd: &openolt.IntfOperIndication{
241 Type: nni.Type,
242 IntfId: nni.ID,
Matteo Scandolo9a3518c2019-08-13 14:36:01 -0700243 OperState: nni.OperState.Current(),
Matteo Scandolo4747d292019-08-05 11:50:18 -0700244 }}
245
246 if err := stream.Send(&openolt.Indication{Data: operData}); err != nil {
Matteo Scandolo11006992019-08-28 11:29:46 -0700247 oltLogger.Errorf("Failed to send Indication_IntfOperInd for NNI: %v", err)
Matteo Scandolo4747d292019-08-05 11:50:18 -0700248 }
249
Matteo Scandolo9a3518c2019-08-13 14:36:01 -0700250 oltLogger.WithFields(log.Fields{
Matteo Scandolo4747d292019-08-05 11:50:18 -0700251 "Type": nni.Type,
252 "IntfId": nni.ID,
Matteo Scandolo9a3518c2019-08-13 14:36:01 -0700253 "OperState": nni.OperState.Current(),
Matteo Scandolo4747d292019-08-05 11:50:18 -0700254 }).Debug("Sent Indication_IntfOperInd for NNI")
255}
256
257func (o OltDevice) sendPonIndication(msg PonIndicationMessage, stream openolt.Openolt_EnableIndicationServer) {
258 pon, _ := o.getPonById(msg.PonPortID)
Matteo Scandolo9a3518c2019-08-13 14:36:01 -0700259 pon.OperState.Event("enable")
Matteo Scandolo4747d292019-08-05 11:50:18 -0700260 discoverData := &openolt.Indication_IntfInd{IntfInd: &openolt.IntfIndication{
261 IntfId: pon.ID,
Matteo Scandolo9a3518c2019-08-13 14:36:01 -0700262 OperState: pon.OperState.Current(),
Matteo Scandolo4747d292019-08-05 11:50:18 -0700263 }}
264
265 if err := stream.Send(&openolt.Indication{Data: discoverData}); err != nil {
Matteo Scandolo11006992019-08-28 11:29:46 -0700266 oltLogger.Errorf("Failed to send Indication_IntfInd: %v", err)
Matteo Scandolo4747d292019-08-05 11:50:18 -0700267 }
268
Matteo Scandolo9a3518c2019-08-13 14:36:01 -0700269 oltLogger.WithFields(log.Fields{
Matteo Scandolo4747d292019-08-05 11:50:18 -0700270 "IntfId": pon.ID,
Matteo Scandolo9a3518c2019-08-13 14:36:01 -0700271 "OperState": pon.OperState.Current(),
Matteo Scandolo4747d292019-08-05 11:50:18 -0700272 }).Debug("Sent Indication_IntfInd")
273
274 operData := &openolt.Indication_IntfOperInd{IntfOperInd: &openolt.IntfOperIndication{
275 Type: pon.Type,
276 IntfId: pon.ID,
Matteo Scandolo9a3518c2019-08-13 14:36:01 -0700277 OperState: pon.OperState.Current(),
Matteo Scandolo4747d292019-08-05 11:50:18 -0700278 }}
279
280 if err := stream.Send(&openolt.Indication{Data: operData}); err != nil {
Matteo Scandolo11006992019-08-28 11:29:46 -0700281 oltLogger.Errorf("Failed to send Indication_IntfOperInd for PON: %v", err)
Matteo Scandolo4747d292019-08-05 11:50:18 -0700282 }
283
Matteo Scandolo9a3518c2019-08-13 14:36:01 -0700284 oltLogger.WithFields(log.Fields{
Matteo Scandolo4747d292019-08-05 11:50:18 -0700285 "Type": pon.Type,
286 "IntfId": pon.ID,
Matteo Scandolo9a3518c2019-08-13 14:36:01 -0700287 "OperState": pon.OperState.Current(),
Matteo Scandolo4747d292019-08-05 11:50:18 -0700288 }).Debug("Sent Indication_IntfOperInd for PON")
289}
290
Matteo Scandolo9a3518c2019-08-13 14:36:01 -0700291func (o OltDevice) processOltMessages(stream openolt.Openolt_EnableIndicationServer) {
292 oltLogger.Debug("Started OLT Indication Channel")
Matteo Scandolo4747d292019-08-05 11:50:18 -0700293 for message := range o.channel {
294
Matteo Scandolo4747d292019-08-05 11:50:18 -0700295
Matteo Scandolo9a3518c2019-08-13 14:36:01 -0700296 oltLogger.WithFields(log.Fields{
297 "oltId": o.ID,
298 "messageType": message.Type,
299 }).Trace("Received message")
300
301 switch message.Type {
302 case OltIndication:
303 msg, _ := message.Data.(OltIndicationMessage)
304 if msg.OperState == UP {
Matteo Scandolo4747d292019-08-05 11:50:18 -0700305 o.InternalState.Event("enable")
Matteo Scandolo9a3518c2019-08-13 14:36:01 -0700306 o.OperState.Event("enable")
307 } else if msg.OperState == DOWN {
308 o.InternalState.Event("disable")
309 o.OperState.Event("disable")
Matteo Scandolo4747d292019-08-05 11:50:18 -0700310 }
Matteo Scandolo9a3518c2019-08-13 14:36:01 -0700311 o.sendOltIndication(msg, stream)
312 case NniIndication:
313 msg, _ := message.Data.(NniIndicationMessage)
314 o.sendNniIndication(msg, stream)
315 case PonIndication:
316 msg, _ := message.Data.(PonIndicationMessage)
317 o.sendPonIndication(msg, stream)
318 default:
319 oltLogger.Warnf("Received unknown message data %v for type %v in OLT channel", message.Data, message.Type)
Matteo Scandolo4747d292019-08-05 11:50:18 -0700320 }
321
322 }
323}
324
325// GRPC Endpoints
326
327func (o OltDevice) ActivateOnu(context context.Context, onu *openolt.Onu) (*openolt.Empty, error) {
Matteo Scandolo9a3518c2019-08-13 14:36:01 -0700328 oltLogger.WithFields(log.Fields{
Matteo Scandolo4747d292019-08-05 11:50:18 -0700329 "onuSerialNumber": onu.SerialNumber,
330 }).Info("Received ActivateOnu call from VOLTHA")
Matteo Scandolo9a3518c2019-08-13 14:36:01 -0700331
332 pon, _ := o.getPonById(onu.IntfId)
333 _onu, _ := pon.getOnuBySn(onu.SerialNumber)
334
335 // NOTE we need to immediately activate the ONU or the OMCI state machine won't start
Matteo Scandolo4747d292019-08-05 11:50:18 -0700336 msg := Message{
337 Type: OnuIndication,
338 Data: OnuIndicationMessage{
339 OnuSN: onu.SerialNumber,
340 PonPortID: onu.IntfId,
341 OperState: UP,
342 },
343 }
Matteo Scandolo9a3518c2019-08-13 14:36:01 -0700344 _onu.channel <- msg
Matteo Scandolo4747d292019-08-05 11:50:18 -0700345 return new(openolt.Empty) , nil
346}
347
348func (o OltDevice) DeactivateOnu(context.Context, *openolt.Onu) (*openolt.Empty, error) {
Matteo Scandolo9a3518c2019-08-13 14:36:01 -0700349 oltLogger.Error("DeactivateOnu not implemented")
Matteo Scandolo4747d292019-08-05 11:50:18 -0700350 return new(openolt.Empty) , nil
351}
352
353func (o OltDevice) DeleteOnu(context.Context, *openolt.Onu) (*openolt.Empty, error) {
Matteo Scandolo9a3518c2019-08-13 14:36:01 -0700354 oltLogger.Error("DeleteOnu not implemented")
Matteo Scandolo4747d292019-08-05 11:50:18 -0700355 return new(openolt.Empty) , nil
356}
357
358func (o OltDevice) DisableOlt(context.Context, *openolt.Empty) (*openolt.Empty, error) {
Matteo Scandolo9a3518c2019-08-13 14:36:01 -0700359 // NOTE when we disable the OLT should we disable NNI, PONs and ONUs altogether?
360 olt_msg := Message{
361 Type: OltIndication,
362 Data: OltIndicationMessage{
363 OperState: DOWN,
364 },
365 }
366 o.channel <- olt_msg
Matteo Scandolo4747d292019-08-05 11:50:18 -0700367 return new(openolt.Empty) , nil
368}
369
370func (o OltDevice) DisablePonIf(context.Context, *openolt.Interface) (*openolt.Empty, error) {
Matteo Scandolo9a3518c2019-08-13 14:36:01 -0700371 oltLogger.Error("DisablePonIf not implemented")
Matteo Scandolo4747d292019-08-05 11:50:18 -0700372 return new(openolt.Empty) , nil
373}
374
375func (o OltDevice) EnableIndication(_ *openolt.Empty, stream openolt.Openolt_EnableIndicationServer) error {
Matteo Scandolo9a3518c2019-08-13 14:36:01 -0700376 oltLogger.WithField("oltId", o.ID).Info("OLT receives EnableIndication call from VOLTHA")
Matteo Scandolo4747d292019-08-05 11:50:18 -0700377 o.Enable(stream)
378 return nil
379}
380
381func (o OltDevice) EnablePonIf(context.Context, *openolt.Interface) (*openolt.Empty, error) {
Matteo Scandolo9a3518c2019-08-13 14:36:01 -0700382 oltLogger.Error("EnablePonIf not implemented")
Matteo Scandolo4747d292019-08-05 11:50:18 -0700383 return new(openolt.Empty) , nil
384}
385
Matteo Scandolo3bc73742019-08-20 14:04:04 -0700386func (o OltDevice) FlowAdd(ctx context.Context, flow *openolt.Flow) (*openolt.Empty, error) {
387 oltLogger.WithFields(log.Fields{
388 "IntfId": flow.AccessIntfId,
389 "OnuId": flow.OnuId,
390 "EthType": fmt.Sprintf("%x", flow.Classifier.EthType),
391 "InnerVlan": flow.Classifier.IVid,
392 "OuterVlan": flow.Classifier.OVid,
393 "FlowType": flow.FlowType,
394 "FlowId": flow.FlowId,
395 "UniID": flow.UniId,
396 "PortNo": flow.PortNo,
397 }).Infof("OLT receives Flow")
398 // TODO optionally store flows somewhere
399
400 if flow.AccessIntfId == -1 {
401 oltLogger.WithFields(log.Fields{
402 "FlowId": flow.FlowId,
403 }).Debugf("This is an OLT flow")
404 } else {
405 pon, _ := o.getPonById(uint32(flow.AccessIntfId))
406 onu, _ := pon.getOnuById(uint32(flow.OnuId))
407
408 msg := Message{
409 Type: FlowUpdate,
410 Data: OnuFlowUpdateMessage{
411 PonPortID: pon.ID,
412 OnuID: onu.ID,
413 Flow: flow,
414 },
415 }
416 onu.channel <- msg
417 }
418
Matteo Scandolo4747d292019-08-05 11:50:18 -0700419 return new(openolt.Empty) , nil
420}
421
422func (o OltDevice) FlowRemove(context.Context, *openolt.Flow) (*openolt.Empty, error) {
Matteo Scandoloc559ef12019-08-20 13:24:21 -0700423 oltLogger.Info("received FlowRemove")
424 // TODO store flows somewhere
Matteo Scandolo4747d292019-08-05 11:50:18 -0700425 return new(openolt.Empty) , nil
426}
427
428func (o OltDevice) HeartbeatCheck(context.Context, *openolt.Empty) (*openolt.Heartbeat, error) {
Matteo Scandolo9a3518c2019-08-13 14:36:01 -0700429 oltLogger.Error("HeartbeatCheck not implemented")
Matteo Scandolo4747d292019-08-05 11:50:18 -0700430 return new(openolt.Heartbeat) , nil
431}
432
433func (o OltDevice) GetDeviceInfo(context.Context, *openolt.Empty) (*openolt.DeviceInfo, error) {
434
Matteo Scandoloda9cbe22019-08-19 16:05:10 -0700435 oltLogger.WithFields(log.Fields{
436 "oltId": o.ID,
437 "PonPorts": o.NumPon,
438 }).Info("OLT receives GetDeviceInfo call from VOLTHA")
Matteo Scandolo4747d292019-08-05 11:50:18 -0700439 devinfo := new(openolt.DeviceInfo)
440 devinfo.Vendor = "BBSim"
441 devinfo.Model = "asfvolt16"
Matteo Scandolo84f7d482019-08-08 19:00:47 -0700442 devinfo.HardwareVersion = "emulated"
Matteo Scandolo4747d292019-08-05 11:50:18 -0700443 devinfo.FirmwareVersion = ""
444 devinfo.Technology = "xgspon"
Matteo Scandoloda9cbe22019-08-19 16:05:10 -0700445 devinfo.PonPorts = uint32(o.NumPon)
Matteo Scandolo4747d292019-08-05 11:50:18 -0700446 devinfo.OnuIdStart = 1
447 devinfo.OnuIdEnd = 255
448 devinfo.AllocIdStart = 1024
449 devinfo.AllocIdEnd = 16383
450 devinfo.GemportIdStart = 1024
451 devinfo.GemportIdEnd = 65535
452 devinfo.FlowIdStart = 1
453 devinfo.FlowIdEnd = 16383
Matteo Scandolo84f7d482019-08-08 19:00:47 -0700454 devinfo.DeviceSerialNumber = fmt.Sprintf("BBSIM_OLT_%d", o.ID)
Matteo Scandolo4747d292019-08-05 11:50:18 -0700455
456 return devinfo, nil
457}
458
Matteo Scandolo9a3518c2019-08-13 14:36:01 -0700459func (o OltDevice) OmciMsgOut(ctx context.Context, omci_msg *openolt.OmciMsg) (*openolt.Empty, error) {
Matteo Scandolo9a3518c2019-08-13 14:36:01 -0700460 pon, _ := o.getPonById(omci_msg.IntfId)
461 onu, _ := pon.getOnuById(omci_msg.OnuId)
462 msg := Message{
463 Type: OMCI,
464 Data: OmciMessage{
465 OnuSN: onu.SerialNumber,
Matteo Scandoloc559ef12019-08-20 13:24:21 -0700466 OnuID: onu.ID,
467 omciMsg: omci_msg,
Matteo Scandolo9a3518c2019-08-13 14:36:01 -0700468 },
469 }
470 onu.channel <- msg
Matteo Scandolo4747d292019-08-05 11:50:18 -0700471 return new(openolt.Empty) , nil
472}
473
474func (o OltDevice) OnuPacketOut(context.Context, *openolt.OnuPacket) (*openolt.Empty, error) {
Matteo Scandolo9a3518c2019-08-13 14:36:01 -0700475 oltLogger.Error("OnuPacketOut not implemented")
Matteo Scandolo4747d292019-08-05 11:50:18 -0700476 return new(openolt.Empty) , nil
477}
478
479func (o OltDevice) Reboot(context.Context, *openolt.Empty) (*openolt.Empty, error) {
Matteo Scandolo9a3518c2019-08-13 14:36:01 -0700480 oltLogger.Info("Shutting Down, hope you're running in K8s...")
481 os.Exit(0)
Matteo Scandolo4747d292019-08-05 11:50:18 -0700482 return new(openolt.Empty) , nil
483}
484
485func (o OltDevice) ReenableOlt(context.Context, *openolt.Empty) (*openolt.Empty, error) {
Matteo Scandolo9a3518c2019-08-13 14:36:01 -0700486 oltLogger.Error("ReenableOlt not implemented")
Matteo Scandolo4747d292019-08-05 11:50:18 -0700487 return new(openolt.Empty) , nil
488}
489
490func (o OltDevice) UplinkPacketOut(context context.Context, packet *openolt.UplinkPacket) (*openolt.Empty, error) {
Matteo Scandoloc559ef12019-08-20 13:24:21 -0700491 oltLogger.Warn("UplinkPacketOut not implemented")
Matteo Scandolo4747d292019-08-05 11:50:18 -0700492 return new(openolt.Empty) , nil
493}
494
495func (o OltDevice) CollectStatistics(context.Context, *openolt.Empty) (*openolt.Empty, error) {
Matteo Scandolo9a3518c2019-08-13 14:36:01 -0700496 oltLogger.Error("CollectStatistics not implemented")
Matteo Scandolo4747d292019-08-05 11:50:18 -0700497 return new(openolt.Empty) , nil
498}
499
Matteo Scandolo4747d292019-08-05 11:50:18 -0700500func (o OltDevice) GetOnuInfo(context context.Context, packet *openolt.Onu) (*openolt.OnuIndication, error) {
Matteo Scandolo9a3518c2019-08-13 14:36:01 -0700501 oltLogger.Error("GetOnuInfo not implemented")
Matteo Scandolo4747d292019-08-05 11:50:18 -0700502 return new(openolt.OnuIndication) , nil
503}
504
505func (o OltDevice) GetPonIf(context context.Context, packet *openolt.Interface) (*openolt.IntfIndication, error) {
Matteo Scandolo9a3518c2019-08-13 14:36:01 -0700506 oltLogger.Error("GetPonIf not implemented")
Matteo Scandolo4747d292019-08-05 11:50:18 -0700507 return new(openolt.IntfIndication) , nil
Matteo Scandolod54283a2019-08-13 16:22:31 -0700508}
509
510func (s OltDevice) CreateTrafficQueues(context.Context, *tech_profile.TrafficQueues) (*openolt.Empty, error) {
Matteo Scandoloc559ef12019-08-20 13:24:21 -0700511 oltLogger.Info("received CreateTrafficQueues")
Matteo Scandolod54283a2019-08-13 16:22:31 -0700512 return new(openolt.Empty), nil
513}
514
515func (s OltDevice) RemoveTrafficQueues(context.Context, *tech_profile.TrafficQueues) (*openolt.Empty, error) {
Matteo Scandoloc559ef12019-08-20 13:24:21 -0700516 oltLogger.Info("received RemoveTrafficQueues")
Matteo Scandolod54283a2019-08-13 16:22:31 -0700517 return new(openolt.Empty), nil
518}
519
520func (s OltDevice) CreateTrafficSchedulers(context.Context, *tech_profile.TrafficSchedulers) (*openolt.Empty, error) {
Matteo Scandoloc559ef12019-08-20 13:24:21 -0700521 oltLogger.Info("received CreateTrafficSchedulers")
Matteo Scandolod54283a2019-08-13 16:22:31 -0700522 return new(openolt.Empty), nil
523}
524
525func (s OltDevice) RemoveTrafficSchedulers(context.Context, *tech_profile.TrafficSchedulers) (*openolt.Empty, error) {
Matteo Scandoloc559ef12019-08-20 13:24:21 -0700526 oltLogger.Info("received RemoveTrafficSchedulers")
Matteo Scandolod54283a2019-08-13 16:22:31 -0700527 return new(openolt.Empty), nil
Matteo Scandolo4747d292019-08-05 11:50:18 -0700528}