From 50924d1c0381b2331326f09cd37993447328a33e Mon Sep 17 00:00:00 2001
From: Malte Bauch <malte.bauch@stud.h-da.de>
Date: Fri, 23 Dec 2022 12:25:45 +0100
Subject: [PATCH] Refactor GetMne

Update the model representation within the database. For the return the
response from the device is used directly.
---
 controller/northbound/server/pnd.go          | 17 ++++-------------
 controller/nucleus/principalNetworkDomain.go |  1 +
 2 files changed, 5 insertions(+), 13 deletions(-)

diff --git a/controller/northbound/server/pnd.go b/controller/northbound/server/pnd.go
index 989f5f15f..64d3e1634 100644
--- a/controller/northbound/server/pnd.go
+++ b/controller/northbound/server/pnd.go
@@ -58,6 +58,8 @@ func (p PndServer) GetMne(ctx context.Context, request *ppb.GetMneRequest) (*ppb
 		return nil, status.Errorf(codes.Aborted, "%v", err)
 	}
 
+	// TODO(path): This needs some adjustments when we're switching towards a new
+	// path request handling.
 	mne, err := fillMneBySpecificPath(networkElement, "/")
 	if err != nil {
 		log.Error(err)
@@ -330,11 +332,6 @@ func (p PndServer) GetPath(ctx context.Context, request *ppb.GetPathRequest) (*p
 		return nil, status.Errorf(codes.Aborted, "%v", err)
 	}
 
-	networkElement, err := pnd.GetNetworkElement(request.Mneid)
-	if err != nil {
-		log.Error(err)
-		return nil, status.Errorf(codes.Aborted, "%v", err)
-	}
 	mneuid, err := uuid.Parse(request.Mneid)
 	if err != nil {
 		log.Error(err)
@@ -344,13 +341,7 @@ func (p PndServer) GetPath(ctx context.Context, request *ppb.GetPathRequest) (*p
 	// In case we get the path from grpc-gateway we have to replace
 	path := strings.ReplaceAll(request.Path, "||", "/")
 
-	_, err = pnd.Request(mneuid, path)
-	if err != nil {
-		log.Error(err)
-		return nil, status.Errorf(codes.Aborted, "%v", err)
-	}
-
-	mne, err := fillMneBySpecificPath(networkElement, path)
+	resp, err := pnd.Request(mneuid, path)
 	if err != nil {
 		log.Error(err)
 		return nil, status.Errorf(codes.Aborted, "%v", err)
@@ -363,7 +354,7 @@ func (p PndServer) GetPath(ctx context.Context, request *ppb.GetPathRequest) (*p
 			Name:        pnd.GetName(),
 			Description: pnd.GetDescription(),
 		},
-		MneNotification: mne.MneNotification,
+		MneNotification: resp.(*gnmi.GetResponse).Notification,
 	}, nil
 }
 
diff --git a/controller/nucleus/principalNetworkDomain.go b/controller/nucleus/principalNetworkDomain.go
index 0b6d8b999..e7b6a6f38 100644
--- a/controller/nucleus/principalNetworkDomain.go
+++ b/controller/nucleus/principalNetworkDomain.go
@@ -433,6 +433,7 @@ func (pnd *pndImplementation) Request(uuid uuid.UUID, path string) (proto.Messag
 		return nil, err
 	}
 
+	// TODO(path): We probably have to remove this when we address path request handling.
 	err = pnd.networkElementService.Update(mne)
 	if err != nil {
 		return nil, err
-- 
GitLab