-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.go
62 lines (56 loc) · 1.17 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
52
53
54
55
56
57
58
59
60
61
62
package main
import (
"github.com/TrilliumIT/docker-vxlan-plugin/vxlan"
"os"
log "github.com/Sirupsen/logrus"
"github.com/codegangsta/cli"
"github.com/docker/go-plugins-helpers/network"
)
const (
version = "0.7.1"
)
func main() {
var flagDebug = cli.BoolFlag{
Name: "debug, d",
Usage: "Enable debugging.",
}
var flagScope = cli.StringFlag{
Name: "scope",
Value: "local",
Usage: "Scope of the network. local or global.",
}
var flagVtepDev = cli.StringFlag{
Name: "vtepdev",
Value: "",
Usage: "VTEP device.",
}
app := cli.NewApp()
app.Name = "docker-vxlan-plugin"
app.Usage = "Docker vxLan Networking"
app.Version = version
app.Flags = []cli.Flag{
flagDebug,
flagScope,
flagVtepDev,
}
app.Action = Run
app.Run(os.Args)
}
// Run initializes the driver
func Run(ctx *cli.Context) {
if ctx.Bool("debug") {
log.SetLevel(log.DebugLevel)
}
log.SetFormatter(&log.TextFormatter{
ForceColors: false,
DisableColors: true,
DisableTimestamp: false,
FullTimestamp: true,
})
d, err := vxlan.NewDriver(ctx.String("scope"), ctx.String("vtepdev"))
if err != nil {
panic(err)
}
h := network.NewHandler(d)
h.ServeUnix("root", "vxlan")
}