[VOL-5483]fec_history

Change-Id: I4da83241fb22c6b8f4740a3978dd44e9048bc50a
Signed-off-by: Akash Reddy Kankanala <akash.kankanala@radisys.com>
diff --git a/VERSION b/VERSION
index f33bbfa..319bf4d 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.11.10
+1.11.11
diff --git a/internal/pkg/commands/devices.go b/internal/pkg/commands/devices.go
index 61bb758..eb65adb 100644
--- a/internal/pkg/commands/devices.go
+++ b/internal/pkg/commands/devices.go
@@ -171,6 +171,11 @@
  RxBytes:        {{.RxBytes}}
  TxPackets:      {{.TxPackets}}
  TxBytes:        {{.TxBytes}}{{end}}`
+	DEFAULT_ONU_FEC_HISTORY_FORMAT = `CorrectedBytes:         {{.CorrectedBytes}}
+CorrectedCodeWords:     {{.CorrectedCodeWords}}
+FecSeconds:             {{.FecSeconds}}
+TotalCodeWords:         {{.TotalCodeWords}}
+UncorrectableCodeWords: {{.UncorrectableCodeWords}}`
 
 	DEFAULT_ONU_DISTANCE_FORMAT          = `Distance`
 	DEFAULT_DEVICE_ALARMS_FORMAT         = "table{{ .ClassId }}\t{{.InstanceId}}\t{{.Name}}\t{{.Description}}"
@@ -578,6 +583,12 @@
 	} `positional-args:"yes"`
 }
 
+type GetOnuFecHistory struct {
+	ListOutputOptions
+	Args struct {
+		Id DeviceId `positional-arg-name:"DEVICE_ID" required:"yes"`
+	} `positional-args:"yes"`
+}
 type GetOnuDistance struct {
 	ListOutputOptions
 	Args struct {
@@ -688,6 +699,7 @@
 		NniStats                GetNniPortStats                       `command:"nni_statistics"`
 		OnuGEMStats             GetOnuGEMStats                        `command:"onu_gem_stats"`
 		OnuAllocGemStats        GetOnuAllocGemStatsFromOlt            `command:"onu_alloc_gem_from_olt"`
+		OnuFecHistory           GetOnuFecHistory                      `command:"onu_fec_history"`
 	} `command:"getextval"`
 	SetExtVal struct {
 		OffloadAppStatsSet SetOffloadApp `command:"set_offload_app"`
@@ -3109,6 +3121,47 @@
 
 }
 
+func (options *GetOnuFecHistory) Execute(args []string) error {
+	conn, err := NewConnection()
+	if err != nil {
+		return err
+	}
+	defer conn.Close()
+	client := extension.NewExtensionClient(conn)
+	singleGetValReq := extension.SingleGetValueRequest{
+		TargetId: string(options.Args.Id),
+		Request: &extension.GetValueRequest{
+			Request: &extension.GetValueRequest_FecHistory{
+				FecHistory: &extension.GetOnuFecHistory{},
+			},
+		},
+	}
+	ctx, cancel := context.WithTimeout(context.Background(), GlobalConfig.Current().Grpc.Timeout)
+	defer cancel()
+	rv, err := client.GetExtValue(ctx, &singleGetValReq)
+	if err != nil {
+		Error.Printf("Error getting value on device Id %s,err=%s\n", options.Args.Id, ErrorToString(err))
+		return err
+	}
+	if rv.Response.Status != extension.GetValueResponse_OK {
+		return fmt.Errorf("Failed to get onu FEC history stats from ONT %v", rv.Response.ErrReason.String())
+	}
+
+	outputFormat := CharReplacer.Replace(options.Format)
+	if outputFormat == "" {
+		outputFormat = GetCommandOptionWithDefault("device-get-onu-fec-History", "format", DEFAULT_ONU_FEC_HISTORY_FORMAT)
+	}
+	result := CommandResult{
+		Format:    format.Format(outputFormat),
+		OutputAs:  toOutputType(options.OutputAs),
+		NameLimit: options.NameLimit,
+		Data:      rv.GetResponse().GetFecHistory(),
+	}
+	GenerateOutput(&result)
+	return nil
+
+}
+
 func (options *GetOnuAllocGemStatsFromOlt) Execute(args []string) error {
 	conn, err := NewConnection()
 	if err != nil {