Skip to content
Snippets Groups Projects
Commit cf5f8517 authored by Malte Bauch's avatar Malte Bauch Committed by Fabian Seidl
Browse files

Add map of changeStores to be accessed while creating new PNDs


See merge request !292

Co-authored-by: default avatarAndre Sterba <andre.sterba@stud.h-da.de>
Co-authored-by: default avatarMalte Bauch <malte.bauch@extern.h-da.de>
parent 4e15f1b3
Branches
Tags
2 merge requests!292Add map of changeStores to be accessed while creating new PNDs,!264WIP: Develop
Pipeline #99730 failed
This commit is part of merge request !264. Comments created here will be created in the context of that merge request.
...@@ -39,6 +39,10 @@ import ( ...@@ -39,6 +39,10 @@ import (
"github.com/spf13/viper" "github.com/spf13/viper"
) )
// NOTE: Until we've added database support for changes, we will hold
// changeStores in memory for now.
var changeStoreMap = make(map[uuid.UUID]*store.ChangeStore)
// NewPND creates a Principle Network Domain // NewPND creates a Principle Network Domain
func NewPND( func NewPND(
name string, name string,
...@@ -49,12 +53,18 @@ func NewPND( ...@@ -49,12 +53,18 @@ func NewPND(
) (networkdomain.NetworkDomain, error) { ) (networkdomain.NetworkDomain, error) {
sbiStore := NewSbiStore(id) sbiStore := NewSbiStore(id)
changeStore, ok := changeStoreMap[id]
if !ok {
changeStore = store.NewChangeStore()
changeStoreMap[id] = changeStore
}
pnd := &pndImplementation{ pnd := &pndImplementation{
Name: name, Name: name,
Description: description, Description: description,
sbic: sbiStore, sbic: sbiStore,
devices: NewDeviceStore(id, sbiStore), devices: NewDeviceStore(id, sbiStore),
changes: store.NewChangeStore(), changes: changeStore,
Id: id, Id: id,
csbiClient: c, csbiClient: c,
...@@ -399,10 +409,12 @@ func (pnd *pndImplementation) RequestAll(path string) error { ...@@ -399,10 +409,12 @@ func (pnd *pndImplementation) RequestAll(path string) error {
// ChangeOND creates a change from the provided Operation, path and value. // ChangeOND creates a change from the provided Operation, path and value.
// The Change is Pending and times out after the specified timeout period // The Change is Pending and times out after the specified timeout period
func (pnd *pndImplementation) ChangeOND(duid uuid.UUID, operation ppb.ApiOperation, path string, value ...string) (uuid.UUID, error) { func (pnd *pndImplementation) ChangeOND(duid uuid.UUID, operation ppb.ApiOperation, path string, value ...string) (uuid.UUID, error) {
d, err := pnd.devices.Get((store.Query{ d, err := pnd.devices.Get(store.Query{
ID: duid, ID: duid,
Name: "", })
})) if err != nil {
return uuid.Nil, err
}
cpy, err := ygot.DeepCopy(d.GetModel()) cpy, err := ygot.DeepCopy(d.GetModel())
ygot.BuildEmptyTree(cpy) ygot.BuildEmptyTree(cpy)
if err != nil { if err != nil {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment