Fetch list of container IDs inside weaveutil, for 'weave ps'
This commit is contained in:
1 parent
5e290aa11f
commit
b307b9872a
2 files changed
+18
-3
No files matched your search
+16
-1
@@ -27,10 +27,25 @@ func containerAddrs(args []string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
containerArgs := []string{}
|
||||
for _, cid := range args[1:] {
|
||||
if cid == "weave:allids" { // expand to all container IDs
|
||||
all, err := client.ListContainers(docker.ListContainersOptions{All: true})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, c := range all {
|
||||
containerArgs = append(containerArgs, c.ID)
|
||||
}
|
||||
} else {
|
||||
containerArgs = append(containerArgs, cid)
|
||||
}
|
||||
}
|
||||
|
||||
var containerIDs []string
|
||||
containers := make(map[string]*docker.Container)
|
||||
|
||||
for _, cid := range args[1:] {
|
||||
for _, cid := range containerArgs {
|
||||
if cid == "weave:expose" {
|
||||
netDev, err := weavenet.GetBridgeNetDev(bridgeName)
|
||||
if err != nil {
|
||||
|
||||
@@ -1009,7 +1009,7 @@ with_container_addresses() {
|
||||
}
|
||||
|
||||
echo_addresses() {
|
||||
echo $1 $3 $4
|
||||
echo $(printf "%.12s" $1) $3 $4
|
||||
}
|
||||
|
||||
echo_ips() {
|
||||
@@ -2246,7 +2246,7 @@ EOF
|
||||
show_addrs $ALL_CIDRS
|
||||
;;
|
||||
ps)
|
||||
[ $# -eq 0 ] && CONTAINERS="weave:expose $(docker ps -q)" || CONTAINERS="$@"
|
||||
[ $# -eq 0 ] && CONTAINERS="weave:expose weave:allids" || CONTAINERS="$@"
|
||||
with_container_addresses echo_addresses $CONTAINERS
|
||||
;;
|
||||
stop)
|
||||
|
||||
Reference in new issue
Block a user