Fixing BUG in disable OLT device
Change-Id: I297f2056163262719c904defc3cfbc89c53ce306
diff --git a/README.md b/README.md
index 5e6cea5..6bd5eae 100644
--- a/README.md
+++ b/README.md
@@ -34,7 +34,7 @@
{
"state": "HEALTHY"
}
-(voltha) preprovision_olt -t openolt -H <BBSim Docker container IP>
+(voltha) preprovision_olt -t bbsimolt -H <BBSim Docker container IP>
success (device id = <deviceid>)
(voltha) enable
enabling <deviceid>
diff --git a/core/core_server.go b/core/core_server.go
index 7067b3f..be6b04a 100644
--- a/core/core_server.go
+++ b/core/core_server.go
@@ -54,6 +54,7 @@
VethEnv []string
TestFlag bool
Processes []string
+ EnableServer *openolt.Openolt_EnableIndicationServer
}
type Packet struct {
@@ -86,6 +87,7 @@
for intfid := nnni; intfid < npon+nnni; intfid++ {
s.Onumap[intfid] = device.CreateOnus(oltid, intfid, nonus, nnni)
}
+ s.EnableServer = new(openolt.Openolt_EnableIndicationServer)
return s
}
@@ -95,15 +97,7 @@
oltid := olt.ID
wg := &sync.WaitGroup{}
- // DEBUG
- log.Printf("pointer@activateOLT %p", s)
- log.Printf("Ioinfos:%v\n", s.Ioinfos)
- log.Printf("OLT Status:%v\n", s.Olt.OperState)
- log.Printf("ONUmap:%v\n", s.Onumap)
- log.Printf("VethEnv:%v\n", s.VethEnv)
- log.Printf("Processes:%v\n", s.Processes)
-
- if err := sendOltInd(stream, olt); err != nil {
+ if err := sendOltIndUp(stream, olt); err != nil {
return err
}
olt.OperState = "up"
@@ -296,12 +290,12 @@
ethtype := le.EthernetType
if ethtype == 0x888e {
log.Printf("Received upstream packet is EAPOL.")
- log.Println(unipkt.Pkt.Dump())
- log.Println(pkt.Dump())
+ //log.Println(unipkt.Pkt.Dump())
+ //log.Println(pkt.Dump())
} else if layerDHCP := pkt.Layer(layers.LayerTypeDHCPv4); layerDHCP != nil {
log.Printf("Received upstream packet is DHCP.")
- log.Println(unipkt.Pkt.Dump())
- log.Println(pkt.Dump())
+ //log.Println(unipkt.Pkt.Dump())
+ //log.Println(pkt.Dump())
} else {
continue
}
@@ -336,7 +330,6 @@
log.Println("Closed unichannel !")
close(nnichannel)
log.Println("Closed nnichannel !")
-
flag = true
return nil
}
@@ -346,7 +339,7 @@
}
func (s *Server) exeAAATest() error {
- log.Println("exeAAATest Start")
+ log.Println("exeAAATest starts to sleep....")
infos, err := s.getUniIoinfos("outside")
if err != nil {
return err
@@ -363,7 +356,7 @@
log.Println("exeAAATest thread receives close !")
return nil
case <- time.After(time.Second * time.Duration(s.AAAWait)):
- log.Println("timeout")
+ log.Println("exeAAATest Start")
err = setup.ActivateWPASups(univeths)
if err != nil {
return err
@@ -377,7 +370,7 @@
}
func (s *Server) exeDHCPTest() error {
- log.Println("exeDHCPTest Start")
+ log.Println("exeDHCPTest starts to sleep....")
info, err := s.identifyNniIoinfo("outside")
if err != nil {
@@ -406,7 +399,7 @@
log.Println("exeDHCPTest thread receives close !")
return nil
case <- time.After(time.Second * time.Duration(s.DhcpWait)):
- log.Println("timeout")
+ log.Println("exeDHCPTest Start")
err = setup.ActivateDHCPClients(univeths)
if err != nil {
return err
@@ -426,10 +419,10 @@
ethtype := pkt.EthernetType
if ethtype == 0x888e {
log.Printf("Received downstream packet is EAPOL.")
- log.Println(rawpkt.Dump())
+ //log.Println(rawpkt.Dump())
} else if layerDHCP := rawpkt.Layer(layers.LayerTypeDHCPv4); layerDHCP != nil {
log.Printf("Received downstream packet is DHCP.")
- log.Println(rawpkt.Dump())
+ //log.Println(rawpkt.Dump())
rawpkt, _, _ = PopVLAN(rawpkt)
rawpkt, _, _ = PopVLAN(rawpkt)
} else {
diff --git a/core/grpc_service.go b/core/grpc_service.go
index e647c9d..90bdf35 100644
--- a/core/grpc_service.go
+++ b/core/grpc_service.go
@@ -25,11 +25,16 @@
"google.golang.org/grpc"
"log"
"net"
+ "os/exec"
)
// gRPC Service
func (s *Server) DisableOlt(c context.Context, empty *openolt.Empty) (*openolt.Empty, error) {
log.Printf("OLT receives DisableOLT()\n")
+ if err := sendOltIndDown(*s.EnableServer); err != nil {
+ return new(openolt.Empty), err
+ }
+ log.Println("Successfuly sent OLT DOWN indication !")
return new(openolt.Empty), nil
}
@@ -134,15 +139,16 @@
func (s *Server) Reboot(c context.Context, empty *openolt.Empty) (*openolt.Empty, error) {
log.Printf("OLT %d receives Reboot ().\n", s.Olt.ID)
- log.Printf("pointer@Reboot %p", s)
// Initialize OLT & Env
if s.TestFlag == true{
- log.Println("Initialize by Reboot")
+ log.Println("Initialized by Reboot")
cleanUpVeths(s.VethEnv)
close(s.Endchan)
processes := s.Processes
log.Println("processes:", processes)
killProcesses(processes)
+ exec.Command("rm", "/var/run/dhcpd.pid").Run()
+ exec.Command("touch", "/var/run/dhcpd.pid").Run()
s.Initialize()
}
olt := s.Olt
@@ -159,6 +165,7 @@
defer func() {
s.gRPCserver.Stop()
}()
+ s.EnableServer = &stream
log.Printf("OLT receives EnableInd.\n")
if err := s.activateOLT(stream); err != nil {
log.Printf("Failed to activate OLT: %v\n", err)
diff --git a/core/openolt_service.go b/core/openolt_service.go
index ffded4d..dbb7644 100644
--- a/core/openolt_service.go
+++ b/core/openolt_service.go
@@ -22,10 +22,19 @@
"log"
)
-func sendOltInd(stream openolt.Openolt_EnableIndicationServer, olt *device.Olt) error {
+func sendOltIndUp(stream openolt.Openolt_EnableIndicationServer, olt *device.Olt) error {
data := &openolt.Indication_OltInd{OltInd: &openolt.OltIndication{OperState: "up"}}
if err := stream.Send(&openolt.Indication{Data: data}); err != nil {
- log.Printf("Failed to send OLT indication: %v\n", err)
+ log.Printf("Failed to send OLT UP indication: %v\n", err)
+ return err
+ }
+ return nil
+}
+
+func sendOltIndDown(stream openolt.Openolt_EnableIndicationServer) error {
+ data := &openolt.Indication_OltInd{OltInd: &openolt.OltIndication{OperState: "down"}}
+ if err := stream.Send(&openolt.Indication{Data: data}); err != nil {
+ log.Printf("Failed to send OLT DOWN indication: %v\n", err)
return err
}
return nil