Add support to restart EAPOL and DHCP for a specific UNI

Change-Id: Idacb94e6a9e91221f2f008ec9b5d63210d74b7ce
diff --git a/internal/bbsimctl/commands/onu.go b/internal/bbsimctl/commands/onu.go
index 4ae8841..f929f39 100644
--- a/internal/bbsimctl/commands/onu.go
+++ b/internal/bbsimctl/commands/onu.go
@@ -245,8 +245,9 @@
 
 	ctx, cancel := context.WithTimeout(context.Background(), config.GlobalConfig.Grpc.Timeout)
 	defer cancel()
-	req := pb.ONURequest{
-		SerialNumber: string(options.Args.OnuSn),
+	req := pb.UNIRequest{
+		OnuSerialNumber: string(options.Args.OnuSn),
+		UniID:           "",
 	}
 	res, err := client.RestartEapol(ctx, &req)
 
@@ -266,8 +267,9 @@
 
 	ctx, cancel := context.WithTimeout(context.Background(), config.GlobalConfig.Grpc.Timeout)
 	defer cancel()
-	req := pb.ONURequest{
-		SerialNumber: string(options.Args.OnuSn),
+	req := pb.UNIRequest{
+		OnuSerialNumber: string(options.Args.OnuSn),
+		UniID:           "",
 	}
 	res, err := client.RestartDhcp(ctx, &req)
 
diff --git a/internal/bbsimctl/commands/uni.go b/internal/bbsimctl/commands/uni.go
index 81f7c96..b025e72 100644
--- a/internal/bbsimctl/commands/uni.go
+++ b/internal/bbsimctl/commands/uni.go
@@ -19,6 +19,7 @@
 
 import (
 	"context"
+	"fmt"
 	"os"
 	"strconv"
 	"strings"
@@ -56,10 +57,26 @@
 	} `positional-args:"yes"`
 }
 
+type UNIEapolRestart struct {
+	Args struct {
+		OnuSn OnuSnString
+		UniId UniIdInt
+	} `positional-args:"yes" required:"yes"`
+}
+
+type UNIDhcpRestart struct {
+	Args struct {
+		OnuSn OnuSnString
+		UniId UniIdInt
+	} `positional-args:"yes" required:"yes"`
+}
+
 type UNIOptions struct {
-	List     UNIList     `command:"list"`
-	Get      UNIGet      `command:"get"`
-	Services UNIServices `command:"services"`
+	List         UNIList         `command:"list"`
+	Get          UNIGet          `command:"get"`
+	Services     UNIServices     `command:"services"`
+	RestartEapol UNIEapolRestart `command:"auth_restart"`
+	RestartDchp  UNIDhcpRestart  `command:"dhcp_restart"`
 }
 
 func RegisterUNICommands(parser *flags.Parser) {
@@ -142,6 +159,52 @@
 	return nil
 }
 
+func (options *UNIEapolRestart) Execute(args []string) error {
+	client, conn := connect()
+	defer conn.Close()
+
+	ctx, cancel := context.WithTimeout(context.Background(), config.GlobalConfig.Grpc.Timeout)
+	defer cancel()
+
+	req := pb.UNIRequest{
+		OnuSerialNumber: string(options.Args.OnuSn),
+		UniID:           string(options.Args.UniId),
+	}
+	res, err := client.RestartEapol(ctx, &req)
+
+	if err != nil {
+		log.Fatalf("Cannot restart EAPOL for ONU %s and UNI %s: %v", options.Args.OnuSn, options.Args.UniId, err)
+		return err
+	}
+
+	fmt.Println(fmt.Sprintf("[Status: %d] %s", res.StatusCode, res.Message))
+
+	return nil
+}
+
+func (options *UNIDhcpRestart) Execute(args []string) error {
+	client, conn := connect()
+	defer conn.Close()
+
+	ctx, cancel := context.WithTimeout(context.Background(), config.GlobalConfig.Grpc.Timeout)
+	defer cancel()
+
+	req := pb.UNIRequest{
+		OnuSerialNumber: string(options.Args.OnuSn),
+		UniID:           string(options.Args.UniId),
+	}
+	res, err := client.RestartDhcp(ctx, &req)
+
+	if err != nil {
+		log.Fatalf("Cannot restart DHCP for ONU %s and UNI %s: %v", options.Args.OnuSn, options.Args.UniId, err)
+		return err
+	}
+
+	fmt.Println(fmt.Sprintf("[Status: %d] %s", res.StatusCode, res.Message))
+
+	return nil
+}
+
 func (uniId *UniIdInt) Complete(match string) []flags.Completion {
 	client, conn := connect()
 	defer conn.Close()