X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=E2Manager%2Fmanagers%2Fran_setup_manager.go;h=6297467c0c032e38884403ec0b3a447c3d0e3f68;hb=3f9a67b3d8e15bc725f2f66adf499617ffc0d2fc;hp=f6fe1d202e33d611fc88e0208e652dc22424a89a;hpb=264731981e4a52e876c5b484e35032ada6559ac6;p=ric-plt%2Fe2mgr.git diff --git a/E2Manager/managers/ran_setup_manager.go b/E2Manager/managers/ran_setup_manager.go index f6fe1d2..6297467 100644 --- a/E2Manager/managers/ran_setup_manager.go +++ b/E2Manager/managers/ran_setup_manager.go @@ -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 { @@ -49,9 +51,9 @@ func (m *RanSetupManager) updateConnectionStatusConnecting(nodebInfo *entities.N nodebInfo.ConnectionAttempts++ err := m.rnibWriterProvider().UpdateNodebInfo(nodebInfo) if err != nil { - m.logger.Errorf("#RanSetupManager.updateConnectionStatusConnecting - failed to update RAN's connection status to CONNECTING: %s", err) + m.logger.Errorf("#RanSetupManager.updateConnectionStatusConnecting - Ran name: %s - Failed updating RAN's connection status to CONNECTING : %s", nodebInfo.RanName, err) } else { - m.logger.Infof("#RanSetupManager.updateConnectionStatusConnecting - successfully updated RAN's connection status to CONNECTING") + m.logger.Infof("#RanSetupManager.updateConnectionStatusConnecting - Ran name: %s - Successfully updated rNib. RAN's current connection status: CONNECTING, RAN's current connection attempts: %d", nodebInfo.RanName, nodebInfo.ConnectionAttempts) } return err } @@ -63,9 +65,9 @@ func (m *RanSetupManager) updateConnectionStatusDisconnected(nodebInfo *entities nodebInfo.ConnectionAttempts-- err := m.rnibWriterProvider().UpdateNodebInfo(nodebInfo) if err != nil { - m.logger.Errorf("#RanSetupManager.updateConnectionStatusDisconnected - failed to update RAN's connection status to DISCONNECTED : %s", err) + m.logger.Errorf("#RanSetupManager.updateConnectionStatusDisconnected - Ran name: %s - Failed updating RAN's connection status to DISCONNECTED : %s", nodebInfo.RanName, err) } else { - m.logger.Errorf("#RanSetupManager.updateConnectionStatusDisconnected - successfully updated RAN's connection status to DISCONNECTED") + m.logger.Infof("#RanSetupManager.updateConnectionStatusDisconnected - Ran name: %s - Successfully updated rNib. RAN's current connection status: DISCONNECTED, RAN's current connection attempts: %d", nodebInfo.RanName, nodebInfo.ConnectionAttempts) } return err } @@ -83,28 +85,36 @@ func (m *RanSetupManager) prepareSetupRequest(nodebInfo *entities.NodebInfo) (in return rmrMsgType, request, nil } - m.logger.Errorf("#RanSetupManager.ExecuteSetup - unsupported nodebInfo.E2ApplicationProtocol %d ", nodebInfo.E2ApplicationProtocol) + m.logger.Errorf("#RanSetupManager.prepareSetupRequest - Unsupported nodebInfo.E2ApplicationProtocol %d ", nodebInfo.E2ApplicationProtocol) return 0, nil, e2managererrors.NewInternalError() } // 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 } // Send the endc/x2 setup request response := &models.NotificationResponse{MgsType: rmrMsgType, RanName: nodebInfo.RanName, Payload: request.GetMessageAsBytes(m.logger)} if err := m.rmrService.SendRmrMessage(response); err != nil { - m.logger.Errorf("#RanSetupManager.ExecuteSetup - failed to send setup request to RMR: %s", err) + m.logger.Errorf("#RanSetupManager.ExecuteSetup - failed sending 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 {