blob: a986205405f86056af7cf2a42b72ba1cdaeb6122 [file] [log] [blame]
Matteo Scandolo8df63df2019-09-12 10:34:32 -07001/*
2 * Portions copyright 2019-present Open Networking Foundation
3 * Original copyright 2019-present Ciena Corporation
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18package commands
19
20import (
21 "context"
Matteo Scandolo10f965c2019-09-24 10:40:46 -070022 "fmt"
Anand S Katti09541352020-01-29 15:54:01 +053023 "os"
24 "strconv"
25 "strings"
26
Matteo Scandolo8df63df2019-09-12 10:34:32 -070027 "github.com/jessevdk/go-flags"
Anand S Katti09541352020-01-29 15:54:01 +053028 "github.com/olekukonko/tablewriter"
Matteo Scandolo8df63df2019-09-12 10:34:32 -070029 pb "github.com/opencord/bbsim/api/bbsim"
30 "github.com/opencord/bbsim/internal/bbsimctl/config"
31 "github.com/opencord/cordctl/pkg/format"
32 log "github.com/sirupsen/logrus"
Matteo Scandolo8df63df2019-09-12 10:34:32 -070033)
34
35const (
Matteo Scandolocedde462021-03-09 17:37:16 -080036 DEFAULT_ONU_DEVICE_HEADER_FORMAT = "table{{ .PonPortID }}\t{{ .ID }}\t{{ .PortNo }}\t{{ .SerialNumber }}\t{{ .OperState }}\t{{ .InternalState }}\t{{ .ImageSoftwareExpectedSections }}\t{{ .ImageSoftwareReceivedSections }}\t{{ .ActiveImageEntityId }}\t{{ .CommittedImageEntityId }}"
Matteo Scandoloef4e8f82021-05-17 11:20:49 -070037 DEFAULT_ONU_DEVICE_HEADER_FORMAT_WITH_SERVICES = "table{{ .PonPortID }}\t{{ .ID }}\t{{ .PortNo }}\t{{ .SerialNumber }}\t{{ .OperState }}\t{{ .InternalState }}\t{{ .ImageSoftwareExpectedSections }}\t{{ .ImageSoftwareReceivedSections }}\t{{ .ActiveImageEntityId }}\t{{ .CommittedImageEntityId }}\t{{ .Unis }}\t{{ .Services }}"
38 DEFAULT_UNI_HEADER_FORMAT = "table{{ .OnuSn }}\t{{ .OnuID }}\t{{ .ID }}\t{{ .MeID }}\t{{ .OperState }}"
Matteo Scandolo8df63df2019-09-12 10:34:32 -070039)
40
Matteo Scandolo10f965c2019-09-24 10:40:46 -070041type OnuSnString string
Arjun E K57a7fcb2020-01-30 06:44:45 +000042type IgmpSubAction string
Onur Kalinagac9f9faca2021-01-21 14:04:34 +000043type GroupAddress string
Arjun E K57a7fcb2020-01-30 06:44:45 +000044
45const IgmpJoinKey string = "join"
46const IgmpLeaveKey string = "leave"
Arjun E Kdd443f02020-02-07 15:24:01 +000047const IgmpJoinKeyV3 string = "joinv3"
Arjun E K57a7fcb2020-01-30 06:44:45 +000048
Matteo Scandolo618a6582020-09-09 12:21:29 -070049var IgmpAllowedActions = []string{IgmpJoinKey, IgmpLeaveKey, IgmpJoinKeyV3}
50
Matteo Scandolo4a036262020-08-17 15:56:13 -070051type ONUList struct {
52 Verbose bool `short:"v" long:"verbose" description:"Print all the informations we have about ONUs"`
53}
Matteo Scandolod2ca2c72019-10-04 16:50:22 -070054
55type ONUGet struct {
Matteo Scandolo4a036262020-08-17 15:56:13 -070056 Verbose bool `short:"v" long:"verbose" description:"Print all the informations we have about ONUs"`
57 Args struct {
58 OnuSn OnuSnString
59 } `positional-args:"yes" required:"yes"`
60}
61
62type ONUServices struct {
Matteo Scandolod2ca2c72019-10-04 16:50:22 -070063 Args struct {
64 OnuSn OnuSnString
65 } `positional-args:"yes" required:"yes"`
66}
67
Matteo Scandoloef4e8f82021-05-17 11:20:49 -070068type ONUUnis struct {
69 Args struct {
70 OnuSn OnuSnString
71 } `positional-args:"yes" required:"yes"`
72}
73
Matteo Scandolo10f965c2019-09-24 10:40:46 -070074type ONUShutDown struct {
75 Args struct {
76 OnuSn OnuSnString
77 } `positional-args:"yes" required:"yes"`
Matteo Scandolo8df63df2019-09-12 10:34:32 -070078}
79
Matteo Scandolo10f965c2019-09-24 10:40:46 -070080type ONUPowerOn struct {
81 Args struct {
82 OnuSn OnuSnString
83 } `positional-args:"yes" required:"yes"`
84}
85
Matteo Scandoloe383d5d2019-10-25 14:47:27 -070086type ONUEapolRestart struct {
87 Args struct {
88 OnuSn OnuSnString
89 } `positional-args:"yes" required:"yes"`
90}
91
92type ONUDhcpRestart struct {
93 Args struct {
94 OnuSn OnuSnString
95 } `positional-args:"yes" required:"yes"`
96}
97
Arjun E K57a7fcb2020-01-30 06:44:45 +000098type ONUIgmp struct {
99 Args struct {
Onur Kalinagac9f9faca2021-01-21 14:04:34 +0000100 OnuSn OnuSnString
101 SubAction IgmpSubAction
102 GroupAddress GroupAddress
Arjun E K57a7fcb2020-01-30 06:44:45 +0000103 } `positional-args:"yes" required:"yes"`
104}
105
Pragya Arya8bdb4532020-03-02 17:08:09 +0530106type ONUTrafficSchedulers struct {
107 Args struct {
108 OnuSn OnuSnString
109 } `positional-args:"yes" required:"yes"`
110}
111
112type ONUFlows struct {
113 Args struct {
114 OnuSn OnuSnString
115 } `positional-args:"yes" required:"yes"`
116}
117
Matteo Scandolo10f965c2019-09-24 10:40:46 -0700118type ONUOptions struct {
Anand S Katti09541352020-01-29 15:54:01 +0530119 List ONUList `command:"list"`
120 Get ONUGet `command:"get"`
Matteo Scandolo4a036262020-08-17 15:56:13 -0700121 Services ONUServices `command:"services"`
Matteo Scandoloef4e8f82021-05-17 11:20:49 -0700122 Unis ONUUnis `command:"unis"`
Anand S Katti09541352020-01-29 15:54:01 +0530123 ShutDown ONUShutDown `command:"shutdown"`
124 PowerOn ONUPowerOn `command:"poweron"`
125 RestartEapol ONUEapolRestart `command:"auth_restart"`
126 RestartDchp ONUDhcpRestart `command:"dhcp_restart"`
127 Igmp ONUIgmp `command:"igmp"`
128 TrafficSchedulers ONUTrafficSchedulers `command:"traffic_schedulers"`
Anand S Katti86552f92020-03-03 21:56:32 +0530129 Alarms AlarmOptions `command:"alarms"`
Pragya Arya8bdb4532020-03-02 17:08:09 +0530130 Flows ONUFlows `command:"flows"`
Matteo Scandolo10f965c2019-09-24 10:40:46 -0700131}
132
133func RegisterONUCommands(parser *flags.Parser) {
Shrey Baid688b4242020-07-10 20:40:10 +0530134 _, _ = parser.AddCommand("onu", "ONU Commands", "Commands to query and manipulate ONU devices", &ONUOptions{})
Matteo Scandolo10f965c2019-09-24 10:40:46 -0700135}
136
Matteo Scandolo10f965c2019-09-24 10:40:46 -0700137func getONUs() *pb.ONUs {
138
139 client, conn := connect()
Matteo Scandolo8df63df2019-09-12 10:34:32 -0700140 defer conn.Close()
Matteo Scandolo8df63df2019-09-12 10:34:32 -0700141
142 // Contact the server and print out its response.
Matteo Scandolo8df63df2019-09-12 10:34:32 -0700143 ctx, cancel := context.WithTimeout(context.Background(), config.GlobalConfig.Grpc.Timeout)
144 defer cancel()
Matteo Scandolo10f965c2019-09-24 10:40:46 -0700145
146 onus, err := client.GetONUs(ctx, &pb.Empty{})
Matteo Scandolo8df63df2019-09-12 10:34:32 -0700147 if err != nil {
Matteo Scandolo2bf742a2019-10-01 11:33:34 -0700148 log.Fatalf("could not get OLT: %v", err)
Matteo Scandolo8df63df2019-09-12 10:34:32 -0700149 return nil
150 }
151 return onus
152}
153
Matteo Scandolo10f965c2019-09-24 10:40:46 -0700154func (options *ONUList) Execute(args []string) error {
Matteo Scandolo8df63df2019-09-12 10:34:32 -0700155 onus := getONUs()
156
157 // print out
Matteo Scandolo4a036262020-08-17 15:56:13 -0700158 var tableFormat format.Format
159 if options.Verbose {
160 tableFormat = format.Format(DEFAULT_ONU_DEVICE_HEADER_FORMAT_WITH_SERVICES)
161 } else {
162 tableFormat = format.Format(DEFAULT_ONU_DEVICE_HEADER_FORMAT)
163 }
Matteo Scandolo8df63df2019-09-12 10:34:32 -0700164 if err := tableFormat.Execute(os.Stdout, true, onus.Items); err != nil {
165 log.Fatalf("Error while formatting ONUs table: %s", err)
166 }
167
168 return nil
169}
Matteo Scandolo10f965c2019-09-24 10:40:46 -0700170
Matteo Scandolod2ca2c72019-10-04 16:50:22 -0700171func (options *ONUGet) Execute(args []string) error {
172 client, conn := connect()
173 defer conn.Close()
174
175 ctx, cancel := context.WithTimeout(context.Background(), config.GlobalConfig.Grpc.Timeout)
176 defer cancel()
177 req := pb.ONURequest{
178 SerialNumber: string(options.Args.OnuSn),
179 }
180 res, err := client.GetONU(ctx, &req)
181
182 if err != nil {
Matteo Scandolo4a036262020-08-17 15:56:13 -0700183 log.Fatalf("Cannot not get ONU %s: %v", options.Args.OnuSn, err)
Matteo Scandolod2ca2c72019-10-04 16:50:22 -0700184 return err
185 }
186
Matteo Scandolo4a036262020-08-17 15:56:13 -0700187 var tableFormat format.Format
188 if options.Verbose {
189 tableFormat = format.Format(DEFAULT_ONU_DEVICE_HEADER_FORMAT_WITH_SERVICES)
190 } else {
191 tableFormat = format.Format(DEFAULT_ONU_DEVICE_HEADER_FORMAT)
192 }
Matteo Scandolod2ca2c72019-10-04 16:50:22 -0700193 if err := tableFormat.Execute(os.Stdout, true, []*pb.ONU{res}); err != nil {
194 log.Fatalf("Error while formatting ONUs table: %s", err)
195 }
196
197 return nil
198}
199
Matteo Scandolo4a036262020-08-17 15:56:13 -0700200func (options *ONUServices) Execute(args []string) error {
201
202 client, conn := connect()
203 defer conn.Close()
204
205 ctx, cancel := context.WithTimeout(context.Background(), config.GlobalConfig.Grpc.Timeout)
206 defer cancel()
207 req := pb.ONURequest{
208 SerialNumber: string(options.Args.OnuSn),
209 }
210 res, err := client.GetOnuServices(ctx, &req)
211
212 if err != nil {
213 log.Fatalf("Cannot not get services for ONU %s: %v", options.Args.OnuSn, err)
214 return err
215 }
216
217 tableFormat := format.Format(DEFAULT_SERVICE_HEADER_FORMAT)
218 if err := tableFormat.Execute(os.Stdout, true, res.Items); err != nil {
219 log.Fatalf("Error while formatting Services table: %s", err)
220 }
221
222 return nil
223}
224
Matteo Scandoloef4e8f82021-05-17 11:20:49 -0700225func (options *ONUUnis) Execute(args []string) error {
226
227 client, conn := connect()
228 defer conn.Close()
229
230 ctx, cancel := context.WithTimeout(context.Background(), config.GlobalConfig.Grpc.Timeout)
231 defer cancel()
232 req := pb.ONURequest{
233 SerialNumber: string(options.Args.OnuSn),
234 }
235 res, err := client.GetOnuUnis(ctx, &req)
236
237 if err != nil {
238 log.Fatalf("Cannot not get unis for ONU %s: %v", options.Args.OnuSn, err)
239 return err
240 }
241
242 tableFormat := format.Format(DEFAULT_UNI_HEADER_FORMAT)
243 if err := tableFormat.Execute(os.Stdout, true, res.Items); err != nil {
244 log.Fatalf("Error while formatting Unis table: %s", err)
245 }
246
247 return nil
248}
249
Matteo Scandolo10f965c2019-09-24 10:40:46 -0700250func (options *ONUShutDown) Execute(args []string) error {
251
252 client, conn := connect()
253 defer conn.Close()
254
255 ctx, cancel := context.WithTimeout(context.Background(), config.GlobalConfig.Grpc.Timeout)
256 defer cancel()
257 req := pb.ONURequest{
258 SerialNumber: string(options.Args.OnuSn),
259 }
260 res, err := client.ShutdownONU(ctx, &req)
261
262 if err != nil {
Matteo Scandoloe383d5d2019-10-25 14:47:27 -0700263 log.Fatalf("Cannot shutdown ONU %s: %v", options.Args.OnuSn, err)
Matteo Scandolo10f965c2019-09-24 10:40:46 -0700264 return err
265 }
266
267 fmt.Println(fmt.Sprintf("[Status: %d] %s", res.StatusCode, res.Message))
268
269 return nil
270}
271
272func (options *ONUPowerOn) Execute(args []string) error {
273 client, conn := connect()
274 defer conn.Close()
275
276 ctx, cancel := context.WithTimeout(context.Background(), config.GlobalConfig.Grpc.Timeout)
277 defer cancel()
278 req := pb.ONURequest{
279 SerialNumber: string(options.Args.OnuSn),
280 }
281 res, err := client.PoweronONU(ctx, &req)
282
283 if err != nil {
Matteo Scandoloe383d5d2019-10-25 14:47:27 -0700284 log.Fatalf("Cannot power on ONU %s: %v", options.Args.OnuSn, err)
285 return err
286 }
287
288 fmt.Println(fmt.Sprintf("[Status: %d] %s", res.StatusCode, res.Message))
289
290 return nil
291}
292
293func (options *ONUEapolRestart) Execute(args []string) error {
294 client, conn := connect()
295 defer conn.Close()
296
297 ctx, cancel := context.WithTimeout(context.Background(), config.GlobalConfig.Grpc.Timeout)
298 defer cancel()
299 req := pb.ONURequest{
300 SerialNumber: string(options.Args.OnuSn),
301 }
302 res, err := client.RestartEapol(ctx, &req)
303
304 if err != nil {
305 log.Fatalf("Cannot restart EAPOL for ONU %s: %v", options.Args.OnuSn, err)
306 return err
307 }
308
309 fmt.Println(fmt.Sprintf("[Status: %d] %s", res.StatusCode, res.Message))
310
311 return nil
312}
313
314func (options *ONUDhcpRestart) Execute(args []string) error {
315 client, conn := connect()
316 defer conn.Close()
317
318 ctx, cancel := context.WithTimeout(context.Background(), config.GlobalConfig.Grpc.Timeout)
319 defer cancel()
320 req := pb.ONURequest{
321 SerialNumber: string(options.Args.OnuSn),
322 }
323 res, err := client.RestartDhcp(ctx, &req)
324
325 if err != nil {
326 log.Fatalf("Cannot restart DHCP for ONU %s: %v", options.Args.OnuSn, err)
Matteo Scandolo10f965c2019-09-24 10:40:46 -0700327 return err
328 }
329
330 fmt.Println(fmt.Sprintf("[Status: %d] %s", res.StatusCode, res.Message))
331
332 return nil
333}
334
Arjun E K57a7fcb2020-01-30 06:44:45 +0000335func (options *ONUIgmp) Execute(args []string) error {
336 client, conn := connect()
337 defer conn.Close()
338
339 ctx, cancel := context.WithTimeout(context.Background(), config.GlobalConfig.Grpc.Timeout)
340 defer cancel()
341
342 req := pb.ONURequest{
343 SerialNumber: string(options.Args.OnuSn),
344 }
345
346 var subActionVal pb.SubActionTypes
347 if string(options.Args.SubAction) == IgmpJoinKey {
348 subActionVal = pb.SubActionTypes_JOIN
349 } else if string(options.Args.SubAction) == IgmpLeaveKey {
350 subActionVal = pb.SubActionTypes_LEAVE
Anand S Katti09541352020-01-29 15:54:01 +0530351 } else if string(options.Args.SubAction) == IgmpJoinKeyV3 {
352 subActionVal = pb.SubActionTypes_JOINV3
353 }
Arjun E K57a7fcb2020-01-30 06:44:45 +0000354
355 igmpReq := pb.IgmpRequest{
356 OnuReq: &req,
357 SubActionVal: subActionVal,
Onur Kalinagac9f9faca2021-01-21 14:04:34 +0000358 GroupAddress: string(options.Args.GroupAddress),
Arjun E K57a7fcb2020-01-30 06:44:45 +0000359 }
360 res, err := client.GetONU(ctx, igmpReq.OnuReq)
361 if err != nil {
362 log.WithFields(log.Fields{
363 "SerialNumber": options.Args.OnuSn,
364 }).Errorf("Cannot not get details on ONU error: %v", err)
365 }
366 log.WithFields(log.Fields{
367 "SerialNumber": igmpReq.OnuReq.SerialNumber,
Onur Kalinagac9f9faca2021-01-21 14:04:34 +0000368 }).Debugf("ONU has identified : %s", res)
Arjun E K57a7fcb2020-01-30 06:44:45 +0000369
370 igmpRes, igmpErr := client.ChangeIgmpState(ctx, &igmpReq)
371 if igmpErr != nil {
372 log.WithFields(log.Fields{
373 "SubAction": options.Args.SubAction,
374 }).Errorf("Could not process Action: error: %v", igmpErr)
375 } else {
376 log.WithFields(log.Fields{
377 "SubAction": options.Args.SubAction,
378 }).Debugf("igmp state has been changed with response: %s",
379 igmpRes.Message)
380 }
381
382 return nil
383}
384
Pragya Arya8bdb4532020-03-02 17:08:09 +0530385func (options *ONUFlows) Execute(args []string) error {
386 client, conn := connect()
387 defer conn.Close()
388
389 ctx, cancel := context.WithTimeout(context.Background(), config.GlobalConfig.Grpc.Timeout)
390 defer cancel()
391 req := pb.ONURequest{
392 SerialNumber: string(options.Args.OnuSn),
393 }
394 res, err := client.GetFlows(ctx, &req)
395 if err != nil {
396 log.Errorf("Cannot get flows for ONU %s: %v", options.Args.OnuSn, err)
397 return err
398 }
399
400 if res.Flows == nil {
401 fmt.Println(fmt.Sprintf("ONU %s has no flows", options.Args.OnuSn))
402 return nil
403 }
404
405 flowHeader := []string{
406 "access_intf_id",
407 "onu_id",
408 "uni_id",
409 "flow_id",
410 "flow_type",
411 "eth_type",
412 "alloc_id",
413 "network_intf_id",
414 "gemport_id",
415 "classifier",
416 "action",
417 "priority",
418 "cookie",
419 "port_no",
420 }
421
422 tableFlow := tablewriter.NewWriter(os.Stdout)
423 tableFlow.SetRowLine(true)
424 fmt.Fprintf(os.Stdout, "ONU Flows:\n")
425 tableFlow.SetHeader(flowHeader)
426
427 for _, flow := range res.Flows {
428 flowInfo := []string{}
429 flowInfo = append(flowInfo,
430 strconv.Itoa(int(flow.AccessIntfId)),
431 strconv.Itoa(int(flow.OnuId)),
432 strconv.Itoa(int(flow.UniId)),
433 strconv.Itoa(int(flow.FlowId)),
434 flow.FlowType,
435 fmt.Sprintf("%x", flow.Classifier.EthType),
436 strconv.Itoa(int(flow.AllocId)),
437 strconv.Itoa(int(flow.NetworkIntfId)),
438 strconv.Itoa(int(flow.GemportId)),
439 flow.Classifier.String(),
440 flow.Action.String(),
441 strconv.Itoa(int(flow.Priority)),
442 strconv.Itoa(int(flow.Cookie)),
443 strconv.Itoa(int(flow.PortNo)),
444 )
445 tableFlow.Append(flowInfo)
446 }
447 tableFlow.Render()
448 tableFlow.SetNewLine("")
449 return nil
450}
451
Matteo Scandolo10f965c2019-09-24 10:40:46 -0700452func (onuSn *OnuSnString) Complete(match string) []flags.Completion {
453 client, conn := connect()
454 defer conn.Close()
455
456 ctx, cancel := context.WithTimeout(context.Background(), config.GlobalConfig.Grpc.Timeout)
457 defer cancel()
458
459 onus, err := client.GetONUs(ctx, &pb.Empty{})
460 if err != nil {
Matteo Scandolo86e8ce62019-10-11 12:03:10 -0700461 log.Fatalf("could not get ONUs: %v", err)
Matteo Scandolo10f965c2019-09-24 10:40:46 -0700462 return nil
463 }
464
465 list := make([]flags.Completion, 0)
466 for _, k := range onus.Items {
467 if strings.HasPrefix(k.SerialNumber, match) {
468 list = append(list, flags.Completion{Item: k.SerialNumber})
469 }
470 }
471
472 return list
473}
Anand S Katti09541352020-01-29 15:54:01 +0530474
Matteo Scandolo618a6582020-09-09 12:21:29 -0700475func (onuSn *IgmpSubAction) Complete(match string) []flags.Completion {
476 list := make([]flags.Completion, 0)
477 for _, k := range IgmpAllowedActions {
478 if strings.HasPrefix(k, match) {
479 list = append(list, flags.Completion{Item: k})
480 }
481 }
482 return list
483}
484
Anand S Katti09541352020-01-29 15:54:01 +0530485func (options *ONUTrafficSchedulers) Execute(args []string) error {
486 client, conn := connect()
487 defer conn.Close()
488
489 ctx, cancel := context.WithTimeout(context.Background(), config.GlobalConfig.Grpc.Timeout)
490 defer cancel()
491 req := pb.ONURequest{
492 SerialNumber: string(options.Args.OnuSn),
493 }
494 res, err := client.GetOnuTrafficSchedulers(ctx, &req)
495 if err != nil {
496 log.Fatalf("Cannot get traffic schedulers for ONU %s: %v", options.Args.OnuSn, err)
497 return err
498 }
499
500 if res.TraffSchedulers == nil {
501 log.Fatalf("Cannot get traffic schedulers for ONU: %s (unavailable)", options.Args.OnuSn)
502 return nil
503 }
504
505 SchedulerHeader := []string{"Direction",
506 "AllocId",
507 "Scheduler.Direction",
508 "Scheduler.AdditionalBw",
509 "Scheduler.Priority",
510 "Scheduler.Weight",
511 "Scheduler.SchedPolicy",
512 }
513
514 ShapingInfoHeader := []string{"InferredAdditionBwIndication",
515 "Cbs",
516 "Cir",
517 "Gir",
518 "Pbs",
519 "Pir",
520 }
521
522 SchedulerVals := []string{}
523 ShapingInfoVals := []string{}
524 for _, v := range res.TraffSchedulers.TrafficScheds {
525 SchedulerVals = append(SchedulerVals,
526 v.GetDirection().String(),
527 strconv.Itoa(int(v.GetAllocId())),
528 v.Scheduler.GetDirection().String(),
529 v.Scheduler.GetAdditionalBw().String(),
530 strconv.Itoa(int(v.Scheduler.GetPriority())),
531 strconv.Itoa(int(v.Scheduler.GetWeight())),
532 v.GetScheduler().GetSchedPolicy().String(),
533 )
534
535 ShapingInfoVals = append(ShapingInfoVals,
536 v.TrafficShapingInfo.GetAddBwInd().String(),
537 strconv.Itoa(int(v.TrafficShapingInfo.GetCbs())),
538 strconv.Itoa(int(v.TrafficShapingInfo.GetCir())),
539 strconv.Itoa(int(v.TrafficShapingInfo.GetGir())),
540 strconv.Itoa(int(v.TrafficShapingInfo.GetPbs())),
541 strconv.Itoa(int(v.TrafficShapingInfo.GetPir())),
542 )
543 }
544
545 fmt.Fprintf(os.Stdout, "OnuId: %d \n", int(res.TraffSchedulers.OnuId))
546 fmt.Fprintf(os.Stdout, "IntfId: %d \n", int(res.TraffSchedulers.IntfId))
547 fmt.Fprintf(os.Stdout, "UniId: %d \n", int(res.TraffSchedulers.UniId))
548 fmt.Fprintf(os.Stdout, "OnuPortNo: %d \n", int(res.TraffSchedulers.PortNo))
549
550 tableSched := tablewriter.NewWriter(os.Stdout)
551 tableSched.SetRowLine(true)
552 fmt.Fprintf(os.Stdout, "Traffic Schedulers Info:\n")
553 tableSched.SetHeader(SchedulerHeader)
554 tableSched.Append(SchedulerVals)
555 tableSched.Render()
556 tableSched.SetNewLine("")
557
558 tableShap := tablewriter.NewWriter(os.Stdout)
559 tableShap.SetRowLine(true)
560 fmt.Fprintf(os.Stdout, "Traffic Shaping Info:\n")
561 tableShap.SetHeader(ShapingInfoHeader)
562 tableShap.Append(ShapingInfoVals)
563 tableShap.Render()
564
565 return nil
566}