mirror of
https://github.com/clearlinux/docker.git
synced 2026-09-05 21:21:42 +00:00
register libnetwork API and UI with docker parent chain
This commit also brings in the ability to specify a default network and its corresponding driver as daemon flags. This helps in existing clients to make use of newer networking features provided by libnetwork. Signed-off-by: Madhu Venugopal <madhu@docker.com>
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
// +build experimental
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
"strings"
|
||||
|
||||
"github.com/go-check/check"
|
||||
)
|
||||
|
||||
func isNetworkPresent(c *check.C, name string) bool {
|
||||
runCmd := exec.Command(dockerBinary, "network", "ls")
|
||||
out, _, _, err := runCommandWithStdoutStderr(runCmd)
|
||||
if err != nil {
|
||||
c.Fatal(out, err)
|
||||
}
|
||||
lines := strings.Split(out, "\n")
|
||||
for i := 1; i < len(lines)-1; i++ {
|
||||
if strings.Contains(lines[i], name) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestDockerNetworkLsDefault(c *check.C) {
|
||||
defaults := []string{"bridge", "host", "none"}
|
||||
for _, nn := range defaults {
|
||||
if !isNetworkPresent(c, nn) {
|
||||
c.Fatalf("Missing Default network : %s", nn)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestDockerNetworkCreateDelete(c *check.C) {
|
||||
runCmd := exec.Command(dockerBinary, "network", "create", "test")
|
||||
out, _, _, err := runCommandWithStdoutStderr(runCmd)
|
||||
if err != nil {
|
||||
c.Fatal(out, err)
|
||||
}
|
||||
if !isNetworkPresent(c, "test") {
|
||||
c.Fatalf("Network test not found")
|
||||
}
|
||||
|
||||
runCmd = exec.Command(dockerBinary, "network", "rm", "test")
|
||||
out, _, _, err = runCommandWithStdoutStderr(runCmd)
|
||||
if err != nil {
|
||||
c.Fatal(out, err)
|
||||
}
|
||||
if isNetworkPresent(c, "test") {
|
||||
c.Fatalf("Network test is not removed")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user