Merge pull request #17300 from kunalkushwaha/plugin-info

Patch for Plugin drivers in docker info
This commit is contained in:
Alexander Morozov 2015-11-17 10:46:29 -08:00
commit f18d5da6a7
8 changed files with 79 additions and 0 deletions

View file

@ -44,6 +44,19 @@ func (cli *DockerCli) CmdInfo(args ...string) error {
}
ioutils.FprintfIfNotEmpty(cli.out, "Execution Driver: %s\n", info.ExecutionDriver)
ioutils.FprintfIfNotEmpty(cli.out, "Logging Driver: %s\n", info.LoggingDriver)
fmt.Fprintf(cli.out, "Plugins: \n")
fmt.Fprintf(cli.out, " Volume:")
for _, driver := range info.Plugins.Volume {
fmt.Fprintf(cli.out, " %s", driver)
}
fmt.Fprintf(cli.out, "\n")
fmt.Fprintf(cli.out, " Network:")
for _, driver := range info.Plugins.Network {
fmt.Fprintf(cli.out, " %s", driver)
}
fmt.Fprintf(cli.out, "\n")
ioutils.FprintfIfNotEmpty(cli.out, "Kernel Version: %s\n", info.KernelVersion)
ioutils.FprintfIfNotEmpty(cli.out, "Operating System: %s\n", info.OperatingSystem)
fmt.Fprintf(cli.out, "CPUs: %d\n", info.NCPU)

View file

@ -188,6 +188,7 @@ type Info struct {
Images int
Driver string
DriverStatus [][2]string
Plugins PluginsInfo
MemoryLimit bool
SwapLimit bool
CPUCfsPeriod bool `json:"CpuCfsPeriod"`
@ -225,6 +226,15 @@ type Info struct {
ClusterAdvertise string
}
// PluginsInfo is temp struct holds Plugins name
// registered with docker daemon. It used by Info struct
type PluginsInfo struct {
// List of Volume plugins registered
Volume []string
// List of Network plugins registered
Network []string
}
// ExecStartCheck is a temp struct used by execStart
// Config fields is part of ExecConfig in runconfig package
type ExecStartCheck struct {

View file

@ -15,6 +15,7 @@ import (
"github.com/docker/docker/pkg/system"
"github.com/docker/docker/registry"
"github.com/docker/docker/utils"
"github.com/docker/docker/volume/drivers"
)
// SystemInfo returns information about the host server the daemon is running on.
@ -62,6 +63,7 @@ func (daemon *Daemon) SystemInfo() (*types.Info, error) {
Images: len(daemon.Graph().Map()),
Driver: daemon.GraphDriver().String(),
DriverStatus: daemon.GraphDriver().Status(),
Plugins: daemon.showPluginsInfo(),
IPv4Forwarding: !sysInfo.IPv4ForwardingDisabled,
BridgeNfIptables: !sysInfo.BridgeNfCallIptablesDisabled,
BridgeNfIP6tables: !sysInfo.BridgeNfCallIP6tablesDisabled,
@ -111,3 +113,16 @@ func (daemon *Daemon) SystemInfo() (*types.Info, error) {
return v, nil
}
func (daemon *Daemon) showPluginsInfo() types.PluginsInfo {
var pluginsInfo types.PluginsInfo
pluginsInfo.Volume = volumedrivers.GetDriverList()
networkDriverList := daemon.GetNetworkDriverList()
for nd := range networkDriverList {
pluginsInfo.Network = append(pluginsInfo.Network, nd)
}
return pluginsInfo
}

View file

@ -146,3 +146,19 @@ func (daemon *Daemon) DisconnectContainerFromNetwork(containerName string, netwo
}
return container.DisconnectFromNetwork(network)
}
// GetNetworkDriverList returns the list of plugins drivers
// registered for network.
func (daemon *Daemon) GetNetworkDriverList() map[string]bool {
pluginList := make(map[string]bool)
c := daemon.netController
networks := c.Networks()
for _, network := range networks {
driver := network.Type()
pluginList[driver] = true
}
return pluginList
}

View file

@ -1891,6 +1891,16 @@ Display system-wide information
"DockerRootDir": "/var/lib/docker",
"Driver": "btrfs",
"DriverStatus": [[""]],
"Plugins": {
"Volume": [
"local"
],
"Network": [
"null",
"host",
"bridge"
]
},
"ExecutionDriver": "native-0.1",
"ExperimentalBuild": false,
"HttpProxy": "http://test:test@localhost:8080",

View file

@ -25,6 +25,8 @@ func (s *DockerSuite) TestInfoEnsureSucceeds(c *check.C) {
"Total Memory:",
"Kernel Version:",
"Storage Driver:",
"Volume:",
"Network:",
}
if utils.ExperimentalBuild() {

View file

@ -39,6 +39,9 @@ Here is a sample output:
Dirs: 80
Execution Driver: native-0.2
Logging Driver: json-file
Plugins:
Volume: local
Network: bridge null host
Kernel Version: 3.13.0-24-generic
Operating System: Ubuntu 14.04 LTS
CPUs: 1

View file

@ -106,3 +106,13 @@ func GetDriver(name string) (volume.Driver, error) {
}
return Lookup(name)
}
// GetDriverList returns list of volume drivers registered.
// If no driver is registered, empty string list will be returned.
func GetDriverList() []string {
var driverList []string
for driverName := range drivers.extensions {
driverList = append(driverList, driverName)
}
return driverList
}