summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libpod/container_inspect.go42
-rw-r--r--libpod/inspect_data.go35
2 files changed, 59 insertions, 18 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 {
diff --git a/libpod/inspect_data.go b/libpod/inspect_data.go
index 072b94ab2..5f9e3166d 100644
--- a/libpod/inspect_data.go
+++ b/libpod/inspect_data.go
@@ -3,6 +3,7 @@ package libpod
import (
"time"
+ "github.com/cri-o/ocicni/pkg/ocicni"
digest "github.com/opencontainers/go-digest"
"github.com/opencontainers/image-spec/specs-go/v1"
specs "github.com/opencontainers/runtime-spec/specs-go"
@@ -55,23 +56,23 @@ type ContainerInspectState struct {
// NetworkSettings holds information about the newtwork settings of the container
type NetworkSettings struct {
- Bridge string `json:"Bridge"`
- SandboxID string `json:"SandboxID"`
- HairpinMode bool `json:"HairpinMode"`
- LinkLocalIPv6Address string `json:"LinkLocalIPv6Address"`
- LinkLocalIPv6PrefixLen int `json:"LinkLocalIPv6PrefixLen"`
- Ports map[string]struct{} `json:"Ports"`
- SandboxKey string `json:"SandboxKey"`
- SecondaryIPAddresses string `json:"SecondaryIPAddresses"` //idk type
- SecondaryIPv6Addresses string `json:"SecondaryIPv6Addresses"` //idk type
- EndpointID string `json:"EndpointID"`
- Gateway string `json:"Gateway"`
- GlobalIPv6Addresses string `json:"GlobalIPv6Addresses"`
- GlobalIPv6PrefixLen int `json:"GlobalIPv6PrefixLen"`
- IPAddress string `json:"IPAddress"`
- IPPrefixLen int `json:"IPPrefixLen"`
- IPv6Gateway string `json:"IPv6Gateway"`
- MacAddress string `json:"MacAddress"`
+ Bridge string `json:"Bridge"`
+ SandboxID string `json:"SandboxID"`
+ HairpinMode bool `json:"HairpinMode"`
+ LinkLocalIPv6Address string `json:"LinkLocalIPv6Address"`
+ LinkLocalIPv6PrefixLen int `json:"LinkLocalIPv6PrefixLen"`
+ Ports []ocicni.PortMapping `json:"Ports"`
+ SandboxKey string `json:"SandboxKey"`
+ SecondaryIPAddresses []string `json:"SecondaryIPAddresses"`
+ SecondaryIPv6Addresses []string `json:"SecondaryIPv6Addresses"`
+ EndpointID string `json:"EndpointID"`
+ Gateway string `json:"Gateway"`
+ GlobalIPv6Addresses []string `json:"GlobalIPv6Addresses"`
+ GlobalIPv6PrefixLen int `json:"GlobalIPv6PrefixLen"`
+ IPAddress string `json:"IPAddress"`
+ IPPrefixLen int `json:"IPPrefixLen"`
+ IPv6Gateway string `json:"IPv6Gateway"`
+ MacAddress string `json:"MacAddress"`
}
// ImageData holds the inspect information of an image