Merge pull request #1944 from weaveworks/issues/1940-remove-proxy-weaveps-dep

Use netlink instead of shelling out to `weave ps`
This commit is contained in:
Bryan Boreham committed 2016-02-04 13:45:58 +00:00
commit 1d3c80ab49
10 files changed
+183 -64

No files matched your search

-31
View File
@@ -3,10 +3,8 @@ package proxy
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"net"
"net/http"
"os"
"os/exec"
@@ -131,35 +129,6 @@ func inspectContainerInPath(client *docker.Client, path string) (*docker.Contain
return container, err
}
func weaveContainerIPs(containerID string) (mac string, ips []net.IP, nets []*net.IPNet, err error) {
stdout, stderr, err := callWeave("ps", containerID)
if err != nil || len(stderr) > 0 {
err = errors.New(string(stderr))
return
}
if len(stdout) <= 0 {
return
}
fields := strings.Fields(string(stdout))
if len(fields) < 2 {
return
}
mac = fields[1]
var ip net.IP
var ipnet *net.IPNet
for _, cidr := range fields[2:] {
ip, ipnet, err = net.ParseCIDR(cidr)
if err != nil {
return
}
ips = append(ips, ip)
nets = append(nets, ipnet)
}
return
}
func addVolume(hostConfig jsonObject, source, target, mode string) error {
configBinds, err := hostConfig.StringArray("Binds")
if err != nil {