From 67db13a28cd83bc0a69a7680e2e18a27bafe5abd Mon Sep 17 00:00:00 2001 From: "S.H." <sebastian.heiss94@proton.me> Date: Wed, 26 Feb 2025 23:49:14 +0100 Subject: [PATCH] add test case for getting network elements to test-config --- applications/rtdt-manager/test-config/main.go | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/applications/rtdt-manager/test-config/main.go b/applications/rtdt-manager/test-config/main.go index 6e5386b02..9783d44a0 100644 --- a/applications/rtdt-manager/test-config/main.go +++ b/applications/rtdt-manager/test-config/main.go @@ -7,10 +7,12 @@ import ( "os" "time" + "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/networkelement" "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/pnd" "code.fbi.h-da.de/danet/gosdn/applications/rtdt-manager/gosdnutil" rtdt_auth "code.fbi.h-da.de/danet/gosdn/applications/rtdt-manager/rtdt-auth" "code.fbi.h-da.de/danet/gosdn/applications/rtdt-manager/sdnconfig" + "code.fbi.h-da.de/danet/gosdn/applications/rtdt-manager/util" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" ) @@ -39,6 +41,26 @@ func SetupGosdnConn() (*pnd.PrincipalNetworkDomain, *rtdt_auth.RtdtAuth) { } +func GetMne(name string) { + gosdn_pnd, testauth := SetupGosdnConn() + if gosdn_pnd == nil || testauth == nil { + fmt.Println("ERROR: couldn't establish connection to gosdn") + } + getAllReq := &networkelement.GetAllRequest{ + Timestamp: util.Now(), + Pid: gosdn_pnd.GetId(), + } + mneServiceClient := networkelement.NewNetworkElementServiceClient(testauth.GetConn()) + response, err := mneServiceClient.GetAll(testauth.CreateContextWithAuthorization(), getAllReq) + if err != nil { + fmt.Printf("Bad thing happened. Bad thing: %v\n", err) + return + } + for i, mne := range response.GetMne() { + fmt.Printf("Mne model %d: %s\n", i, mne.String()) + } +} + func Download() { gosdn_pnd, testauth := SetupGosdnConn() if gosdn_pnd == nil || testauth == nil { @@ -93,6 +115,9 @@ func main() { fmt.Println("Mode: Upload") Upload(sdnConfigPath) return + case "get": + fmt.Println("Mode: Get") + GetMne("gnmi-target-switch0") default: fmt.Println("Unknown Mode!") return -- GitLab