Skip to content

Commit

Permalink
fix: comply new NF structure
Browse files Browse the repository at this point in the history
  • Loading branch information
andy89923 committed Sep 30, 2024
1 parent 690c8a0 commit 1ac8c65
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
22 changes: 14 additions & 8 deletions internal/sbi/consumer/udm_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,9 @@ func (s *nudmService) GetSmData(ctx context.Context, supi string,
SDMConf := Nudm_SubscriberDataManagement.NewConfiguration()
SDMConf.SetBasePath(service.ApiPrefix)
client = s.getSubscribeDataManagementClient(service.ApiPrefix)
if client != nil {
break
}
}
}

Expand Down Expand Up @@ -209,6 +212,9 @@ func (s *nudmService) Subscribe(ctx context.Context, smCtx *smf_context.SMContex
SDMConf := Nudm_SubscriberDataManagement.NewConfiguration()
SDMConf.SetBasePath(service.ApiPrefix)
client = s.getSubscribeDataManagementClient(service.ApiPrefix)
if client != nil {
break
}
}
}

Expand All @@ -217,7 +223,7 @@ func (s *nudmService) Subscribe(ctx context.Context, smCtx *smf_context.SMContex
}

sdmSubscription := models.SdmSubscription{
NfInstanceId: smf_context.GetSelf().NfInstanceID,
NfInstanceId: s.consumer.Context().NfInstanceID,
PlmnId: smPlmnID,
}

Expand All @@ -233,7 +239,7 @@ func (s *nudmService) Subscribe(ctx context.Context, smCtx *smf_context.SMContex
}()

if localErr == nil {
smf_context.GetSelf().Ues.SetSubscriptionId(smCtx.Supi, resSubscription.SubscriptionId)
s.consumer.Context().Ues.SetSubscriptionId(smCtx.Supi, resSubscription.SubscriptionId)
logger.PduSessLog.Infoln("SDM Subscription Successful UE:", smCtx.Supi, "SubscriptionId:",
resSubscription.SubscriptionId)
} else if httpResp != nil {
Expand All @@ -246,19 +252,19 @@ func (s *nudmService) Subscribe(ctx context.Context, smCtx *smf_context.SMContex
return nil, openapi.ReportError("server no response")
}

smf_context.GetSelf().Ues.IncrementPduSessionCount(smCtx.Supi)
s.consumer.Context().Ues.IncrementPduSessionCount(smCtx.Supi)
return nil, nil
}

func (s *nudmService) UnSubscribe(smCtx *smf_context.SMContext) (
*models.ProblemDetails, error,
) {
ctx, _, oauthErr := smf_context.GetSelf().GetTokenCtx(models.ServiceName_NUDM_SDM, models.NfType_UDM)
ctx, _, oauthErr := s.consumer.Context().GetTokenCtx(models.ServiceName_NUDM_SDM, models.NfType_UDM)
if oauthErr != nil {
return nil, fmt.Errorf("Get Token Context Error[%v]", oauthErr)
}

if smf_context.GetSelf().Ues.IsLastPduSession(smCtx.Supi) {
if s.consumer.Context().Ues.IsLastPduSession(smCtx.Supi) {
var client *Nudm_SubscriberDataManagement.APIClient
for _, service := range *s.consumer.Context().UDMProfile.NfServices {
if service.ServiceName == models.ServiceName_NUDM_SDM {
Expand All @@ -272,7 +278,7 @@ func (s *nudmService) UnSubscribe(smCtx *smf_context.SMContext) (
return nil, fmt.Errorf("sdm client failed")
}

subscriptionId := smf_context.GetSelf().Ues.GetSubscriptionId(smCtx.Supi)
subscriptionId := s.consumer.Context().Ues.GetSubscriptionId(smCtx.Supi)

httpResp, localErr := client.SubscriptionDeletionApi.Unsubscribe(ctx, smCtx.Supi, subscriptionId)
defer func() {
Expand All @@ -295,9 +301,9 @@ func (s *nudmService) UnSubscribe(smCtx *smf_context.SMContext) (
} else {
return nil, openapi.ReportError("server no response")
}
smf_context.GetSelf().Ues.DeleteUe(smCtx.Supi)
s.consumer.Context().Ues.DeleteUe(smCtx.Supi)
} else {
smf_context.GetSelf().Ues.DecrementPduSessionCount(smCtx.Supi)
s.consumer.Context().Ues.DecrementPduSessionCount(smCtx.Supi)
}

return nil, nil
Expand Down
8 changes: 4 additions & 4 deletions internal/sbi/processor/pdu_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,15 @@ func (p *Processor) HandlePDUSessionSMContextCreate(
}
}

if !smf_context.GetSelf().Ues.UeExists(smContext.Supi) {
if !p.Context().Ues.UeExists(smContext.Supi) {
if problemDetails, err := p.Consumer().
Subscribe(ctx, smContext, smPlmnID); problemDetails != nil {
smContext.Log.Errorln("SDM Subscription Failed Problem:", problemDetails)
} else if err != nil {
smContext.Log.Errorln("SDM Subscription Error:", err)
}
} else {
smf_context.GetSelf().Ues.IncrementPduSessionCount(smContext.Supi)
p.Context().Ues.IncrementPduSessionCount(smContext.Supi)
}

establishmentRequest := m.PDUSessionEstablishmentRequest
Expand Down Expand Up @@ -898,7 +898,7 @@ func (p *Processor) HandlePDUSessionSMContextRelease(
}
}

if smf_context.GetSelf().Ues.UeExists(smContext.Supi) {
if p.Context().Ues.UeExists(smContext.Supi) {
problemDetails, err := p.Consumer().UnSubscribe(smContext)
if problemDetails != nil {
logger.PduSessLog.Errorf("SDM UnSubscription Failed Problem[%+v]", problemDetails)
Expand Down Expand Up @@ -998,7 +998,7 @@ func (p *Processor) HandlePDUSessionSMContextLocalRelease(
}
}

if smf_context.GetSelf().Ues.UeExists(smContext.Supi) {
if p.Context().Ues.UeExists(smContext.Supi) {
problemDetails, err := p.Consumer().UnSubscribe(smContext)
if problemDetails != nil {
logger.PduSessLog.Errorf("SDM UnSubscription Failed Problem[%+v]", problemDetails)
Expand Down

0 comments on commit 1ac8c65

Please sign in to comment.