Include interface name in container-addrs output

This commit is contained in:
Adam Harrison committed 2016-05-06 14:12:50 +01:00
1 parent ad5845b67f
commit 260b416cd7
3 files changed
+10 -9

No files matched your search

+2 -1
View File
@@ -45,6 +45,7 @@ func WithNetNS(ns netns.NsHandle, work func() error) error {
}
type NetDev struct {
Name string
MAC net.HardwareAddr
CIDRs []*net.IPNet
}
@@ -97,7 +98,7 @@ func linkToNetDev(link netlink.Link) (*NetDev, error) {
return nil, err
}
netDev := &NetDev{MAC: link.Attrs().HardwareAddr}
netDev := &NetDev{Name: link.Attrs().Name, MAC: link.Attrs().HardwareAddr}
for _, addr := range addrs {
netDev.CIDRs = append(netDev.CIDRs, addr.IPNet)
}
+1 -1
View File
@@ -27,7 +27,7 @@ func containerAddrs(args []string) error {
}
for _, netDev := range netDevs {
fmt.Printf("%12s %s", containerID, netDev.MAC.String())
fmt.Printf("%12s %s %s", containerID, netDev.Name, netDev.MAC.String())
for _, cidr := range netDev.CIDRs {
prefixLength, _ := cidr.Mask.Size()
fmt.Printf(" %v/%v", cidr.IP, prefixLength)
+7 -7
View File
@@ -1143,23 +1143,23 @@ with_container_addresses() {
shift 1
CONTAINER_ADDRS=$(util_op container-addrs $BRIDGE "$@") || return 1
echo "$CONTAINER_ADDRS" | while read CONTAINER_ID CONTAINER_MAC CONTAINER_IPS; do
$COMMAND "$CONTAINER_ID" "$CONTAINER_MAC" "$CONTAINER_IPS"
echo "$CONTAINER_ADDRS" | while read CONTAINER_ID CONTAINER_IFACE CONTAINER_MAC CONTAINER_IPS; do
$COMMAND "$CONTAINER_ID" "$CONTAINER_IFACE" "$CONTAINER_MAC" "$CONTAINER_IPS"
done
}
echo_addresses() {
echo $1 $2 $3
echo $1 $3 $4
}
echo_ips() {
for CIDR in $3; do
for CIDR in $4; do
echo ${CIDR%/*}
done
}
echo_cidrs() {
echo $3
echo $4
}
peer_args() {
@@ -1382,13 +1382,13 @@ check_overlap() {
# Claim addresses for a container in IPAM. Expects to be called from
# with_container_addresses.
ipam_reclaim() {
for CIDR in $3 ; do
for CIDR in $4 ; do
http_call $HTTP_ADDR PUT "/ip/$1/$CIDR?noErrorOnUnknown=true&?check-alive=true" || true
done
}
ipam_reclaim_no_check_alive() {
for CIDR in $3 ; do
for CIDR in $4 ; do
http_call $HTTP_ADDR PUT /ip/$1/$CIDR?noErrorOnUnknown=true || true
done
}