mirror of https://github.com/containers/podman.git
compat: Add DefaultAddressPools field to GET /info
Signed-off-by: Nicola Sella <nsella@redhat.com>
This commit is contained in:
parent
ee283c7514
commit
7c0262db3d
|
@ -55,53 +55,54 @@ func GetInfo(w http.ResponseWriter, r *http.Request) {
|
|||
// liveRestoreEnabled := criu.CheckForCriu() && configInfo.RuntimeSupportsCheckpoint()
|
||||
info := &handlers.Info{
|
||||
Info: dockerSystem.Info{
|
||||
Architecture: goRuntime.GOARCH,
|
||||
BridgeNfIP6tables: !sysInfo.BridgeNFCallIP6TablesDisabled,
|
||||
BridgeNfIptables: !sysInfo.BridgeNFCallIPTablesDisabled,
|
||||
CPUCfsPeriod: sysInfo.CPUCfsPeriod,
|
||||
CPUCfsQuota: sysInfo.CPUCfsQuota,
|
||||
CPUSet: sysInfo.Cpuset,
|
||||
CPUShares: sysInfo.CPUShares,
|
||||
CgroupDriver: configInfo.Engine.CgroupManager,
|
||||
ContainerdCommit: dockerSystem.Commit{},
|
||||
Containers: infoData.Store.ContainerStore.Number,
|
||||
ContainersPaused: stateInfo[define.ContainerStatePaused],
|
||||
ContainersRunning: stateInfo[define.ContainerStateRunning],
|
||||
ContainersStopped: stateInfo[define.ContainerStateStopped] + stateInfo[define.ContainerStateExited],
|
||||
Debug: log.IsLevelEnabled(log.DebugLevel),
|
||||
DefaultRuntime: configInfo.Engine.OCIRuntime,
|
||||
DockerRootDir: infoData.Store.GraphRoot,
|
||||
Driver: infoData.Store.GraphDriverName,
|
||||
DriverStatus: getGraphStatus(infoData.Store.GraphStatus),
|
||||
ExperimentalBuild: true,
|
||||
GenericResources: nil,
|
||||
HTTPProxy: getEnv("http_proxy"),
|
||||
HTTPSProxy: getEnv("https_proxy"),
|
||||
ID: uuid.New().String(),
|
||||
IPv4Forwarding: !sysInfo.IPv4ForwardingDisabled,
|
||||
Images: infoData.Store.ImageStore.Number,
|
||||
IndexServerAddress: "",
|
||||
InitBinary: "",
|
||||
InitCommit: dockerSystem.Commit{},
|
||||
Isolation: "",
|
||||
KernelMemoryTCP: false,
|
||||
KernelVersion: infoData.Host.Kernel,
|
||||
Labels: nil,
|
||||
LiveRestoreEnabled: false,
|
||||
LoggingDriver: "",
|
||||
MemTotal: infoData.Host.MemTotal,
|
||||
MemoryLimit: sysInfo.MemoryLimit,
|
||||
NCPU: goRuntime.NumCPU(),
|
||||
NEventsListener: 0,
|
||||
NFd: getFdCount(),
|
||||
NGoroutines: goRuntime.NumGoroutine(),
|
||||
Name: infoData.Host.Hostname,
|
||||
NoProxy: getEnv("no_proxy"),
|
||||
OSType: goRuntime.GOOS,
|
||||
OSVersion: infoData.Host.Distribution.Version,
|
||||
OomKillDisable: sysInfo.OomKillDisable,
|
||||
OperatingSystem: infoData.Host.Distribution.Distribution,
|
||||
PidsLimit: sysInfo.PidsLimit,
|
||||
Architecture: goRuntime.GOARCH,
|
||||
BridgeNfIP6tables: !sysInfo.BridgeNFCallIP6TablesDisabled,
|
||||
BridgeNfIptables: !sysInfo.BridgeNFCallIPTablesDisabled,
|
||||
CPUCfsPeriod: sysInfo.CPUCfsPeriod,
|
||||
CPUCfsQuota: sysInfo.CPUCfsQuota,
|
||||
CPUSet: sysInfo.Cpuset,
|
||||
CPUShares: sysInfo.CPUShares,
|
||||
CgroupDriver: configInfo.Engine.CgroupManager,
|
||||
ContainerdCommit: dockerSystem.Commit{},
|
||||
Containers: infoData.Store.ContainerStore.Number,
|
||||
ContainersPaused: stateInfo[define.ContainerStatePaused],
|
||||
ContainersRunning: stateInfo[define.ContainerStateRunning],
|
||||
ContainersStopped: stateInfo[define.ContainerStateStopped] + stateInfo[define.ContainerStateExited],
|
||||
Debug: log.IsLevelEnabled(log.DebugLevel),
|
||||
DefaultAddressPools: getDefaultAddressPools(configInfo),
|
||||
DefaultRuntime: configInfo.Engine.OCIRuntime,
|
||||
DockerRootDir: infoData.Store.GraphRoot,
|
||||
Driver: infoData.Store.GraphDriverName,
|
||||
DriverStatus: getGraphStatus(infoData.Store.GraphStatus),
|
||||
ExperimentalBuild: true,
|
||||
GenericResources: nil,
|
||||
HTTPProxy: getEnv("http_proxy"),
|
||||
HTTPSProxy: getEnv("https_proxy"),
|
||||
ID: uuid.New().String(),
|
||||
IPv4Forwarding: !sysInfo.IPv4ForwardingDisabled,
|
||||
Images: infoData.Store.ImageStore.Number,
|
||||
IndexServerAddress: "",
|
||||
InitBinary: "",
|
||||
InitCommit: dockerSystem.Commit{},
|
||||
Isolation: "",
|
||||
KernelMemoryTCP: false,
|
||||
KernelVersion: infoData.Host.Kernel,
|
||||
Labels: nil,
|
||||
LiveRestoreEnabled: false,
|
||||
LoggingDriver: "",
|
||||
MemTotal: infoData.Host.MemTotal,
|
||||
MemoryLimit: sysInfo.MemoryLimit,
|
||||
NCPU: goRuntime.NumCPU(),
|
||||
NEventsListener: 0,
|
||||
NFd: getFdCount(),
|
||||
NGoroutines: goRuntime.NumGoroutine(),
|
||||
Name: infoData.Host.Hostname,
|
||||
NoProxy: getEnv("no_proxy"),
|
||||
OSType: goRuntime.GOOS,
|
||||
OSVersion: infoData.Host.Distribution.Version,
|
||||
OomKillDisable: sysInfo.OomKillDisable,
|
||||
OperatingSystem: infoData.Host.Distribution.Distribution,
|
||||
PidsLimit: sysInfo.PidsLimit,
|
||||
Plugins: dockerSystem.PluginsInfo{
|
||||
Volume: infoData.Plugins.Volume,
|
||||
Network: infoData.Plugins.Network,
|
||||
|
@ -237,3 +238,24 @@ func getEnv(value string) string {
|
|||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func getDefaultAddressPools(configInfo *config.Config) []dockerSystem.NetworkAddressPool {
|
||||
// Convert DefaultSubnetPools to DefaultAddressPools
|
||||
if len(configInfo.Network.DefaultSubnetPools) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
pools := make([]dockerSystem.NetworkAddressPool, 0, len(configInfo.Network.DefaultSubnetPools))
|
||||
for _, pool := range configInfo.Network.DefaultSubnetPools {
|
||||
if pool.Base == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
pools = append(pools, dockerSystem.NetworkAddressPool{
|
||||
Base: pool.Base.String(),
|
||||
Size: pool.Size,
|
||||
})
|
||||
}
|
||||
|
||||
return pools
|
||||
}
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
# -*- sh -*-
|
||||
#
|
||||
# subnet pools conversion tests
|
||||
#
|
||||
|
||||
# Create a temporary containers.conf with custom DefaultSubnetPools
|
||||
testdir=$(mktemp -d)
|
||||
cat > $testdir/containers.default_subnet_pools.conf <<EOF
|
||||
[network]
|
||||
default_subnet_pools = [
|
||||
{ "base" = "10.89.0.0/16", "size" = 24 },
|
||||
{ "base" = "10.90.0.0/15", "size" = 26 }
|
||||
]
|
||||
EOF
|
||||
|
||||
# Restart podman with custom config
|
||||
stop_service
|
||||
CONTAINERS_CONF=$testdir/containers.default_subnet_pools.conf start_service
|
||||
|
||||
# Test the Docker-compatible API endpoints
|
||||
t GET info 200 \
|
||||
'.DefaultAddressPools | length=2' \
|
||||
'.DefaultAddressPools[0].Base=10.89.0.0/16' \
|
||||
'.DefaultAddressPools[0].Size=24' \
|
||||
'.DefaultAddressPools[1].Base=10.90.0.0/15' \
|
||||
'.DefaultAddressPools[1].Size=26'
|
||||
|
||||
# Restart with the default containers.conf for next tests.
|
||||
rm -rf $testdir
|
||||
stop_service
|
||||
start_service
|
Loading…
Reference in New Issue