From aa7fd884e609d3d13df628600a1799e0e76444e9 Mon Sep 17 00:00:00 2001 From: Kunal Kushwaha Date: Fri, 23 Oct 2015 15:08:26 +0900 Subject: [PATCH] Supported added for reterving Plugin list for Network and Volume. Also, plugin information in docker info output. Signed-off-by: Kunal Kushwaha --- api/client/info.go | 13 +++++++++++++ api/types/types.go | 10 ++++++++++ daemon/info.go | 15 +++++++++++++++ daemon/network.go | 16 ++++++++++++++++ docs/reference/api/docker_remote_api_v1.22.md | 10 ++++++++++ integration-cli/docker_cli_info_test.go | 2 ++ man/docker-info.1.md | 3 +++ volume/drivers/extpoint.go | 10 ++++++++++ 8 files changed, 79 insertions(+) diff --git a/api/client/info.go b/api/client/info.go index 7d373e0e68..7e4d45b690 100644 --- a/api/client/info.go +++ b/api/client/info.go @@ -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) diff --git a/api/types/types.go b/api/types/types.go index b69bbaea6e..bd31eb8794 100644 --- a/api/types/types.go +++ b/api/types/types.go @@ -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 { diff --git a/daemon/info.go b/daemon/info.go index 9e15f0de19..eb4665f82a 100644 --- a/daemon/info.go +++ b/daemon/info.go @@ -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 +} diff --git a/daemon/network.go b/daemon/network.go index c1412cec89..4e2a76d35b 100644 --- a/daemon/network.go +++ b/daemon/network.go @@ -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 +} diff --git a/docs/reference/api/docker_remote_api_v1.22.md b/docs/reference/api/docker_remote_api_v1.22.md index fa14eed601..fee0842966 100644 --- a/docs/reference/api/docker_remote_api_v1.22.md +++ b/docs/reference/api/docker_remote_api_v1.22.md @@ -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", diff --git a/integration-cli/docker_cli_info_test.go b/integration-cli/docker_cli_info_test.go index 21b8e51682..3f622ca818 100644 --- a/integration-cli/docker_cli_info_test.go +++ b/integration-cli/docker_cli_info_test.go @@ -25,6 +25,8 @@ func (s *DockerSuite) TestInfoEnsureSucceeds(c *check.C) { "Total Memory:", "Kernel Version:", "Storage Driver:", + "Volume:", + "Network:", } if utils.ExperimentalBuild() { diff --git a/man/docker-info.1.md b/man/docker-info.1.md index f67a4fb00c..2abfb0b4ec 100644 --- a/man/docker-info.1.md +++ b/man/docker-info.1.md @@ -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 diff --git a/volume/drivers/extpoint.go b/volume/drivers/extpoint.go index 3927b29c4e..3783ec6e67 100644 --- a/volume/drivers/extpoint.go +++ b/volume/drivers/extpoint.go @@ -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 +}