Merge "[RICPLT-1898] - Replace http router to gorilla-mux + UT + Automation code"
authorHila Anina <hanina@intl.att.com>
Thu, 29 Aug 2019 08:32:09 +0000 (08:32 +0000)
committerGerrit Code Review <gerrit@o-ran-sc.org>
Thu, 29 Aug 2019 08:32:09 +0000 (08:32 +0000)
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()