summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWim <wim@42.be>2018-06-17 11:08:41 +0200
committerAtomic Bot <atomic-devel@projectatomic.io>2018-06-17 21:21:27 +0000
commit9e134576e8eb047466706fa71a201def6d5d8159 (patch)
treeb5f84ff12098dec681b217ae15cc28baffaef484
parentfc5e3706e9b9f81d5ce75e3013488dc23cb6558d (diff)
downloadpodman-9e134576e8eb047466706fa71a201def6d5d8159.tar.gz
podman-9e134576e8eb047466706fa71a201def6d5d8159.tar.bz2
podman-9e134576e8eb047466706fa71a201def6d5d8159.zip
Add more network info ipv4/ipv6 and be more compatible with docker
Signed-off-by: Wim <wim@42.be> Closes: #953 Approved by: mheon
-rw-r--r--libpod/container_inspect.go28
-rw-r--r--pkg/inspect/inspect.go4
2 files changed, 18 insertions, 14 deletions
diff --git a/libpod/container_inspect.go b/libpod/container_inspect.go
index 0e37036ca..a3b4d0f65 100644
--- a/libpod/container_inspect.go
+++ b/libpod/container_inspect.go
@@ -1,6 +1,7 @@
package libpod
import (
+ "strconv"
"strings"
"github.com/cri-o/ocicni/pkg/ocicni"
@@ -97,11 +98,11 @@ func (c *Container) getContainerInspectData(size bool, driverData *inspect.Data)
SecondaryIPv6Addresses: nil, // TODO - do we support this?
EndpointID: "", // TODO - is this even relevant?
Gateway: "", // TODO
- GlobalIPv6Addresses: []string{}, // TODO - do we even support IPv6?
- GlobalIPv6PrefixLen: 0, // TODO - do we even support IPv6?
- IPAddress: nil,
- IPPrefixLen: 0, // TODO
- IPv6Gateway: "", // TODO - do we even support IPv6?
+ GlobalIPv6Address: "",
+ GlobalIPv6PrefixLen: 0,
+ IPAddress: "",
+ IPPrefixLen: 0,
+ IPv6Gateway: "",
MacAddress: "", // TODO
},
}
@@ -114,18 +115,21 @@ func (c *Container) getContainerInspectData(size bool, driverData *inspect.Data)
// Get information on the container's network namespace (if present)
if runtimeInfo.NetNS != nil {
// Go through our IP addresses
- ctrIPs := []string{}
-
for _, ctrIP := range c.state.IPs {
+ ipWithMask := ctrIP.Address.String()
+ splitIP := strings.Split(ipWithMask, "/")
+ mask, _ := strconv.Atoi(splitIP[1])
if ctrIP.Version == "4" {
- ipWithMask := ctrIP.Address.String()
- splitIP := strings.Split(ipWithMask, "/")
- ctrIPs = append(ctrIPs, splitIP[0])
+ data.NetworkSettings.IPAddress = splitIP[0]
+ data.NetworkSettings.IPPrefixLen = mask
+ data.NetworkSettings.Gateway = ctrIP.Gateway.String()
+ } else {
+ data.NetworkSettings.GlobalIPv6Address = splitIP[0]
+ data.NetworkSettings.GlobalIPv6PrefixLen = mask
+ data.NetworkSettings.IPv6Gateway = ctrIP.Gateway.String()
}
}
- data.NetworkSettings.IPAddress = ctrIPs
-
// Set network namespace path
data.NetworkSettings.SandboxKey = runtimeInfo.NetNS.Path()
}
diff --git a/pkg/inspect/inspect.go b/pkg/inspect/inspect.go
index 09ddf488c..765ee43a7 100644
--- a/pkg/inspect/inspect.go
+++ b/pkg/inspect/inspect.go
@@ -198,9 +198,9 @@ type NetworkSettings struct {
SecondaryIPv6Addresses []string `json:"SecondaryIPv6Addresses"`
EndpointID string `json:"EndpointID"`
Gateway string `json:"Gateway"`
- GlobalIPv6Addresses []string `json:"GlobalIPv6Addresses"`
+ GlobalIPv6Address string `json:"GlobalIPv6Address"`
GlobalIPv6PrefixLen int `json:"GlobalIPv6PrefixLen"`
- IPAddress []string `json:"IPAddress"`
+ IPAddress string `json:"IPAddress"`
IPPrefixLen int `json:"IPPrefixLen"`
IPv6Gateway string `json:"IPv6Gateway"`
MacAddress string `json:"MacAddress"`