[SEBA-843] Storing PortNo in the ONU Device struct so that it can be passed with the packetIndications

Change-Id: I28e0bf5721d11fc52d70c6072a6cf70586ba5f98
diff --git a/internal/bbsim/devices/nni.go b/internal/bbsim/devices/nni.go
index 05585fc..30104fc 100644
--- a/internal/bbsim/devices/nni.go
+++ b/internal/bbsim/devices/nni.go
@@ -34,6 +34,22 @@
 	dhcpServerIp = "182.21.0.128"
 )
 
+type Executor interface {
+	Command(name string, arg ...string) Runnable
+}
+
+type DefaultExecutor struct{}
+
+func (d DefaultExecutor) Command(name string, arg ...string) Runnable {
+	return exec.Command(name, arg...)
+}
+
+type Runnable interface {
+	Run() error
+}
+
+var executor = DefaultExecutor{}
+
 type NniPort struct {
 	// BBSIM Internals
 	ID uint32
@@ -51,7 +67,7 @@
 		}),
 		Type: "nni",
 	}
-	createNNIPair(olt)
+	createNNIPair(executor, olt)
 	return nniPort, nil
 }
 
@@ -89,21 +105,21 @@
 	return nil
 }
 
-// createNNIBridge will create a veth bridge to fake the connection between the NNI port
-// and something upstream, in this case a DHCP server.
-// It is also responsible to start the DHCP server itself
-func createNNIPair(olt *OltDevice) error {
+//createNNIBridge will create a veth bridge to fake the connection between the NNI port
+//and something upstream, in this case a DHCP server.
+//It is also responsible to start the DHCP server itself
+func createNNIPair(executor Executor, olt *OltDevice) error {
 
-	if err := exec.Command("ip", "link", "add", nniVeth, "type", "veth", "peer", "name", upstreamVeth).Run(); err != nil {
+	if err := executor.Command("ip", "link", "add", nniVeth, "type", "veth", "peer", "name", upstreamVeth).Run(); err != nil {
 		nniLogger.Errorf("Couldn't create veth pair between %s and %s", nniVeth, upstreamVeth)
 		return err
 	}
 
-	if err := setVethUp(nniVeth); err != nil {
+	if err := setVethUp(executor, nniVeth); err != nil {
 		return err
 	}
 
-	if err := setVethUp(upstreamVeth); err != nil {
+	if err := setVethUp(executor, upstreamVeth); err != nil {
 		return err
 	}
 
@@ -120,21 +136,21 @@
 }
 
 // setVethUp is responsible to activate a virtual interface
-func setVethUp(vethName string) error {
-	if err := exec.Command("ip", "link", "set", vethName, "up").Run(); err != nil {
+func setVethUp(executor Executor, vethName string) error {
+	if err := executor.Command("ip", "link", "set", vethName, "up").Run(); err != nil {
 		nniLogger.Errorf("Couldn't change interface %s state to up: %v", vethName, err)
 		return err
 	}
 	return nil
 }
 
-func startDHCPServer() error {
+var startDHCPServer = func() error {
 	if err := exec.Command("ip", "addr", "add", dhcpServerIp, "dev", upstreamVeth).Run(); err != nil {
 		nniLogger.Errorf("Couldn't assing ip %s to interface %s: %v", dhcpServerIp, upstreamVeth, err)
 		return err
 	}
 
-	if err := setVethUp(upstreamVeth); err != nil {
+	if err := setVethUp(executor, upstreamVeth); err != nil {
 		return err
 	}
 
@@ -168,7 +184,7 @@
 	return handle, nil
 }
 
-func listenOnVeth(vethName string) (chan *types.PacketMsg, error) {
+var listenOnVeth = func(vethName string) (chan *types.PacketMsg, error) {
 
 	handle, err := getVethHandler(vethName)
 	if err != nil {