From a1b198fd1f403c152c1a9a1c3801a1878a3417ba Mon Sep 17 00:00:00 2001
From: Malte Bauch <malte.bauch@stud.h-da.de>
Date: Thu, 11 Feb 2021 14:04:28 +0100
Subject: [PATCH] changed GetDevices to GetDevice

there was no need to get the full device list. but for the cli there is
a need to access specific devices from the pnd via their uuid
---
 nucleus/principalNetworkDomain.go | 11 ++++++++---
 nucleus/southbound.go             |  3 +++
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/nucleus/principalNetworkDomain.go b/nucleus/principalNetworkDomain.go
index c304f8ae3..6a6eaf5ac 100644
--- a/nucleus/principalNetworkDomain.go
+++ b/nucleus/principalNetworkDomain.go
@@ -17,7 +17,7 @@ type PrincipalNetworkDomain interface {
 	RequestAll(string) error
 	GetName() string
 	GetDescription() string
-	GetDevices() map[uuid.UUID]*Device
+	GetDevice(uuid.UUID) (*Device, bool)
 	GetSBIs() map[string]SouthboundInterface
 }
 
@@ -45,8 +45,8 @@ func (pnd *pndImplementation) GetName() string {
 	return pnd.name
 }
 
-func (pnd *pndImplementation) GetDevices() map[uuid.UUID]*Device {
-	return pnd.devices
+func (pnd *pndImplementation) GetDevice(uuid uuid.UUID) (*Device, bool) {
+	return pnd.getDevice(uuid)
 }
 
 func (pnd *pndImplementation) GetDescription() string {
@@ -104,6 +104,11 @@ func (pnd *pndImplementation) removeDevice(uuid uuid.UUID) error {
 	return nil
 }
 
+func (pnd *pndImplementation) getDevice(uuid uuid.UUID) (*Device, bool) {
+	device, exists := pnd.devices[uuid]
+	return device, exists
+}
+
 func (pnd *pndImplementation) Request(uuid uuid.UUID, path string) error {
 	d := pnd.devices[uuid]
 	ctx := context.Background()
diff --git a/nucleus/southbound.go b/nucleus/southbound.go
index cb2ac3721..2a31d78f2 100644
--- a/nucleus/southbound.go
+++ b/nucleus/southbound.go
@@ -62,6 +62,9 @@ func (oc *OpenConfig) SetNode() func(schema *yang.Entry, root interface{}, path
 	}
 }
 
+// deprecated
+// Use for prototyping only.
+// Use OpenConfig instead
 type AristaOC struct {
 	// deprecated
 	transport Transport
-- 
GitLab