-
Notifications
You must be signed in to change notification settings - Fork 1
/
ifmgrd.go
58 lines (47 loc) · 1.13 KB
/
ifmgrd.go
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Copyright (c) 2019, AT&T Intellectual Property. All rights reserved.
//
// Copyright (c) 2015-2016 by Brocade Communications Systems, Inc.
// All rights reserved.
//
// SPDX-License-Identifier: GPL-2.0-only
package ifmgrd
import (
"sync/atomic"
"github.com/danos/config/schema"
)
type atomicSchemaNode struct {
atomic.Value
}
// atomic.Values need to be consistently store a concrete type.
// This wrapper allows us to store anything that meets the
// interface we care about.
type nodeWrapper struct {
node schema.Node
}
func newAtomicSchemaNode() *atomicSchemaNode {
a := &atomicSchemaNode{}
tree, _ := schema.NewTree(nil)
a.Store(tree)
return a
}
func (t *atomicSchemaNode) Store(n schema.Node) {
t.Value.Store(&nodeWrapper{n})
}
func (t *atomicSchemaNode) Load() schema.Node {
v := t.Value.Load().(*nodeWrapper)
return v.node
}
var intfmgr *IntfManager
var sessionmgr *Sessions
var SchemaTree *atomicSchemaNode
func init() {
sessionmgr = NewSessionMap()
intfmgr = NewIntfManager()
SchemaTree = newAtomicSchemaNode()
}
type Config struct {
Yangdir string
Socket string
Capabilities string
ConfigdSocket string
}