diff --git a/controller/nucleus/principalNetworkDomain.go b/controller/nucleus/principalNetworkDomain.go index 54a04a44759e2c1450714f370ae08ff4065ee7e3..9f24bcc9f03017d2a79eba32cb1c50ba7c1a1d5f 100644 --- a/controller/nucleus/principalNetworkDomain.go +++ b/controller/nucleus/principalNetworkDomain.go @@ -39,6 +39,10 @@ import ( "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 func NewPND( name string, @@ -49,12 +53,18 @@ func NewPND( ) (networkdomain.NetworkDomain, error) { sbiStore := NewSbiStore(id) + changeStore, ok := changeStoreMap[id] + if !ok { + changeStore = store.NewChangeStore() + changeStoreMap[id] = changeStore + } + pnd := &pndImplementation{ Name: name, Description: description, sbic: sbiStore, devices: NewDeviceStore(id, sbiStore), - changes: store.NewChangeStore(), + changes: changeStore, Id: id, csbiClient: c, @@ -399,10 +409,12 @@ func (pnd *pndImplementation) RequestAll(path string) error { // ChangeOND creates a change from the provided Operation, path and value. // 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) { - d, err := pnd.devices.Get((store.Query{ - ID: duid, - Name: "", - })) + d, err := pnd.devices.Get(store.Query{ + ID: duid, + }) + if err != nil { + return uuid.Nil, err + } cpy, err := ygot.DeepCopy(d.GetModel()) ygot.BuildEmptyTree(cpy) if err != nil {