-
Notifications
You must be signed in to change notification settings - Fork 879
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IPAM config through cni network config
This commit introduces configurable IPAM setting for cni configs. This would allow used to configure the network level ipam configs in the cni config Signed-off-by: Abhinandan Prativadi <[email protected]>
- Loading branch information
Showing
13 changed files
with
412 additions
and
378 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package main | ||
|
||
import ( | ||
"io" | ||
"os" | ||
|
||
"github.com/codegangsta/cli" | ||
"github.com/docker/docker/pkg/reexec" | ||
"github.com/docker/docker/pkg/term" | ||
"github.com/sirupsen/logrus" | ||
) | ||
|
||
func main() { | ||
if reexec.Init() { | ||
return | ||
} | ||
_, stdout, stderr := term.StdStreams() | ||
logrus.SetOutput(stderr) | ||
err := cniApp(stdout, stderr) | ||
if err != nil { | ||
os.Exit(1) | ||
} | ||
} | ||
|
||
func cniApp(stdout, stderr io.Writer) error { | ||
app := cli.NewApp() | ||
|
||
app.Name = "cniserver" | ||
app.Usage = "A cni side car for libnetwork daemon." | ||
app.Flags = cniserverFlags | ||
app.Before = processFlags | ||
//app.Commands = cniCommands | ||
|
||
app.Run(os.Args) | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/codegangsta/cli" | ||
cniserver "github.com/docker/libnetwork/pkg/server/cniserver" | ||
"github.com/sirupsen/logrus" | ||
) | ||
|
||
var ( | ||
cniserverFlags = []cli.Flag{ | ||
cli.StringFlag{ | ||
Name: "sock", | ||
Value: "/var/run/cniserver.sock", | ||
Usage: "path to the socket file on which cniserver listens. Default (/var/run/cni-libnetwork.sock)", | ||
}, | ||
cli.StringFlag{ | ||
Name: "dnet-port", | ||
Value: "2389", | ||
Usage: "Daemon socket to connect to. Default(2389)", | ||
}, | ||
cli.StringFlag{ | ||
Name: "dnet-address", | ||
Value: "127.0.0.1", | ||
Usage: "Daemon IP address to connect to", | ||
}, | ||
cli.BoolFlag{ | ||
Name: "D, -debug", | ||
Usage: "Enable debug mode", | ||
}, | ||
} | ||
) | ||
|
||
func processFlags(c *cli.Context) error { | ||
var err error | ||
|
||
if c.Bool("D") { | ||
logrus.SetLevel(logrus.DebugLevel) | ||
} | ||
|
||
cniService, err := cniserver.NewCniService(c.String("sock"), c.String("dnet-address"), c.String("dnet-port")) | ||
if err != nil { | ||
return fmt.Errorf("faile to create cni service: %v", err) | ||
} | ||
serverCloseChan := make(chan struct{}) | ||
if err := cniService.InitCniService(serverCloseChan); err != nil { | ||
fmt.Printf("Failed to initialize CNI server: \n", err) | ||
os.Exit(1) | ||
} | ||
<-serverCloseChan | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.