Minor fixes & tweaks to improve error handing in preparation for BBSim REST API pull request.
Added comments to reduce golint warnings.
Main contributors: Pragya Arya, Vishesh Prasidh
Change-Id: I6f0b67a39dd0b8da0288306ac4f66098df53b18d
diff --git a/device/device_olt.go b/device/device_olt.go
index 618e668..daffcec 100644
--- a/device/device_olt.go
+++ b/device/device_olt.go
@@ -16,10 +16,14 @@
package device
-import "sync"
+import (
+ "strconv"
+ "sync"
+)
type DeviceState int
+// Device interface provides common methods for OLT and ONU devices
type Device interface {
Initialize()
UpdateIntState(intstate DeviceState)
@@ -32,6 +36,7 @@
Intfid uint32
}
+// Olt structure consists required fields for OLT
type Olt struct {
ID uint32
NumPonIntf uint32
@@ -65,6 +70,7 @@
OLT_ACTIVE // After PacketInDaemon Running
)
+// NewOlt creates and return new Olt object
func NewOlt(oltid uint32, npon uint32, nnni uint32) *Olt {
olt := Olt{}
olt.ID = oltid
@@ -73,6 +79,8 @@
olt.Name = "BBSIM OLT"
olt.InternalState = OLT_INACTIVE
olt.OperState = "up"
+ olt.Manufacture = "BBSIM"
+ olt.SerialNumber = "BBSIMOLT00" + strconv.FormatInt(int64(oltid), 10)
olt.Intfs = make([]intf, olt.NumPonIntf+olt.NumNniIntf)
olt.HeartbeatSignature = oltid
olt.mu = &sync.Mutex{}
@@ -89,6 +97,7 @@
return &olt
}
+// Initialize method initializes NNI and PON ports
func (olt *Olt) Initialize() {
olt.InternalState = OLT_INACTIVE
olt.OperState = "up"
@@ -104,16 +113,19 @@
}
}
+// GetIntState returns internal state of OLT
func (olt *Olt) GetIntState() DeviceState {
olt.mu.Lock()
defer olt.mu.Unlock()
return olt.InternalState
}
+// GetDevkey returns device key of OLT
func (olt *Olt) GetDevkey () Devkey {
return Devkey{ID: olt.ID}
}
+// UpdateIntState method updates OLT internal state
func (olt *Olt) UpdateIntState(intstate DeviceState) {
olt.mu.Lock()
defer olt.mu.Unlock()