[RICPLT-1852] - update rnib from the setup response handler 27/827/1
authorrh362j <ronen.hasid@intl.att.com>
Wed, 28 Aug 2019 15:57:52 +0000 (18:57 +0300)
committerrh362j <ronen.hasid@intl.att.com>
Wed, 28 Aug 2019 15:58:04 +0000 (18:58 +0300)
Change-Id: I513f872ab353accc2c5b793086b0afa13e3c88c4
Signed-off-by: rh362j <ronen.hasid@intl.att.com>
E2Manager/managers/ran_setup_manager.go

index f6fe1d2..df7119e 100644 (file)
@@ -25,7 +25,9 @@ import (
        "e2mgr/rNibWriter"
        "e2mgr/rmrCgo"
        "e2mgr/services"
+       "e2mgr/sessions"
        "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
+       "time"
 )
 
 type RanSetupManager struct {
@@ -90,14 +92,20 @@ func (m *RanSetupManager) prepareSetupRequest(nodebInfo *entities.NodebInfo) (in
 // ExecuteSetup updates the connection status and number of attempts in the nodebInfo and send an endc/x2 setup request to establish a connection with the RAN
 func (m *RanSetupManager) ExecuteSetup(nodebInfo *entities.NodebInfo) error {
 
+       //Fill details for the response handler
+       requestDetails := models.RequestDetails{RanName: nodebInfo.RanName, RanPort: uint16(nodebInfo.Port), RanIp: nodebInfo.Ip}
+       m.rmrService.E2sessions[nodebInfo.RanName] = sessions.E2SessionDetails{SessionStart: time.Now(), Request: &requestDetails}
+
        // Update retries and connection status (connecting)
        if err := m.updateConnectionStatusConnecting(nodebInfo); err != nil {
+               delete(m.rmrService.E2sessions,nodebInfo.RanName)
                return e2managererrors.NewRnibDbError()
        }
 
        // Build the endc/x2 setup request
        rmrMsgType, request, err := m.prepareSetupRequest(nodebInfo)
        if err != nil {
+               delete(m.rmrService.E2sessions,nodebInfo.RanName)
                return err
        }
 
@@ -106,6 +114,8 @@ func (m *RanSetupManager) ExecuteSetup(nodebInfo *entities.NodebInfo) error {
        if err := m.rmrService.SendRmrMessage(response); err != nil {
                m.logger.Errorf("#RanSetupManager.ExecuteSetup - failed to send setup request to RMR: %s", err)
 
+               delete(m.rmrService.E2sessions,nodebInfo.RanName)
+
                // Decrement retries and connection status (disconnected)
                if err := m.updateConnectionStatusDisconnected(nodebInfo); err != nil {
                        return e2managererrors.NewRnibDbError()