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
|
@ -69,6 +69,7 @@ func GetInfo(w http.ResponseWriter, r *http.Request) {
|
|||
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,
|
||||
|
@ -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