forked from kandoo/beehive-netctrl
/
loadbalancer.go
43 lines (36 loc) · 962 Bytes
/
loadbalancer.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
package main
import (
"flag"
"log"
"os"
"runtime/pprof"
bh "github.com/kandoo/beehive"
"github.com/kandoo/beehive-netctrl/controller"
"github.com/jyzhe/beehive-netctrl/discovery"
"github.com/kandoo/beehive-netctrl/openflow"
"github.com/jyzhe/beehive-netctrl/routing"
// "github.com/jyzhe/beehive-netctrl/switching"
)
var cpuprofile = flag.String("cpuprofile", "", "write cpu profile to file")
func main() {
flag.Parse()
if *cpuprofile != "" {
f, err := os.Create(*cpuprofile)
if err != nil {
log.Fatal(err)
}
pprof.StartCPUProfile(f)
defer pprof.StopCPUProfile()
}
h := bh.NewHive()
openflow.StartOpenFlow(h)
controller.RegisterNOMController(h)
discovery.RegisterDiscovery(h)
// Register a switch:
// switching.RegisterSwitch(h, bh.Persistent(1))
// or a hub:
// switching.RegisterHub(h, bh.NonTransactional())
// routing.InstallRouter(h, bh.Persistent(1))
routing.InstallLoadBalancer(h, bh.Persistent(1))
h.Start()
}