Add MacAddress to inspect

Signed-off-by: Wim <wim@42.be>

Closes: #955
Approved by: rhatdan
This commit is contained in:
Wim
2018-06-17 17:40:39 +02:00
committed by Atomic Bot
parent fc81dd71fe
commit 4d3db1b4a9
5 changed files with 14 additions and 0 deletions

View File

@ -179,6 +179,7 @@ func (s *BoltState) Refresh() error {
state.State = ContainerStateConfigured state.State = ContainerStateConfigured
state.ExecSessions = make(map[string]*ExecSession) state.ExecSessions = make(map[string]*ExecSession)
state.IPs = nil state.IPs = nil
state.Interfaces = nil
state.Routes = nil state.Routes = nil
state.BindMounts = make(map[string]string) state.BindMounts = make(map[string]string)

View File

@ -152,6 +152,10 @@ type containerState struct {
// Only populated if we created a network namespace for the container, // Only populated if we created a network namespace for the container,
// and the network namespace is currently active // and the network namespace is currently active
IPs []*cnitypes.IPConfig `json:"ipAddresses,omitempty"` 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 // Routes contains network routes present in the container
// Only populated if we created a network namespace for the container, // Only populated if we created a network namespace for the container,
// and the network namespace is currently active // and the network namespace is currently active

View File

@ -132,6 +132,13 @@ func (c *Container) getContainerInspectData(size bool, driverData *inspect.Data)
// Set network namespace path // Set network namespace path
data.NetworkSettings.SandboxKey = runtimeInfo.NetNS.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 { if size {

View File

@ -805,6 +805,7 @@ func (c *Container) cleanupNetwork() error {
c.state.NetNS = nil c.state.NetNS = nil
c.state.IPs = nil c.state.IPs = nil
c.state.Interfaces = nil
c.state.Routes = nil c.state.Routes = nil
return c.save() return c.save()
} }

View File

@ -55,6 +55,7 @@ func (r *Runtime) configureNetNS(ctr *Container, ctrNS ns.NetNS) (err error) {
ctr.state.NetNS = ctrNS ctr.state.NetNS = ctrNS
ctr.state.IPs = resultStruct.IPs ctr.state.IPs = resultStruct.IPs
ctr.state.Routes = resultStruct.Routes ctr.state.Routes = resultStruct.Routes
ctr.state.Interfaces = resultStruct.Interfaces
// We need to temporarily use iptables to allow the container // We need to temporarily use iptables to allow the container
// to resolve DNS until this issue is fixed upstream. // to resolve DNS until this issue is fixed upstream.