package control
import (
+ "encoding/json"
"fmt"
"gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
"strings"
e.SubscribeChannels()
}
+func (e *E2IfState) GetE2NodesJson() []byte {
+
+ e.mutex.Lock()
+ defer e.mutex.Unlock()
+
+ // Map contains something like this{"RAN_NAME_1":"RAN_NAME_1","RAN_NAME_11":"RAN_NAME_11","RAN_NAME_2":"RAN_NAME_2"}
+ var ranNameList []string
+ for _, ranName := range e.NbIdMap {
+ ranNameList = append(ranNameList, ranName)
+ }
+
+ e2NodesJson, err := json.Marshal(ranNameList)
+ if err != nil {
+ xapp.Logger.Error("GetE2Node() json.Marshal error: %v", err)
+ }
+ return e2NodesJson
+}
+
+func (e *E2IfState) GetAllE2Nodes() map[string]string {
+
+ e.mutex.Lock()
+ defer e.mutex.Unlock()
+ return e.NbIdMap
+}
+
func (e *E2IfState) NotificationCb(ch string, events ...string) {
xapp.Logger.Debug("SDL notification received from channel=%s, event=%v", ch, events[0])
return
}
- if strings.Contains(events[0], "_CONNECTED") {
+ if strings.Contains(events[0], "_CONNECTED") && !strings.Contains(events[0], "_CONNECTED_SETUP_FAILED") {
+ e.control.UpdateCounter(cE2StateChangedToUp)
nbId, err := ExtractNbiIdFromString(events[0])
if err != nil {
xapp.Logger.Error("NotificationCb CONNECTED len(nbId) == 0 ")
xapp.Logger.Debug("E2 CONNECTED. NbId=%s", nbId)
e.NbIdMap[nbId] = nbId
} else if strings.Contains(events[0], "_DISCONNECTED") {
+ e.control.UpdateCounter(cE2StateChangedToDown)
nbId, err := ExtractNbiIdFromString(events[0])
if err != nil {
xapp.Logger.Error("NotificationCb DISCONNECTED len(nbId) == 0 ")
if e.isNodeBActive(nbIdentity.InventoryName) == false {
if _, ok := e.NbIdMap[nbIdentity.InventoryName]; ok {
delete(e.NbIdMap, nbIdentity.InventoryName)
- e.control.UpdateCounter(cE2StateChangedToDown)
xapp.Logger.Debug("E2 connection DISCONNETED: %v", nbIdentity.InventoryName)
// Delete all subscriptions related to InventoryName/nbId
if _, ok := e.NbIdMap[nbIdentity.InventoryName]; !ok {
e.NbIdMap[nbIdentity.InventoryName] = nbIdentity.InventoryName
- e.control.UpdateCounter(cE2StateChangedToDown)
xapp.Logger.Debug("E2 connection CONNECTED: %v", nbIdentity.InventoryName)
}
}