1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Add DefaultAddressPools to docker info #40388

Signed-off-by: Wang Yumu <37442693@qq.com>
This commit is contained in:
Wang Yumu 2020-07-07 11:17:51 +08:00
parent 260c26b7be
commit 840a12ac90
3 changed files with 45 additions and 9 deletions

View file

@ -4676,6 +4676,25 @@ definitions:
such as number of nodes, and expiration are included.
type: "string"
example: "Community Engine"
DefaultAddressPools:
description: |
List of custom default address pools for local networks, which can be
specified in the daemon.json file or dockerd option.
Example: a Base "10.10.0.0/16" with Size 24 will define the set of 256
10.10.[0-255].0/24 address pools.
type: "array"
items:
type: "object"
properties:
Base:
description: "The network address in CIDR format"
type: "string"
example: "10.10.0.0/16"
Size:
description: "The network pool size"
type: "integer"
example: "24"
Warnings:
description: |
List of warnings / informational messages about missing features, or

View file

@ -203,15 +203,16 @@ type Info struct {
// LiveRestoreEnabled determines whether containers should be kept
// running when the daemon is shutdown or upon daemon start if
// running containers are detected
LiveRestoreEnabled bool
Isolation container.Isolation
InitBinary string
ContainerdCommit Commit
RuncCommit Commit
InitCommit Commit
SecurityOptions []string
ProductLicense string `json:",omitempty"`
Warnings []string
LiveRestoreEnabled bool
Isolation container.Isolation
InitBinary string
ContainerdCommit Commit
RuncCommit Commit
InitCommit Commit
SecurityOptions []string
ProductLicense string `json:",omitempty"`
DefaultAddressPools []NetworkAddressPool
Warnings []string
}
// KeyValue holds a key/value pair
@ -219,6 +220,12 @@ type KeyValue struct {
Key, Value string
}
// NetworkAddressPool is a temp struct used by Info struct
type NetworkAddressPool struct {
Base string
Size int
}
// SecurityOpt contains the name and options of a security option
type SecurityOpt struct {
Name string

View file

@ -78,6 +78,7 @@ func (daemon *Daemon) SystemInfo() *types.Info {
daemon.fillPluginsInfo(v)
daemon.fillSecurityOptions(v, sysInfo)
daemon.fillLicense(v)
daemon.fillDefaultAddressPools(v)
if v.DefaultRuntime == config.LinuxV1RuntimeName {
v.Warnings = append(v.Warnings, fmt.Sprintf("Configured default runtime %q is deprecated and will be removed in the next release.", config.LinuxV1RuntimeName))
@ -229,6 +230,15 @@ func (daemon *Daemon) fillAPIInfo(v *types.Info) {
}
}
func (daemon *Daemon) fillDefaultAddressPools(v *types.Info) {
for _, pool := range daemon.configStore.DefaultAddressPools.Value() {
v.DefaultAddressPools = append(v.DefaultAddressPools, types.NetworkAddressPool{
Base: pool.Base,
Size: pool.Size,
})
}
}
func hostName() string {
hostname := ""
if hn, err := os.Hostname(); err != nil {