LF RNIB Adaptation
Change-Id: Ibfddb7688559c77803a5df025c5bbdbcf1ce2e8d
Signed-off-by: Mohamed Abukar <abukar.mohamed@nokia.com>
diff --git a/pkg/rnib/iSdlInstance.go b/pkg/rnib/iSdlInstance.go
new file mode 100755
index 0000000..2c7ee51
--- /dev/null
+++ b/pkg/rnib/iSdlInstance.go
@@ -0,0 +1,47 @@
+//
+// Copyright 2019 AT&T Intellectual Property
+// Copyright 2019 Nokia
+//
+// 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 writer
+
+/*
+ISdlInstance integrates (wraps) the functionality that sdlgo library provides
+*/
+type ISdlInstance interface {
+ SubscribeChannel(cb func(string, ...string), channels ...string) error
+ UnsubscribeChannel(channels ...string) error
+ Close() error
+ SetAndPublish(channelsAndEvents []string, pairs ...interface{}) error
+ Set(pairs ...interface{}) error
+ Get(keys []string) (map[string]interface{}, error)
+ SetIfAndPublish(channelsAndEvents []string, key string, oldData, newData interface{}) (bool, error)
+ SetIf(key string, oldData, newData interface{}) (bool, error)
+ SetIfNotExistsAndPublish(channelsAndEvents []string, key string, data interface{}) (bool, error)
+ SetIfNotExists(key string, data interface{}) (bool, error)
+ RemoveAndPublish(channelsAndEvents []string, keys []string) error
+ Remove(keys []string) error
+ RemoveIfAndPublish(channelsAndEvents []string, key string, data interface{}) (bool, error)
+ RemoveIf(key string, data interface{}) (bool, error)
+ GetAll() ([]string, error)
+ RemoveAll() error
+ RemoveAllAndPublish(channelsAndEvents []string) error
+ AddMember(group string, member ...interface{}) error
+ RemoveMember(group string, member ...interface{}) error
+ RemoveGroup(group string) error
+ GetMembers(group string) ([]string, error)
+ IsMember(group string, member interface{}) (bool, error)
+ GroupSize(group string) (int64, error)
+}
diff --git a/pkg/rnib/rNibWriter.go b/pkg/rnib/rNibWriter.go
new file mode 100755
index 0000000..cc8e49f
--- /dev/null
+++ b/pkg/rnib/rNibWriter.go
@@ -0,0 +1,181 @@
+//
+// Copyright 2019 AT&T Intellectual Property
+// Copyright 2019 Nokia
+//
+// 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 writer
+
+import (
+ "errors"
+ "fmt"
+ rnibcommon "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common"
+ rnibentities "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
+ "gerrit.o-ran-sc.org/r/ric-plt/sdlgo"
+ "github.com/golang/protobuf/proto"
+)
+
+var writerPool *rnibcommon.Pool
+
+type rNibWriterInstance struct {
+ sdl *ISdlInstance
+ namespace string
+}
+
+/*
+RNibWriter interface allows saving data to the redis BD
+*/
+type RNibWriter interface {
+ SaveNodeb(nbIdentity *rnibentities.NbIdentity, nb *rnibentities.NodebInfo) rnibcommon.IRNibError
+}
+
+/*
+Init initializes the infrastructure required for the RNibWriter instance
+*/
+func InitWriter(namespace string, poolSize int) {
+ initWriterPool(poolSize,
+ func() interface{} {
+ var sdlI ISdlInstance = sdlgo.NewSdlInstance(namespace, sdlgo.NewDatabase())
+ return &rNibWriterInstance{sdl: &sdlI, namespace: namespace}
+ },
+ func(obj interface{}) {
+ (*obj.(*rNibWriterInstance).sdl).Close()
+ })
+}
+
+/*
+InitPool initializes the writer's instances pool
+*/
+func initWriterPool(poolSize int, newObj func() interface{}, destroyObj func(interface{})) {
+ writerPool = rnibcommon.NewPool(poolSize, newObj, destroyObj)
+}
+
+/*
+GetRNibWriter returns RNibWriter instance from the pool
+*/
+func GetRNibWriter() RNibWriter {
+ return writerPool.Get().(RNibWriter)
+}
+
+/*
+SaveNodeb saves nodeB entity data in the redis DB according to the specified data model
+*/
+func (w *rNibWriterInstance) SaveNodeb(nbIdentity *rnibentities.NbIdentity, entity *rnibentities.NodebInfo) rnibcommon.IRNibError {
+
+ isNotEmptyIdentity := isNotEmpty(nbIdentity)
+
+ if isNotEmptyIdentity && entity.GetNodeType() == rnibentities.Node_UNKNOWN {
+ return rnibcommon.NewValidationError(errors.New(fmt.Sprintf("#rNibWriter.saveNodeB - Unknown responding node type, entity: %v", entity)))
+ }
+ defer writerPool.Put(w)
+ data, err := proto.Marshal(entity)
+ if err != nil {
+ return rnibcommon.NewInternalError(err)
+ }
+ var pairs []interface{}
+ key, rNibErr := rnibcommon.ValidateAndBuildNodeBNameKey(nbIdentity.InventoryName)
+ if rNibErr != nil {
+ return rNibErr
+ }
+ pairs = append(pairs, key, data)
+
+ if isNotEmptyIdentity {
+ key, rNibErr = rnibcommon.ValidateAndBuildNodeBIdKey(entity.GetNodeType().String(), nbIdentity.GlobalNbId.GetPlmnId(), nbIdentity.GlobalNbId.GetNbId())
+ if rNibErr != nil {
+ return rNibErr
+ }
+ pairs = append(pairs, key, data)
+ }
+
+ if entity.GetEnb() != nil {
+ pairs, rNibErr = appendEnbCells(nbIdentity, entity.GetEnb().GetServedCells(), pairs)
+ if rNibErr != nil {
+ return rNibErr
+ }
+ }
+ if entity.GetGnb() != nil {
+ pairs, rNibErr = appendGnbCells(nbIdentity, entity.GetGnb().GetServedNrCells(), pairs)
+ if rNibErr != nil {
+ return rNibErr
+ }
+ }
+ err = (*w.sdl).Set(pairs)
+ if err != nil {
+ return rnibcommon.NewInternalError(err)
+ }
+ if isNotEmptyIdentity {
+ nbIdData, err := proto.Marshal(nbIdentity)
+ if err != nil {
+ return rnibcommon.NewInternalError(err)
+ }
+ err = (*w.sdl).AddMember(entity.GetNodeType().String(), nbIdData)
+ if err != nil {
+ return rnibcommon.NewInternalError(err)
+ }
+ }
+ return nil
+}
+
+/*
+Close closes writer's pool
+*/
+func CloseWriter() {
+ writerPool.Close()
+}
+
+func appendEnbCells(nbIdentity *rnibentities.NbIdentity, cells []*rnibentities.ServedCellInfo, pairs []interface{}) ([]interface{}, rnibcommon.IRNibError) {
+ for _, cell := range cells {
+ cellEntity := rnibentities.Cell{Type: rnibentities.Cell_LTE_CELL, Cell: &rnibentities.Cell_ServedCellInfo{ServedCellInfo: cell}}
+ cellData, err := proto.Marshal(&cellEntity)
+ if err != nil {
+ return pairs, rnibcommon.NewInternalError(err)
+ }
+ key, rNibErr := rnibcommon.ValidateAndBuildCellIdKey(cell.GetCellId())
+ if rNibErr != nil {
+ return pairs, rNibErr
+ }
+ pairs = append(pairs, key, cellData)
+ key, rNibErr = rnibcommon.ValidateAndBuildCellNamePciKey(nbIdentity.InventoryName, cell.GetPci())
+ if rNibErr != nil {
+ return pairs, rNibErr
+ }
+ pairs = append(pairs, key, cellData)
+ }
+ return pairs, nil
+}
+
+func appendGnbCells(nbIdentity *rnibentities.NbIdentity, cells []*rnibentities.ServedNRCell, pairs []interface{}) ([]interface{}, rnibcommon.IRNibError) {
+ for _, cell := range cells {
+ cellEntity := rnibentities.Cell{Type: rnibentities.Cell_NR_CELL, Cell: &rnibentities.Cell_ServedNrCell{ServedNrCell: cell}}
+ cellData, err := proto.Marshal(&cellEntity)
+ if err != nil {
+ return pairs, rnibcommon.NewInternalError(err)
+ }
+ key, rNibErr := rnibcommon.ValidateAndBuildNrCellIdKey(cell.GetServedNrCellInformation().GetCellId())
+ if rNibErr != nil {
+ return pairs, rNibErr
+ }
+ pairs = append(pairs, key, cellData)
+ key, rNibErr = rnibcommon.ValidateAndBuildCellNamePciKey(nbIdentity.InventoryName, cell.GetServedNrCellInformation().GetNrPci())
+ if rNibErr != nil {
+ return pairs, rNibErr
+ }
+ pairs = append(pairs, key, cellData)
+ }
+ return pairs, nil
+}
+
+func isNotEmpty(nbIdentity *rnibentities.NbIdentity) bool {
+ return nbIdentity.GlobalNbId != nil && nbIdentity.GlobalNbId.PlmnId != "" && nbIdentity.GlobalNbId.NbId != ""
+}
diff --git a/pkg/xapp/config.go b/pkg/xapp/config.go
index 647b3eb..0493059 100755
--- a/pkg/xapp/config.go
+++ b/pkg/xapp/config.go
@@ -80,3 +80,7 @@
func (*Configurator) GetInt(key string) int {
return viper.GetInt(key)
}
+
+func (*Configurator) GetBool(key string) bool {
+ return viper.GetBool(key)
+}
diff --git a/pkg/xapp/db.go b/pkg/xapp/db.go
index 542c755..779e2cd 100755
--- a/pkg/xapp/db.go
+++ b/pkg/xapp/db.go
@@ -20,7 +20,14 @@
package xapp
import (
+ rnibcommon "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common"
+ rnibentities "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
+ rnibreader "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader"
sdl "gerrit.o-ran-sc.org/r/ric-plt/sdlgo"
+ uenibprotobuf "gerrit.o-ran-sc.org/r/ric-plt/ue-nib/uernibprotobuf"
+ uenibreader "gerrit.o-ran-sc.org/r/ric-plt/ue-nib/uernibreader"
+ uenibwriter "gerrit.o-ran-sc.org/r/ric-plt/ue-nib/uernibwriter"
+ rnibwriter "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/rnib"
"sync"
"time"
)
@@ -40,8 +47,44 @@
ready bool
}
+// Alias
+type EventCategory = uenibreader.EventCategory
+type EventCallback = uenibreader.EventCallback
+type MeasResultNR = uenibprotobuf.MeasResultNR
+type MeasQuantityResults = uenibprotobuf.MeasResultNR_MeasQuantityResults
+type MeasResultServMO = uenibprotobuf.MeasResults_MeasResultServMO
+type MeasResults = uenibprotobuf.MeasResults
+
+type UENIBClient struct {
+ reader *uenibreader.Reader
+ writer *uenibwriter.Writer
+}
+
+// Alias
+type RNIBNodeType = rnibentities.Node_Type
+type RNIBGlobalNbId = rnibentities.GlobalNbId
+type RNIBNodebInfo = rnibentities.NodebInfo
+type RNIBIRNibError = rnibcommon.IRNibError
+type RNIBCells = rnibentities.Cells
+type RNIBNbIdentity = rnibentities.NbIdentity
+type RNIBCellType = rnibentities.Cell_Type
+type RNIBCell = rnibentities.Cell
+type RNIBEnb = rnibentities.Enb
+type RNIBGnb = rnibentities.Gnb
+
+const RNIBNodeENB = rnibentities.Node_ENB
+const RNIBNodeGNB = rnibentities.Node_GNB
+
+type RNIBServedCellInfo = rnibentities.ServedCellInfo
+type RNIBNodebInfoEnb = rnibentities.NodebInfo_Enb
+type RNIBNodebInfoGnb = rnibentities.NodebInfo_Gnb
+type RNIBServedNRCell = rnibentities.ServedNRCell
+type RNIBServedNRCellInformation = rnibentities.ServedNRCellInformation
+type RNIBNrNeighbourInformation = rnibentities.NrNeighbourInformation
+
type RNIBClient struct {
- db *sdl.SdlInstance
+ reader rnibreader.RNibReader
+ writer rnibwriter.RNibWriter
}
// NewSDLClient returns a new SDLClient.
@@ -134,39 +177,74 @@
return
}
-// To be removed ...
+func NewUENIBClient() *UENIBClient {
+ return &UENIBClient{
+ reader: uenibreader.NewReader(),
+ writer: uenibwriter.NewWriter(),
+ }
+}
+
+func (u *UENIBClient) StoreUeMeasurement(gNbId string, gNbUeX2ApId string, data *uenibprotobuf.MeasResults) error {
+ return u.writer.UpdateUeMeasurement(gNbId, gNbUeX2ApId, data)
+}
+
+func (u *UENIBClient) CreateUeContext(gNbId string, gNbUeX2ApId string) error {
+ return u.writer.UeContextAddComplete(gNbId, gNbUeX2ApId)
+}
+
+func (u *UENIBClient) ReleaseUeContext(gNbId string, gNbUeX2ApId string) error {
+ return u.writer.RemoveUeContext(gNbId, gNbUeX2ApId)
+}
+
+func (u *UENIBClient) ReadUeMeasurement(gNbId string, gNbUeX2ApId string) (*uenibprotobuf.MeasResults, error) {
+ return u.reader.GetUeMeasurement(gNbId, gNbUeX2ApId)
+}
+
+func (u *UENIBClient) SubscribeEvents(gNbIDs []string, eventCategories []EventCategory, cb EventCallback) error {
+ return u.reader.SubscribeEvents(gNbIDs, eventCategories, cb)
+}
+
func NewRNIBClient(ns string) *RNIBClient {
+ rnibreader.Init("rnib", 1)
+ rnibwriter.InitWriter("rnib", 1)
return &RNIBClient{
- db: sdl.NewSdlInstance(ns, sdl.NewDatabase()),
+ reader: nil,
+ writer: nil,
}
}
-func (r *RNIBClient) GetgNBList() (values map[string]interface{}, err error) {
- keys, err := r.db.GetAll()
- if err == nil {
- values = make(map[string]interface{})
- for _, key := range keys {
- v, err := r.db.Get([]string{key})
- if err == nil {
- values[key] = v[key]
- }
- }
- }
- return
+func (r *RNIBClient) GetNodeb(invName string) (*RNIBNodebInfo, RNIBIRNibError) {
+ return rnibreader.GetRNibReader().GetNodeb(invName)
}
-func (r *RNIBClient) GetNRCellList(key string) (value map[string]interface{}, err error) {
- return r.db.Get([]string{key})
+func (r *RNIBClient) GetNodebByGlobalNbId(t RNIBNodeType, gid *RNIBGlobalNbId) (*RNIBNodebInfo, RNIBIRNibError) {
+ return rnibreader.GetRNibReader().GetNodebByGlobalNbId(t, gid)
}
-func (r *RNIBClient) GetUE(key1, key2 string) (value map[string]interface{}, err error) {
- return r.db.Get([]string{key1 + key2})
+func (r *RNIBClient) GetCellList(invName string) (*RNIBCells, RNIBIRNibError) {
+ return rnibreader.GetRNibReader().GetCellList(invName)
}
-func (r *RNIBClient) Store(key string, value interface{}) (err error) {
- return r.db.Set(key, value)
+func (r *RNIBClient) GetListGnbIds() (*[]*RNIBNbIdentity, RNIBIRNibError) {
+ return rnibreader.GetRNibReader().GetListGnbIds()
}
-func (r *RNIBClient) Clear() {
- r.db.RemoveAll()
+func (r *RNIBClient) GetListEnbIds() (*[]*RNIBNbIdentity, RNIBIRNibError) {
+ return rnibreader.GetRNibReader().GetListEnbIds()
+}
+
+func (r *RNIBClient) GetCountGnbList() (int, RNIBIRNibError) {
+ return rnibreader.GetRNibReader().GetCountGnbList()
+}
+
+func (r *RNIBClient) GetCell(invName string, pci uint32) (*RNIBCell, RNIBIRNibError) {
+ return rnibreader.GetRNibReader().GetCell(invName, pci)
+}
+
+func (r *RNIBClient) GetCellById(cellType RNIBCellType, cellId string) (*RNIBCell, RNIBIRNibError) {
+ return rnibreader.GetRNibReader().GetCellById(cellType, cellId)
+}
+
+func (r *RNIBClient) SaveNodeb(nbIdentity *RNIBNbIdentity, entity *RNIBNodebInfo) RNIBIRNibError {
+ return rnibwriter.GetRNibWriter().SaveNodeb(nbIdentity, entity)
}
diff --git a/pkg/xapp/logger.go b/pkg/xapp/logger.go
index 484df2c..ff6e52e 100755
--- a/pkg/xapp/logger.go
+++ b/pkg/xapp/logger.go
@@ -21,6 +21,7 @@
import (
mdclog "gerrit.o-ran-sc.org/r/com/golog"
+ "time"
)
type Log struct {
@@ -43,17 +44,21 @@
}
func (l *Log) Error(pattern string, args ...interface{}) {
+ l.SetMdc("time", time.Now().Format("2019-01-02 15:04:05"))
l.logger.Error(pattern, args...)
}
func (l *Log) Warn(pattern string, args ...interface{}) {
+ l.SetMdc("time", time.Now().Format("2019-01-02 15:04:05"))
l.logger.Warning(pattern, args...)
}
func (l *Log) Info(pattern string, args ...interface{}) {
+ l.SetMdc("time", time.Now().Format("2019-01-02 15:04:05"))
l.logger.Info(pattern, args...)
}
func (l *Log) Debug(pattern string, args ...interface{}) {
+ l.SetMdc("time", time.Now().Format("2019-01-02 15:04:05"))
l.logger.Debug(pattern, args...)
}
diff --git a/pkg/xapp/mtypes.go b/pkg/xapp/mtypes.go
index 2965e1e..82f3466 100755
--- a/pkg/xapp/mtypes.go
+++ b/pkg/xapp/mtypes.go
@@ -67,89 +67,88 @@
"DC_ADM_INT_CONTROL_ACK": C.DC_ADM_INT_CONTROL_ACK,
}
-
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
const (
- RIC_SUB_REQ = C.RIC_SUB_REQ
- RIC_SUB_RESP = C.RIC_SUB_RESP
- RIC_SUB_FAILURE = C.RIC_SUB_FAILURE
- RIC_SUB_DEL_REQ = C.RIC_SUB_DEL_REQ
- RIC_SUB_DEL_RESP = C.RIC_SUB_DEL_RESP
- RIC_SUB_DEL_FAILURE = C.RIC_SUB_DEL_FAILURE
- RIC_SERVICE_UPDATE = C.RIC_SERVICE_UPDATE
- RIC_SERVICE_UPDATE_ACK = C.RIC_SERVICE_UPDATE_ACK
- RIC_SERVICE_UPDATE_FAILURE = C.RIC_SERVICE_UPDATE_FAILURE
- RIC_CONTROL_REQ = C.RIC_CONTROL_REQ
- RIC_CONTROL_ACK = C.RIC_CONTROL_ACK
- RIC_CONTROL_FAILURE = C.RIC_CONTROL_FAILURE
- RIC_INDICATION = C.RIC_INDICATION
- RIC_SERVICE_QUERY = C.RIC_SERVICE_QUERY
- RIC_X2_SETUP_REQ = C.RIC_X2_SETUP_REQ
- RIC_X2_SETUP_RESP = C.RIC_X2_SETUP_RESP
- RIC_X2_SETUP_FAILURE = C.RIC_X2_SETUP_FAILURE
- RIC_X2_RESET = C.RIC_X2_RESET
- RIC_X2_RESET_RESP = C.RIC_X2_RESET_RESP
- RIC_ENDC_X2_SETUP_REQ = C.RIC_ENDC_X2_SETUP_REQ
- RIC_ENDC_X2_SETUP_RESP = C.RIC_ENDC_X2_SETUP_RESP
- RIC_ENDC_X2_SETUP_FAILURE = C.RIC_ENDC_X2_SETUP_FAILURE
- RIC_ENDC_CONF_UPDATE = C.RIC_ENDC_CONF_UPDATE
- RIC_ENDC_CONF_UPDATE_ACK = C.RIC_ENDC_CONF_UPDATE_ACK
+ RIC_SUB_REQ = C.RIC_SUB_REQ
+ RIC_SUB_RESP = C.RIC_SUB_RESP
+ RIC_SUB_FAILURE = C.RIC_SUB_FAILURE
+ RIC_SUB_DEL_REQ = C.RIC_SUB_DEL_REQ
+ RIC_SUB_DEL_RESP = C.RIC_SUB_DEL_RESP
+ RIC_SUB_DEL_FAILURE = C.RIC_SUB_DEL_FAILURE
+ RIC_SERVICE_UPDATE = C.RIC_SERVICE_UPDATE
+ RIC_SERVICE_UPDATE_ACK = C.RIC_SERVICE_UPDATE_ACK
+ RIC_SERVICE_UPDATE_FAILURE = C.RIC_SERVICE_UPDATE_FAILURE
+ RIC_CONTROL_REQ = C.RIC_CONTROL_REQ
+ RIC_CONTROL_ACK = C.RIC_CONTROL_ACK
+ RIC_CONTROL_FAILURE = C.RIC_CONTROL_FAILURE
+ RIC_INDICATION = C.RIC_INDICATION
+ RIC_SERVICE_QUERY = C.RIC_SERVICE_QUERY
+ RIC_X2_SETUP_REQ = C.RIC_X2_SETUP_REQ
+ RIC_X2_SETUP_RESP = C.RIC_X2_SETUP_RESP
+ RIC_X2_SETUP_FAILURE = C.RIC_X2_SETUP_FAILURE
+ RIC_X2_RESET = C.RIC_X2_RESET
+ RIC_X2_RESET_RESP = C.RIC_X2_RESET_RESP
+ RIC_ENDC_X2_SETUP_REQ = C.RIC_ENDC_X2_SETUP_REQ
+ RIC_ENDC_X2_SETUP_RESP = C.RIC_ENDC_X2_SETUP_RESP
+ RIC_ENDC_X2_SETUP_FAILURE = C.RIC_ENDC_X2_SETUP_FAILURE
+ RIC_ENDC_CONF_UPDATE = C.RIC_ENDC_CONF_UPDATE
+ RIC_ENDC_CONF_UPDATE_ACK = C.RIC_ENDC_CONF_UPDATE_ACK
RIC_ENDC_CONF_UPDATE_FAILURE = C.RIC_ENDC_CONF_UPDATE_FAILURE
- RIC_RES_STATUS_REQ = C.RIC_RES_STATUS_REQ
- RIC_RES_STATUS_RESP = C.RIC_RES_STATUS_RESP
- RIC_RES_STATUS_FAILURE = C.RIC_RES_STATUS_FAILURE
- RIC_ENB_CONF_UPDATE = C.RIC_ENB_CONF_UPDATE
- RIC_ENB_CONF_UPDATE_ACK = C.RIC_ENB_CONF_UPDATE_ACK
- RIC_ENB_CONF_UPDATE_FAILURE = C.RIC_ENB_CONF_UPDATE_FAILURE
- RIC_ENB_LOAD_INFORMATION = C.RIC_ENB_LOAD_INFORMATION
- RIC_GNB_STATUS_INDICATION = C.RIC_GNB_STATUS_INDICATION
- RIC_RESOURCE_STATUS_UPDATE = C.RIC_RESOURCE_STATUS_UPDATE
- RIC_ERROR_INDICATION = C.RIC_ERROR_INDICATION
- DC_ADM_INT_CONTROL = C.DC_ADM_INT_CONTROL
- DC_ADM_INT_CONTROL_ACK = C.DC_ADM_INT_CONTROL_ACK
+ RIC_RES_STATUS_REQ = C.RIC_RES_STATUS_REQ
+ RIC_RES_STATUS_RESP = C.RIC_RES_STATUS_RESP
+ RIC_RES_STATUS_FAILURE = C.RIC_RES_STATUS_FAILURE
+ RIC_ENB_CONF_UPDATE = C.RIC_ENB_CONF_UPDATE
+ RIC_ENB_CONF_UPDATE_ACK = C.RIC_ENB_CONF_UPDATE_ACK
+ RIC_ENB_CONF_UPDATE_FAILURE = C.RIC_ENB_CONF_UPDATE_FAILURE
+ RIC_ENB_LOAD_INFORMATION = C.RIC_ENB_LOAD_INFORMATION
+ RIC_GNB_STATUS_INDICATION = C.RIC_GNB_STATUS_INDICATION
+ RIC_RESOURCE_STATUS_UPDATE = C.RIC_RESOURCE_STATUS_UPDATE
+ RIC_ERROR_INDICATION = C.RIC_ERROR_INDICATION
+ DC_ADM_INT_CONTROL = C.DC_ADM_INT_CONTROL
+ DC_ADM_INT_CONTROL_ACK = C.DC_ADM_INT_CONTROL_ACK
)
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
var RicMessageTypeToName = map[int]string{
- RIC_SUB_REQ: "RIC SUBSCRIPTION REQUEST",
- RIC_SUB_RESP: "RIC SUBSCRIPTION RESPONSE",
- RIC_SUB_FAILURE: "RIC SUBSCRIPTION FAILURE",
- RIC_SUB_DEL_REQ: "RIC SUBSCRIPTION DELETE REQUEST",
- RIC_SUB_DEL_RESP: "RIC SUBSCRIPTION DELETE RESPONSE",
- RIC_SUB_DEL_FAILURE: "RIC SUBSCRIPTION DELETE FAILURE",
- RIC_SERVICE_UPDATE: "RIC SERVICE UPDATE",
- RIC_SERVICE_UPDATE_ACK: "RIC SERVICE UPDATE ACKNOWLEDGE",
- RIC_SERVICE_UPDATE_FAILURE: "RIC SERVICE UPDATE FAILURE",
- RIC_CONTROL_REQ: "RIC CONTROL REQUEST",
- RIC_CONTROL_ACK: "RIC CONTROL ACKNOWLEDGE",
- RIC_CONTROL_FAILURE: "RIC CONTROL FAILURE",
- RIC_INDICATION: "RIC INDICATION",
- RIC_SERVICE_QUERY: "RIC SERVICE QUERY",
- RIC_X2_SETUP_REQ: "RIC X2 SETUP REQUEST",
- RIC_X2_SETUP_RESP: "RIC X2 SETUP RESPONSE",
- RIC_X2_SETUP_FAILURE: "RIC X2 SETUP FAILURE",
- RIC_X2_RESET: "RIC X2 RESET REQUEST",
- RIC_X2_RESET_RESP: "RIC X2 RESET RESPONSE",
- RIC_ENDC_X2_SETUP_REQ: "RIC EN-DC X2 SETUP REQUEST",
- RIC_ENDC_X2_SETUP_RESP: "RIC EN-DC X2 SETUP RESPONSE",
- RIC_ENDC_X2_SETUP_FAILURE: "RIC EN-DC X2 SETUP FAILURE",
- RIC_ENDC_CONF_UPDATE: "RIC EN-DC CONFIGURATION UPDATE",
- RIC_ENDC_CONF_UPDATE_ACK: "RIC EN-DC CONFIGURATION UPDATE ACKNOWLEDGE",
- RIC_ENDC_CONF_UPDATE_FAILURE:"RIC EN-DC CONFIGURATION UPDATE FAILURE",
- RIC_RES_STATUS_REQ: "RIC RESOURCE STATUS REQUEST",
- RIC_RES_STATUS_RESP: "RIC RESOURCE STATUS RESPONSE",
- RIC_RES_STATUS_FAILURE: "RIC RESOURCE STATUS FAILURE",
- RIC_ENB_CONF_UPDATE: "RIC ENB CONFIGURATION UPDATE",
- RIC_ENB_CONF_UPDATE_ACK: "RIC ENB CONFIGURATION UPDATE ACKNOWLEDGE",
- RIC_ENB_CONF_UPDATE_FAILURE: "RIC ENB CONFIGURATION UPDATE FAILURE",
- RIC_ENB_LOAD_INFORMATION: "RIC ENB LOAD INFORMATION",
- RIC_GNB_STATUS_INDICATION: "RIC GNB STATUS INDICATION",
- RIC_RESOURCE_STATUS_UPDATE: "RIC RESOURCE STATUS UPDATE",
- RIC_ERROR_INDICATION: "RIC ERROR INDICATION",
- DC_ADM_INT_CONTROL: "DC ADMISSION INTERVAL CONTROL",
- DC_ADM_INT_CONTROL_ACK: "DC ADMISSION INTERVAL CONTROL ACK",
+ RIC_SUB_REQ: "RIC SUBSCRIPTION REQUEST",
+ RIC_SUB_RESP: "RIC SUBSCRIPTION RESPONSE",
+ RIC_SUB_FAILURE: "RIC SUBSCRIPTION FAILURE",
+ RIC_SUB_DEL_REQ: "RIC SUBSCRIPTION DELETE REQUEST",
+ RIC_SUB_DEL_RESP: "RIC SUBSCRIPTION DELETE RESPONSE",
+ RIC_SUB_DEL_FAILURE: "RIC SUBSCRIPTION DELETE FAILURE",
+ RIC_SERVICE_UPDATE: "RIC SERVICE UPDATE",
+ RIC_SERVICE_UPDATE_ACK: "RIC SERVICE UPDATE ACKNOWLEDGE",
+ RIC_SERVICE_UPDATE_FAILURE: "RIC SERVICE UPDATE FAILURE",
+ RIC_CONTROL_REQ: "RIC CONTROL REQUEST",
+ RIC_CONTROL_ACK: "RIC CONTROL ACKNOWLEDGE",
+ RIC_CONTROL_FAILURE: "RIC CONTROL FAILURE",
+ RIC_INDICATION: "RIC INDICATION",
+ RIC_SERVICE_QUERY: "RIC SERVICE QUERY",
+ RIC_X2_SETUP_REQ: "RIC X2 SETUP REQUEST",
+ RIC_X2_SETUP_RESP: "RIC X2 SETUP RESPONSE",
+ RIC_X2_SETUP_FAILURE: "RIC X2 SETUP FAILURE",
+ RIC_X2_RESET: "RIC X2 RESET REQUEST",
+ RIC_X2_RESET_RESP: "RIC X2 RESET RESPONSE",
+ RIC_ENDC_X2_SETUP_REQ: "RIC EN-DC X2 SETUP REQUEST",
+ RIC_ENDC_X2_SETUP_RESP: "RIC EN-DC X2 SETUP RESPONSE",
+ RIC_ENDC_X2_SETUP_FAILURE: "RIC EN-DC X2 SETUP FAILURE",
+ RIC_ENDC_CONF_UPDATE: "RIC EN-DC CONFIGURATION UPDATE",
+ RIC_ENDC_CONF_UPDATE_ACK: "RIC EN-DC CONFIGURATION UPDATE ACKNOWLEDGE",
+ RIC_ENDC_CONF_UPDATE_FAILURE: "RIC EN-DC CONFIGURATION UPDATE FAILURE",
+ RIC_RES_STATUS_REQ: "RIC RESOURCE STATUS REQUEST",
+ RIC_RES_STATUS_RESP: "RIC RESOURCE STATUS RESPONSE",
+ RIC_RES_STATUS_FAILURE: "RIC RESOURCE STATUS FAILURE",
+ RIC_ENB_CONF_UPDATE: "RIC ENB CONFIGURATION UPDATE",
+ RIC_ENB_CONF_UPDATE_ACK: "RIC ENB CONFIGURATION UPDATE ACKNOWLEDGE",
+ RIC_ENB_CONF_UPDATE_FAILURE: "RIC ENB CONFIGURATION UPDATE FAILURE",
+ RIC_ENB_LOAD_INFORMATION: "RIC ENB LOAD INFORMATION",
+ RIC_GNB_STATUS_INDICATION: "RIC GNB STATUS INDICATION",
+ RIC_RESOURCE_STATUS_UPDATE: "RIC RESOURCE STATUS UPDATE",
+ RIC_ERROR_INDICATION: "RIC ERROR INDICATION",
+ DC_ADM_INT_CONTROL: "DC ADMISSION INTERVAL CONTROL",
+ DC_ADM_INT_CONTROL_ACK: "DC ADMISSION INTERVAL CONTROL ACK",
}
diff --git a/pkg/xapp/xapp.go b/pkg/xapp/xapp.go
index 1fd7ad6..69d2964 100755
--- a/pkg/xapp/xapp.go
+++ b/pkg/xapp/xapp.go
@@ -31,6 +31,7 @@
// XApp is an application instance
Rmr *RMRClient
Sdl *SDLClient
+ UeNib *UENIBClient
Rnib *RNIBClient
Resource *Router
Metric *Metrics
@@ -55,6 +56,7 @@
Config = Configurator{}
Metric = NewMetrics(viper.GetString("metrics.url"), viper.GetString("metrics.namespace"), Resource.router)
Rmr = NewRMRClient()
+ UeNib = NewUENIBClient()
if viper.IsSet("db.namespaces") {
namespaces := viper.GetStringSlice("db.namespaces")
diff --git a/pkg/xapp/xapp_test.go b/pkg/xapp/xapp_test.go
index 06345af..84a910f 100755
--- a/pkg/xapp/xapp_test.go
+++ b/pkg/xapp/xapp_test.go
@@ -32,7 +32,7 @@
type Consumer struct {
}
-func (m Consumer) Consume(mtype, sid, len int, payload []byte) (err error) {
+func (m Consumer) Consume(mtype, sid int, payload []byte, meid *RMRMeid) (err error) {
Sdl.Store("myKey", payload)
return nil
}
@@ -100,7 +100,7 @@
func TestMessagesReceivedSuccessfully(t *testing.T) {
for i := 0; i < 100; i++ {
- Rmr.Send(10004, 1111, 100, []byte{1, 2, 3, 4, 5, 6})
+ Rmr.Send(10004, 1111, []byte{1, 2, 3, 4, 5, 6}, &RMRMeid{PlmnID: "1234", EnbID: "7788"})
}
// Allow time to process the messages
@@ -132,16 +132,6 @@
}
}
-func TestGetgNBList(t *testing.T) {
- Rnib.Store("Kiikale", "Hello")
- Rnib.Store("mykey", "myval")
-
- v, _ := Rnib.GetgNBList()
- if v["Kiikale"] != "Hello" || v["mykey"] != "myval" {
- t.Errorf("Error: GetgNBList failed!")
- }
-}
-
func TestSubscribeChannels(t *testing.T) {
var NotificationCb = func(ch string, events ...string) {
if ch != "channel1" {
@@ -166,7 +156,7 @@
}
name := Rmr.GetRicMessageName(12010)
- if name != "RIC_SUB_REQ" {
+ if name != "RIC_SUB_REQ" {
t.Errorf("Error: GetRicMessageName failed: name=%s", name)
}
}
@@ -178,14 +168,13 @@
}
name := Rmr.GetRicMessageName(123456)
- if name != "" {
+ if name != "" {
t.Errorf("Error: GetRicMessageName returned invalid value: name=%s", name)
}
}
func TestTeardown(t *testing.T) {
Sdl.Clear()
- Rnib.Clear()
}
// Helper functions
@@ -209,4 +198,4 @@
response := executeRequest(req)
return response.Body.String()
-}
\ No newline at end of file
+}