state manager stub
diff --git a/main.go b/main.go
index c8b8a76..c538eaa 100644
--- a/main.go
+++ b/main.go
@@ -12,8 +12,10 @@
"github.com/golang/glog"
"github.com/golang/protobuf/proto"
- "code.hackerspace.pl/q3k/topo/graph"
confpb "code.hackerspace.pl/q3k/topo/proto/config"
+
+ "code.hackerspace.pl/q3k/topo/graph"
+ "code.hackerspace.pl/q3k/topo/state"
)
var (
@@ -57,9 +59,11 @@
glog.Exitf("Initial netbox feed failed: %v", err)
}
+ stm := state.NewManager()
+
sconf := ServiceConfig{
DebugListen: flagDebugListen,
}
- srv := NewService(gr, sconf)
+ srv := NewService(gr, stm, sconf)
srv.Run()
}
diff --git a/service.go b/service.go
index ccfd0bc..916299c 100644
--- a/service.go
+++ b/service.go
@@ -7,11 +7,13 @@
"sort"
"strings"
- "code.hackerspace.pl/q3k/topo/graph"
"github.com/gobuffalo/packr"
"github.com/golang/glog"
"github.com/q3k/statusz"
"vbom.ml/util/sortorder"
+
+ "code.hackerspace.pl/q3k/topo/graph"
+ "code.hackerspace.pl/q3k/topo/state"
)
type ServiceConfig struct {
@@ -20,12 +22,14 @@
type Service struct {
gr *graph.Graph
+ stm *state.StateManager
config ServiceConfig
}
-func NewService(gr *graph.Graph, c ServiceConfig) *Service {
+func NewService(gr *graph.Graph, stm *state.StateManager, c ServiceConfig) *Service {
return &Service{
gr: gr,
+ stm: stm,
config: c,
}
}
diff --git a/state/state.go b/state/state.go
new file mode 100644
index 0000000..5f7cc56
--- /dev/null
+++ b/state/state.go
@@ -0,0 +1,24 @@
+package state
+
+import (
+ pb "code.hackerspace.pl/q3k/topo/proto/control"
+)
+
+type SwitchportState struct {
+ Proto *pb.SwitchPort
+}
+
+type SwitchState struct {
+ Name string
+ Ports []*SwitchportState
+}
+
+type StateManager struct {
+ Switches map[string]*SwitchState
+}
+
+func NewManager() *StateManager {
+ return &StateManager{
+ Switches: make(map[string]*SwitchState),
+ }
+}