Browse code

Supported added for reterving Plugin list for Network and Volume. Also, plugin information in docker info output.

Signed-off-by: Kunal Kushwaha <kushwaha_kunal_v7@lab.ntt.co.jp>

Kunal Kushwaha authored on 2015/10/23 15:08:26
Showing 8 changed files
... ...
@@ -44,6 +44,19 @@ func (cli *DockerCli) CmdInfo(args ...string) error {
44 44
 	}
45 45
 	ioutils.FprintfIfNotEmpty(cli.out, "Execution Driver: %s\n", info.ExecutionDriver)
46 46
 	ioutils.FprintfIfNotEmpty(cli.out, "Logging Driver: %s\n", info.LoggingDriver)
47
+
48
+	fmt.Fprintf(cli.out, "Plugins: \n")
49
+	fmt.Fprintf(cli.out, " Volume:")
50
+	for _, driver := range info.Plugins.Volume {
51
+		fmt.Fprintf(cli.out, " %s", driver)
52
+	}
53
+	fmt.Fprintf(cli.out, "\n")
54
+	fmt.Fprintf(cli.out, " Network:")
55
+	for _, driver := range info.Plugins.Network {
56
+		fmt.Fprintf(cli.out, " %s", driver)
57
+	}
58
+	fmt.Fprintf(cli.out, "\n")
59
+
47 60
 	ioutils.FprintfIfNotEmpty(cli.out, "Kernel Version: %s\n", info.KernelVersion)
48 61
 	ioutils.FprintfIfNotEmpty(cli.out, "Operating System: %s\n", info.OperatingSystem)
49 62
 	fmt.Fprintf(cli.out, "CPUs: %d\n", info.NCPU)
... ...
@@ -188,6 +188,7 @@ type Info struct {
188 188
 	Images             int
189 189
 	Driver             string
190 190
 	DriverStatus       [][2]string
191
+	Plugins            PluginsInfo
191 192
 	MemoryLimit        bool
192 193
 	SwapLimit          bool
193 194
 	CPUCfsPeriod       bool `json:"CpuCfsPeriod"`
... ...
@@ -225,6 +226,15 @@ type Info struct {
225 225
 	ClusterAdvertise   string
226 226
 }
227 227
 
228
+// PluginsInfo is temp struct holds Plugins name
229
+// registered with docker daemon. It used by Info struct
230
+type PluginsInfo struct {
231
+	// List of Volume plugins registered
232
+	Volume []string
233
+	// List of Network plugins registered
234
+	Network []string
235
+}
236
+
228 237
 // ExecStartCheck is a temp struct used by execStart
229 238
 // Config fields is part of ExecConfig in runconfig package
230 239
 type ExecStartCheck struct {
... ...
@@ -15,6 +15,7 @@ import (
15 15
 	"github.com/docker/docker/pkg/system"
16 16
 	"github.com/docker/docker/registry"
17 17
 	"github.com/docker/docker/utils"
18
+	"github.com/docker/docker/volume/drivers"
18 19
 )
19 20
 
20 21
 // SystemInfo returns information about the host server the daemon is running on.
... ...
@@ -62,6 +63,7 @@ func (daemon *Daemon) SystemInfo() (*types.Info, error) {
62 62
 		Images:             len(daemon.Graph().Map()),
63 63
 		Driver:             daemon.GraphDriver().String(),
64 64
 		DriverStatus:       daemon.GraphDriver().Status(),
65
+		Plugins:            daemon.showPluginsInfo(),
65 66
 		IPv4Forwarding:     !sysInfo.IPv4ForwardingDisabled,
66 67
 		BridgeNfIptables:   !sysInfo.BridgeNfCallIptablesDisabled,
67 68
 		BridgeNfIP6tables:  !sysInfo.BridgeNfCallIP6tablesDisabled,
... ...
@@ -111,3 +113,16 @@ func (daemon *Daemon) SystemInfo() (*types.Info, error) {
111 111
 
112 112
 	return v, nil
113 113
 }
114
+
115
+func (daemon *Daemon) showPluginsInfo() types.PluginsInfo {
116
+	var pluginsInfo types.PluginsInfo
117
+
118
+	pluginsInfo.Volume = volumedrivers.GetDriverList()
119
+
120
+	networkDriverList := daemon.GetNetworkDriverList()
121
+	for nd := range networkDriverList {
122
+		pluginsInfo.Network = append(pluginsInfo.Network, nd)
123
+	}
124
+
125
+	return pluginsInfo
126
+}
... ...
@@ -146,3 +146,19 @@ func (daemon *Daemon) DisconnectContainerFromNetwork(containerName string, netwo
146 146
 	}
147 147
 	return container.DisconnectFromNetwork(network)
148 148
 }
149
+
150
+// GetNetworkDriverList returns the list of plugins drivers
151
+// registered for network.
152
+func (daemon *Daemon) GetNetworkDriverList() map[string]bool {
153
+	pluginList := make(map[string]bool)
154
+
155
+	c := daemon.netController
156
+	networks := c.Networks()
157
+
158
+	for _, network := range networks {
159
+		driver := network.Type()
160
+		pluginList[driver] = true
161
+	}
162
+
163
+	return pluginList
164
+}
... ...
@@ -1891,6 +1891,16 @@ Display system-wide information
1891 1891
         "DockerRootDir": "/var/lib/docker",
1892 1892
         "Driver": "btrfs",
1893 1893
         "DriverStatus": [[""]],
1894
+	"Plugins": {
1895
+		"Volume": [
1896
+			"local"
1897
+		],
1898
+		"Network": [
1899
+			"null",
1900
+			"host",
1901
+			"bridge"
1902
+		]
1903
+	},
1894 1904
         "ExecutionDriver": "native-0.1",
1895 1905
         "ExperimentalBuild": false,
1896 1906
         "HttpProxy": "http://test:test@localhost:8080",
... ...
@@ -25,6 +25,8 @@ func (s *DockerSuite) TestInfoEnsureSucceeds(c *check.C) {
25 25
 		"Total Memory:",
26 26
 		"Kernel Version:",
27 27
 		"Storage Driver:",
28
+		"Volume:",
29
+		"Network:",
28 30
 	}
29 31
 
30 32
 	if utils.ExperimentalBuild() {
... ...
@@ -39,6 +39,9 @@ Here is a sample output:
39 39
      Dirs: 80
40 40
     Execution Driver: native-0.2
41 41
     Logging Driver: json-file
42
+    Plugins:
43
+     Volume: local
44
+     Network: bridge null host
42 45
     Kernel Version: 3.13.0-24-generic
43 46
     Operating System: Ubuntu 14.04 LTS
44 47
     CPUs: 1
... ...
@@ -106,3 +106,13 @@ func GetDriver(name string) (volume.Driver, error) {
106 106
 	}
107 107
 	return Lookup(name)
108 108
 }
109
+
110
+// GetDriverList returns list of volume drivers registered.
111
+// If no driver is registered, empty string list will be returned.
112
+func GetDriverList() []string {
113
+	var driverList []string
114
+	for driverName := range drivers.extensions {
115
+		driverList = append(driverList, driverName)
116
+	}
117
+	return driverList
118
+}