Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package nucleus
import (
"code.fbi.h-da.de/danet/gosdn/controller/interfaces/device"
"code.fbi.h-da.de/danet/gosdn/controller/interfaces/networkdomain"
"code.fbi.h-da.de/danet/gosdn/controller/store"
"github.com/google/uuid"
log "github.com/sirupsen/logrus"
)
const (
pndStoreName = "pnd"
)
// LoadedPnd represents a Principal Network Domain that was loaeded by using
// the Load() method of the PndStore.
type LoadedPnd struct {
ID string `json:"id" bson:"_id,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
}
// PndStore is used to store PrincipalNetworkDomains
type PndStore struct {
pndStoreName string
pendingChannels map[uuid.UUID]chan device.Details
}
// NewPndStore returns a PndStore
func NewPndStore() networkdomain.PndStore {
storeMode := store.GetStoreMode()
log.Debugf("StoreMode: %s", storeMode)
switch storeMode {
case store.Filesystem:
store := NewMemoryPndStore()
return &store
case store.Database:
pendingChannels: make(map[uuid.UUID]chan device.Details),
pndStoreName: "pnd-store.json"}
case store.Memory:
store := NewMemoryPndStore()
return &store
default:
return nil
}
}