SEBA-941 updated apis to  poweron/shutdown all ONUs in PON/OLT

Change-Id: I6923cbcc51a4391f70ff08d266c274e1f34ca3ca
diff --git a/internal/bbsimctl/commands/olt.go b/internal/bbsimctl/commands/olt.go
index 3ea004c..a16edef 100644
--- a/internal/bbsimctl/commands/olt.go
+++ b/internal/bbsimctl/commands/olt.go
@@ -51,15 +51,21 @@
 
 type OltFlows struct{}
 
+type OltPoweronAllOnus struct{}
+
+type OltShutdownAllOnus struct{}
+
 type oltOptions struct {
-	Get      OltGet          `command:"get"`
-	NNI      OltNNIs         `command:"nnis"`
-	PON      OltPONs         `command:"pons"`
-	Shutdown OltShutdown     `command:"shutdown"`
-	Poweron  OltPoweron      `command:"poweron"`
-	Reboot   OltReboot       `command:"reboot"`
-	Alarms   OltAlarmOptions `command:"alarms"`
-	Flows    OltFlows        `command:"flows"`
+	Get             OltGet             `command:"get"`
+	NNI             OltNNIs            `command:"nnis"`
+	PON             OltPONs            `command:"pons"`
+	Shutdown        OltShutdown        `command:"shutdown"`
+	Poweron         OltPoweron         `command:"poweron"`
+	Reboot          OltReboot          `command:"reboot"`
+	Alarms          OltAlarmOptions    `command:"alarms"`
+	Flows           OltFlows           `command:"flows"`
+	PoweronAllOnus  OltPoweronAllOnus  `command:"poweronAllONUs"`
+	ShutdownAllOnus OltShutdownAllOnus `command:"shutdownAllONUs"`
 }
 
 func RegisterOltCommands(parser *flags.Parser) {
@@ -243,3 +249,39 @@
 	tableFlow.SetNewLine("")
 	return nil
 }
+
+func (o *OltPoweronAllOnus) Execute(args []string) error {
+	client, conn := connect()
+	defer conn.Close()
+
+	ctx, cancel := context.WithTimeout(context.Background(), config.GlobalConfig.Grpc.Timeout)
+	defer cancel()
+
+	res, err := client.PoweronAllONUs(ctx, &pb.Empty{})
+
+	if err != nil {
+		log.Errorf("Cannot poweron all ONUs: %v", err)
+		return err
+	}
+
+	fmt.Println(fmt.Sprintf("[Status: %d] %s", res.StatusCode, res.Message))
+	return nil
+}
+
+func (o *OltShutdownAllOnus) Execute(args []string) error {
+	client, conn := connect()
+	defer conn.Close()
+
+	ctx, cancel := context.WithTimeout(context.Background(), config.GlobalConfig.Grpc.Timeout)
+	defer cancel()
+
+	res, err := client.ShutdownAllONUs(ctx, &pb.Empty{})
+
+	if err != nil {
+		log.Errorf("Cannot shutdown all ONUs: %v", err)
+		return err
+	}
+
+	fmt.Println(fmt.Sprintf("[Status: %d] %s", res.StatusCode, res.Message))
+	return nil
+}
diff --git a/internal/bbsimctl/commands/pon.go b/internal/bbsimctl/commands/pon.go
new file mode 100644
index 0000000..885fb75
--- /dev/null
+++ b/internal/bbsimctl/commands/pon.go
@@ -0,0 +1,91 @@
+/*
+ * Portions copyright 2019-present Open Networking Foundation
+ * Original copyright 2019-present Ciena Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package commands
+
+import (
+	"context"
+	"fmt"
+
+	"github.com/jessevdk/go-flags"
+	pb "github.com/opencord/bbsim/api/bbsim"
+	"github.com/opencord/bbsim/internal/bbsimctl/config"
+	log "github.com/sirupsen/logrus"
+)
+
+type PonPoweronAllOnus struct {
+	Args struct {
+		IntfID OltInterfaceID
+	} `positional-args:"yes" required:"yes"`
+}
+
+type PonShutdownAllOnus struct {
+	Args struct {
+		IntfID OltInterfaceID
+	} `positional-args:"yes" required:"yes"`
+}
+
+type PONOptions struct {
+	PoweronAllOnus  PonPoweronAllOnus  `command:"poweronAllONUs"`
+	ShutdownAllOnus PonShutdownAllOnus `command:"shutdownAllONUs"`
+}
+
+func RegisterPonCommands(parser *flags.Parser) {
+	parser.AddCommand("pon", "PON Commands", "Commands to query and manipulate the PON port", &PONOptions{})
+}
+
+func (pon *PonPoweronAllOnus) Execute(args []string) error {
+	client, conn := connect()
+	defer conn.Close()
+
+	ctx, cancel := context.WithTimeout(context.Background(), config.GlobalConfig.Grpc.Timeout)
+	defer cancel()
+
+	req := pb.PONRequest{
+		PonPortId: uint32(pon.Args.IntfID),
+	}
+
+	res, err := client.PoweronONUsOnPON(ctx, &req)
+	if err != nil {
+		log.Errorf("Cannot poweron all ONUs on PON port: %v", err)
+		return err
+	}
+
+	fmt.Println(fmt.Sprintf("[Status: %d] %s", res.StatusCode, res.Message))
+	return nil
+}
+
+func (pon *PonShutdownAllOnus) Execute(args []string) error {
+	client, conn := connect()
+	defer conn.Close()
+
+	ctx, cancel := context.WithTimeout(context.Background(), config.GlobalConfig.Grpc.Timeout)
+	defer cancel()
+
+	req := pb.PONRequest{
+		PonPortId: uint32(pon.Args.IntfID),
+	}
+
+	res, err := client.ShutdownONUsOnPON(ctx, &req)
+	if err != nil {
+		log.Errorf("Cannot shutdown all ONUs on PON port: %v", err)
+		return err
+	}
+
+	fmt.Println(fmt.Sprintf("[Status: %d] %s", res.StatusCode, res.Message))
+	return nil
+}