From f05ecfad898e6093411f6979cc69feae1dab19b0 Mon Sep 17 00:00:00 2001
From: Manuel Kieweg <mail@manuelkieweg.de>
Date: Mon, 25 Jan 2021 10:32:56 +0100
Subject: [PATCH] schema is attached to sbi

---
 nucleus/controller.go      |  2 +-
 nucleus/device.go          |  2 +-
 nucleus/device_test.go     |  2 +-
 nucleus/southbound.go      | 21 +++++++++++++++++++++
 nucleus/southbound_test.go |  2 +-
 5 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/nucleus/controller.go b/nucleus/controller.go
index 9de78e919..47c87bf0a 100644
--- a/nucleus/controller.go
+++ b/nucleus/controller.go
@@ -52,4 +52,4 @@ func (c *Core) Shutdown() {
 	}
 	log.Info("Shutdown complete")
 	os.Exit(0)
-}
\ No newline at end of file
+}
diff --git a/nucleus/device.go b/nucleus/device.go
index bd3dcb722..78bb3fae4 100644
--- a/nucleus/device.go
+++ b/nucleus/device.go
@@ -19,7 +19,7 @@ type Device struct {
 // use better naming in further develop
 // Also all that Interface Call specific logic belongs to SBI!
 func (d Device) Add(resp interface{}) error {
-	s, err := openconfig.Schema()
+	s, err := d.SBI.Schema()
 	if err != nil {
 		return err
 	}
diff --git a/nucleus/device_test.go b/nucleus/device_test.go
index 3f89d7d0f..a452c7912 100644
--- a/nucleus/device_test.go
+++ b/nucleus/device_test.go
@@ -34,4 +34,4 @@ func TestDevice_Add(t *testing.T) {
 			log.Debug(d.SBI.SbiIdentifier())
 		})
 	}
-}
\ No newline at end of file
+}
diff --git a/nucleus/southbound.go b/nucleus/southbound.go
index a3aa5af68..e908f41d1 100644
--- a/nucleus/southbound.go
+++ b/nucleus/southbound.go
@@ -1,9 +1,18 @@
 package nucleus
 
+import (
+	"code.fbi.h-da.de/cocsn/gosdn/nucleus/util"
+	"code.fbi.h-da.de/cocsn/yang-models/generated/openconfig"
+	"github.com/openconfig/ygot/ytypes"
+)
+
 // SouthboundInterface provides an
 // interface for SBI implementations
 type SouthboundInterface interface {
+	// Deprecated
 	SbiIdentifier() string
+
+	Schema() (*ytypes.Schema, error)
 }
 
 type Tapi struct {
@@ -11,12 +20,17 @@ type Tapi struct {
 
 type OpenConfig struct {
 	transport Transport
+	schema    *ytypes.Schema
 }
 
 func (oc *OpenConfig) SbiIdentifier() string {
 	return "openconfig"
 }
 
+func (oc *OpenConfig) Schema() (*ytypes.Schema, error) {
+	return openconfig.Schema()
+}
+
 func (oc *OpenConfig) OpenconfigInterfaces(device Device) {
 	resp, err := oc.transport.Get(nil, nil...)
 	if err != nil {
@@ -24,3 +38,10 @@ func (oc *OpenConfig) OpenconfigInterfaces(device Device) {
 	}
 	device.Add(resp)
 }
+
+func (oc *OpenConfig) GetFullDeviceInfo(device Device) error {
+	paths := util.NewPaths()
+	paths.ParseSchema(oc.schema, "device")
+
+	return nil
+}
diff --git a/nucleus/southbound_test.go b/nucleus/southbound_test.go
index 447696fa7..72536cbbb 100644
--- a/nucleus/southbound_test.go
+++ b/nucleus/southbound_test.go
@@ -47,4 +47,4 @@ func TestOpenConfig_OpenconfigInterfaces(t *testing.T) {
 			oc.OpenconfigInterfaces(tt.args.device)
 		})
 	}
-}
\ No newline at end of file
+}
-- 
GitLab