diff options
author | Matthew Heon <matthew.heon@gmail.com> | 2018-01-08 10:39:27 -0500 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-01-08 16:12:50 +0000 |
commit | f881a8d17c677192ea862bcfc25b829f3cfd7392 (patch) | |
tree | 1075d1ccb2c5cb5e91d5f6f4f2a4fe578a0f4e81 /libpod/container_inspect.go | |
parent | d0fb2e48e5d8ea47332b0a9608129ab268338c7e (diff) | |
download | podman-f881a8d17c677192ea862bcfc25b829f3cfd7392.tar.gz podman-f881a8d17c677192ea862bcfc25b829f3cfd7392.tar.bz2 podman-f881a8d17c677192ea862bcfc25b829f3cfd7392.zip |
Add basic network inspection info
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
Closes: #196
Approved by: rhatdan
Diffstat (limited to 'libpod/container_inspect.go')
-rw-r--r-- | libpod/container_inspect.go | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/libpod/container_inspect.go b/libpod/container_inspect.go index 5f29a231e..0bb45cedd 100644 --- a/libpod/container_inspect.go +++ b/libpod/container_inspect.go @@ -1,8 +1,10 @@ package libpod import ( + "github.com/cri-o/ocicni/pkg/ocicni" "github.com/projectatomic/libpod/libpod/driver" "github.com/sirupsen/logrus" + "github.com/ulule/deepcopier" ) func (c *Container) getContainerInspectData(size bool, driverData *driver.Data) (*ContainerInspectData, error) { @@ -52,8 +54,46 @@ func (c *Container) getContainerInspectData(size bool, driverData *driver.Data) ExecIDs: []string{}, //TODO GraphDriver: driverData, Mounts: spec.Mounts, - NetworkSettings: &NetworkSettings{}, // TODO from networking patch + NetworkSettings: &NetworkSettings{ + Bridge: "", // TODO + SandboxID: "", // TODO - is this even relevant? + HairpinMode: false, // TODO + LinkLocalIPv6Address: "", // TODO - do we even support IPv6? + LinkLocalIPv6PrefixLen: 0, // TODO - do we even support IPv6? + Ports: []ocicni.PortMapping{}, // TODO - maybe worth it to put this in Docker format? + SandboxKey: "", // Network namespace path + SecondaryIPAddresses: nil, // TODO - do we support this? + 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: "", + IPPrefixLen: 0, // TODO + IPv6Gateway: "", // TODO - do we even support IPv6? + MacAddress: "", // TODO + }, + } + + // Copy port mappings into network settings + if config.PortMappings != nil { + deepcopier.Copy(config.PortMappings).To(data.NetworkSettings.Ports) } + + // Get information on the container's network namespace (if present) + if runtimeInfo.NetNS != nil { + // Get IP address + ip, err := c.runtime.getContainerIP(c) + if err != nil { + logrus.Errorf("error getting container %q IP: %v", config.ID, err) + } else { + data.NetworkSettings.IPAddress = ip.To4().String() + } + + // Set network namespace path + data.NetworkSettings.SandboxKey = runtimeInfo.NetNS.Path() + } + if size { rootFsSize, err := c.rootFsSize() if err != nil { |