Add R5 content to master
[ric-plt/e2mgr.git] / E2Manager / rNibWriter / rNibWriter.go
index a44f388..3186d70 100644 (file)
@@ -45,6 +45,8 @@ type RNibWriter interface {
        RemoveE2TInstance(e2tAddress string) error
        UpdateGnbCells(nodebInfo *entities.NodebInfo, servedNrCells []*entities.ServedNRCell) error
        RemoveServedNrCells(inventoryName string, servedNrCells []*entities.ServedNRCell) error
+       UpdateNodebInfoOnConnectionStatusInversion(nodebInfo *entities.NodebInfo, stateChangeMessageChannel string, event string) error
+       SaveGeneralConfiguration(config *entities.GeneralConfiguration) error
 }
 
 /*
@@ -67,6 +69,17 @@ func (w *rNibWriterInstance) RemoveServedNrCells(inventoryName string, servedNrC
        return nil
 }
 
+func (w *rNibWriterInstance) SaveGeneralConfiguration(config *entities.GeneralConfiguration) error {
+
+       err := w.SaveWithKeyAndMarshal(common.BuildGeneralConfigurationKey(), config)
+
+       if err != nil {
+               return common.NewInternalError(err)
+       }
+
+       return nil
+}
+
 /*
 SaveNodeb saves nodeB entity data in the redis DB according to the specified data model
 */
@@ -315,6 +328,46 @@ func (w *rNibWriterInstance) RemoveE2TInstance(address string) error {
        return nil
 }
 
+func (w *rNibWriterInstance) SaveWithKeyAndMarshal(key string, entity interface{}) error {
+
+       data, err := json.Marshal(entity)
+
+       if err != nil {
+               return common.NewInternalError(err)
+       }
+
+       var pairs []interface{}
+       pairs = append(pairs, key, data)
+
+       err = w.sdl.Set(pairs)
+
+       if err != nil {
+               return common.NewInternalError(err)
+       }
+
+       return nil
+}
+
+/*
+UpdateNodebInfoOnConnectionStatusInversion...
+*/
+func (w *rNibWriterInstance) UpdateNodebInfoOnConnectionStatusInversion(nodebInfo *entities.NodebInfo, stateChangeMessageChannel string, event string) error {
+
+       pairs, err := buildUpdateNodebInfoPairs(nodebInfo)
+
+       if err != nil {
+               return err
+       }
+
+       err = w.sdl.SetAndPublish([]string{stateChangeMessageChannel, event}, pairs)
+
+       if err != nil {
+               return common.NewInternalError(err)
+       }
+
+       return nil
+}
+
 /*
 Close the writer
 */
@@ -366,4 +419,4 @@ func appendGnbCells(inventoryName string, cells []*entities.ServedNRCell, pairs
 
 func isNotEmpty(nbIdentity *entities.NbIdentity) bool {
        return nbIdentity.GlobalNbId != nil && nbIdentity.GlobalNbId.PlmnId != "" && nbIdentity.GlobalNbId.NbId != ""
-}
+}
\ No newline at end of file