diff options
author | Wim <wim@42.be> | 2018-06-17 17:40:39 +0200 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-06-18 14:20:30 +0000 |
commit | 4d3db1b4a9ec1a1a2aa74e3da0102b6017f8a328 (patch) | |
tree | 69bf2c39b3e204f27230f97684315dfb5264973b | |
parent | fc81dd71feef94cc754485ee2a38444eb67c4d8c (diff) | |
download | podman-4d3db1b4a9ec1a1a2aa74e3da0102b6017f8a328.tar.gz podman-4d3db1b4a9ec1a1a2aa74e3da0102b6017f8a328.tar.bz2 podman-4d3db1b4a9ec1a1a2aa74e3da0102b6017f8a328.zip |
Add MacAddress to inspect
Signed-off-by: Wim <wim@42.be>
Closes: #955
Approved by: rhatdan
-rw-r--r-- | libpod/boltdb_state.go | 1 | ||||
-rw-r--r-- | libpod/container.go | 4 | ||||
-rw-r--r-- | libpod/container_inspect.go | 7 | ||||
-rw-r--r-- | libpod/container_internal.go | 1 | ||||
-rw-r--r-- | libpod/networking.go | 1 |
5 files changed, 14 insertions, 0 deletions
diff --git a/libpod/boltdb_state.go b/libpod/boltdb_state.go index 77a17ce12..5e70a2554 100644 --- a/libpod/boltdb_state.go +++ b/libpod/boltdb_state.go @@ -179,6 +179,7 @@ func (s *BoltState) Refresh() error { state.State = ContainerStateConfigured state.ExecSessions = make(map[string]*ExecSession) state.IPs = nil + state.Interfaces = nil state.Routes = nil state.BindMounts = make(map[string]string) diff --git a/libpod/container.go b/libpod/container.go index 26232e5c0..a30a9e006 100644 --- a/libpod/container.go +++ b/libpod/container.go @@ -152,6 +152,10 @@ type containerState struct { // Only populated if we created a network namespace for the container, // and the network namespace is currently active IPs []*cnitypes.IPConfig `json:"ipAddresses,omitempty"` + // Interfaces contains interface information about the container + // Only populated if we created a network namespace for the container, + // and the network namespace is currently active + Interfaces []*cnitypes.Interface `json:"interfaces,omitempty"` // Routes contains network routes present in the container // Only populated if we created a network namespace for the container, // and the network namespace is currently active diff --git a/libpod/container_inspect.go b/libpod/container_inspect.go index a3b4d0f65..7dc4d34b9 100644 --- a/libpod/container_inspect.go +++ b/libpod/container_inspect.go @@ -132,6 +132,13 @@ func (c *Container) getContainerInspectData(size bool, driverData *inspect.Data) // Set network namespace path data.NetworkSettings.SandboxKey = runtimeInfo.NetNS.Path() + + // Set MAC address of interface linked with network namespace path + for _, i := range c.state.Interfaces { + if i.Sandbox == data.NetworkSettings.SandboxKey { + data.NetworkSettings.MacAddress = i.Mac + } + } } if size { diff --git a/libpod/container_internal.go b/libpod/container_internal.go index bd0074e56..ef4f907b6 100644 --- a/libpod/container_internal.go +++ b/libpod/container_internal.go @@ -805,6 +805,7 @@ func (c *Container) cleanupNetwork() error { c.state.NetNS = nil c.state.IPs = nil + c.state.Interfaces = nil c.state.Routes = nil return c.save() } diff --git a/libpod/networking.go b/libpod/networking.go index 74ca340a0..afa18b534 100644 --- a/libpod/networking.go +++ b/libpod/networking.go @@ -55,6 +55,7 @@ func (r *Runtime) configureNetNS(ctr *Container, ctrNS ns.NetNS) (err error) { ctr.state.NetNS = ctrNS ctr.state.IPs = resultStruct.IPs ctr.state.Routes = resultStruct.Routes + ctr.state.Interfaces = resultStruct.Interfaces // We need to temporarily use iptables to allow the container // to resolve DNS until this issue is fixed upstream. |