Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add missing GetTokenCtx in AMF-OAM service #103

Merged
merged 1 commit into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions backend/WebUI/api_charging.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package WebUI

import (
"context"
"encoding/json"
"fmt"
"net/http"
Expand Down Expand Up @@ -125,7 +124,14 @@ func GetChargingRecord(c *gin.Context) {
if amfUris := webuiSelf.GetOamUris(models.NfType_AMF); amfUris != nil {
requestUri := fmt.Sprintf("%s/namf-oam/v1/registered-ue-context", amfUris[0])

res, err := http.NewRequestWithContext(context.TODO(), http.MethodGet, requestUri, nil)
ctx, pd, tokerErr := webui_context.GetSelf().GetTokenCtx(models.ServiceName_NAMF_OAM, models.NfType_AMF)
if tokerErr != nil {
logger.ProcLog.Errorf("GetTokenCtx error: %+v", tokerErr)
c.JSON(http.StatusInternalServerError, pd)
return
}

res, err := http.NewRequestWithContext(ctx, http.MethodGet, requestUri, nil)
if err != nil {
logger.ProcLog.Error(err)
c.JSON(http.StatusInternalServerError, gin.H{})
Expand Down
12 changes: 7 additions & 5 deletions backend/WebUI/api_verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,18 @@ func GetSmfUserPlaneInfo() (interface{}, error) {
webuiSelf := webui_context.GetSelf()
webuiSelf.UpdateNfProfiles()

ctx, _, err := webuiSelf.GetTokenCtx(models.ServiceName_NSMF_OAM, models.NfType_SMF)
if err != nil {
logger.ConsumerLog.Infof("GetTokenCtx: service %v, err: %+v", models.ServiceName_NSMF_OAM, err)
}

var jsonData interface{}

// TODO: support fetching data from multiple SMF
if smfUris := webuiSelf.GetOamUris(models.NfType_SMF); smfUris != nil {
requestUri := fmt.Sprintf("%s/nsmf-oam/v1/user-plane-info/", smfUris[0])

ctx, pd, err := webuiSelf.GetTokenCtx(models.ServiceName_NSMF_OAM, models.NfType_SMF)
if err != nil {
logger.ConsumerLog.Infof("GetTokenCtx: service %v, err: %+v", models.ServiceName_NSMF_OAM, err)
return pd, err
}

req, err_req := http.NewRequestWithContext(ctx, http.MethodGet, requestUri, nil)
if err_req != nil {
logger.ProcLog.Error(err_req)
Expand Down
20 changes: 17 additions & 3 deletions backend/WebUI/api_webui.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package WebUI

import (
"context"
"crypto/rand"
"crypto/tls"
"encoding/json"
Expand Down Expand Up @@ -1788,7 +1787,14 @@ func GetRegisteredUEContext(c *gin.Context) {
requestUri = fmt.Sprintf("%s/namf-oam/v1/registered-ue-context", amfUris[0])
}

req, err := http.NewRequestWithContext(context.Background(), http.MethodGet, requestUri, nil)
ctx, pd, tokerErr := webui_context.GetSelf().GetTokenCtx(models.ServiceName_NAMF_OAM, models.NfType_AMF)
if tokerErr != nil {
logger.ProcLog.Errorf("GetTokenCtx error: %+v", tokerErr)
c.JSON(http.StatusInternalServerError, pd)
return
}

req, err := http.NewRequestWithContext(ctx, http.MethodGet, requestUri, nil)
if err != nil {
logger.ProcLog.Error(err)
c.JSON(http.StatusInternalServerError, gin.H{})
Expand Down Expand Up @@ -1845,7 +1851,15 @@ func GetUEPDUSessionInfo(c *gin.Context) {
// TODO: support fetching data from multiple SMF
if smfUris := webuiSelf.GetOamUris(models.NfType_SMF); smfUris != nil {
requestUri := fmt.Sprintf("%s/nsmf-oam/v1/ue-pdu-session-info/%s", smfUris[0], smContextRef)
req, err := http.NewRequestWithContext(context.Background(), http.MethodGet, requestUri, nil)

ctx, pd, tokerErr := webui_context.GetSelf().GetTokenCtx(models.ServiceName_NSMF_OAM, models.NfType_SMF)
if tokerErr != nil {
logger.ProcLog.Errorf("GetTokenCtx error: %+v", tokerErr)
c.JSON(http.StatusInternalServerError, pd)
return
}

req, err := http.NewRequestWithContext(ctx, http.MethodGet, requestUri, nil)
if err != nil {
logger.ProcLog.Error(err)
c.JSON(http.StatusInternalServerError, gin.H{})
Expand Down
Loading