X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=E2Manager%2Fmanagers%2Fe2t_association_manager.go;h=9ebdd604f5b275fe1c1d2973a00ca4a32a116088;hb=0249b5fc410b6c6814906b185dfdf25b27621148;hp=3afba253df0e6933b230a0adc28012cec60c70a5;hpb=514e6041ca6b9b92cb887c941767f298a746e315;p=ric-plt%2Fe2mgr.git diff --git a/E2Manager/managers/e2t_association_manager.go b/E2Manager/managers/e2t_association_manager.go index 3afba25..9ebdd60 100644 --- a/E2Manager/managers/e2t_association_manager.go +++ b/E2Manager/managers/e2t_association_manager.go @@ -28,60 +28,65 @@ import ( ) type E2TAssociationManager struct { - logger *logger.Logger - rnibDataService services.RNibDataService - e2tInstanceManager IE2TInstancesManager - rmClient clients.IRoutingManagerClient + logger *logger.Logger + rnibDataService services.RNibDataService + e2tInstanceManager IE2TInstancesManager + rmClient clients.IRoutingManagerClient + ranConnectStatusChangeManager IRanConnectStatusChangeManager } -func NewE2TAssociationManager(logger *logger.Logger, rnibDataService services.RNibDataService, e2tInstanceManager IE2TInstancesManager, rmClient clients.IRoutingManagerClient) *E2TAssociationManager { +func NewE2TAssociationManager(logger *logger.Logger, rnibDataService services.RNibDataService, e2tInstanceManager IE2TInstancesManager, rmClient clients.IRoutingManagerClient, ranConnectStatusChangeManager IRanConnectStatusChangeManager) *E2TAssociationManager { return &E2TAssociationManager{ - logger: logger, - rnibDataService: rnibDataService, - e2tInstanceManager: e2tInstanceManager, - rmClient: rmClient, + logger: logger, + rnibDataService: rnibDataService, + e2tInstanceManager: e2tInstanceManager, + rmClient: rmClient, + ranConnectStatusChangeManager: ranConnectStatusChangeManager, } } -func (m *E2TAssociationManager) AssociateRan(e2tAddress string, nodebInfo *entities.NodebInfo) error { +func (m *E2TAssociationManager) AssociateRan(e2tAddress string, nodebInfo *entities.NodebInfo) (bool, error) { ranName := nodebInfo.RanName m.logger.Infof("#E2TAssociationManager.AssociateRan - Associating RAN %s to E2T Instance address: %s", ranName, e2tAddress) - err := m.associateRanAndUpdateNodeb(e2tAddress, nodebInfo) + ranStatusChangePublished, err := m.associateRanAndUpdateNodeb(e2tAddress, nodebInfo) if err != nil { m.logger.Errorf("#E2TAssociationManager.AssociateRan - RoutingManager failure: Failed to associate RAN %s to E2T %s. Error: %s", nodebInfo, e2tAddress, err) - return err + return ranStatusChangePublished, err } err = m.e2tInstanceManager.AddRansToInstance(e2tAddress, []string{ranName}) if err != nil { m.logger.Errorf("#E2TAssociationManager.AssociateRan - RAN name: %s - Failed to add RAN to E2T instance %s. Error: %s", ranName, e2tAddress, err) - return e2managererrors.NewRnibDbError() + return ranStatusChangePublished, e2managererrors.NewRnibDbError() } m.logger.Infof("#E2TAssociationManager.AssociateRan - successfully associated RAN %s with E2T %s", ranName, e2tAddress) - return nil + return ranStatusChangePublished, nil } -func (m *E2TAssociationManager) associateRanAndUpdateNodeb(e2tAddress string, nodebInfo *entities.NodebInfo) error { +func (m *E2TAssociationManager) associateRanAndUpdateNodeb(e2tAddress string, nodebInfo *entities.NodebInfo) (bool, error) { rmErr := m.rmClient.AssociateRanToE2TInstance(e2tAddress, nodebInfo.RanName) + if rmErr != nil { - nodebInfo.ConnectionStatus = entities.ConnectionStatus_DISCONNECTED - } else { - nodebInfo.ConnectionStatus = entities.ConnectionStatus_CONNECTED - nodebInfo.AssociatedE2TInstanceAddress = e2tAddress - nodebInfo.ConnectionAttempts = 0 + ranStatusChangePublished, _ := m.ranConnectStatusChangeManager.ChangeStatus(nodebInfo, entities.ConnectionStatus_DISCONNECTED) + return ranStatusChangePublished, e2managererrors.NewRoutingManagerError() } - rNibErr := m.rnibDataService.UpdateNodebInfo(nodebInfo) - if rNibErr != nil { - m.logger.Errorf("#E2TAssociationManager.associateRanAndUpdateNodeb - RAN name: %s - Failed to update nodeb entity in rNib. Error: %s", nodebInfo.RanName, rNibErr) + + ranStatusChangePublished, rnibErr := m.ranConnectStatusChangeManager.ChangeStatus(nodebInfo, entities.ConnectionStatus_CONNECTED) + + if rnibErr != nil { + return ranStatusChangePublished, e2managererrors.NewRnibDbError() } - var err error - if rmErr != nil { - err = e2managererrors.NewRoutingManagerError() - } else if rNibErr != nil{ - err = e2managererrors.NewRnibDbError() + + nodebInfo.AssociatedE2TInstanceAddress = e2tAddress + rnibErr = m.rnibDataService.UpdateNodebInfo(nodebInfo) + + if rnibErr != nil { + m.logger.Errorf("#E2TAssociationManager.associateRanAndUpdateNodeb - RAN name: %s - Failed updating nodeb. Error: %s", nodebInfo.RanName, rnibErr) + return ranStatusChangePublished, e2managererrors.NewRnibDbError() } - return err + + return ranStatusChangePublished, nil } func (m *E2TAssociationManager) DissociateRan(e2tAddress string, ranName string) error { @@ -107,6 +112,7 @@ func (m *E2TAssociationManager) DissociateRan(e2tAddress string, ranName string) } err = m.rmClient.DissociateRanE2TInstance(e2tAddress, ranName) + if err != nil { m.logger.Errorf("#E2TAssociationManager.DissociateRan - RoutingManager failure: Failed to dissociate RAN %s from E2T %s. Error: %s", ranName, e2tAddress, err) } else {