forked from kandoo/beehive-netctrl
/
main.go
51 lines (44 loc) · 1.37 KB
/
main.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
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 controllertype = flag.String("controller", "master", "specify the controller (master, area1, area2)")
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())
if *controllertype == "master" {
routing.InstallMasterC(h, bh.Persistent(1))
} else if *controllertype == "area1" {
routing.InstallR1(h, bh.Persistent(1))
} else {
routing.InstallR2(h, bh.Persistent(1))
}
// routing.InstallLoadBalancer(h, bh.Persistent(1))
// routing.InstallRouterIP(h, bh.Persistent(1))
h.Start()
}