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

Merge pull request #33 from alexlarsson/dm-plugin-status

Add driver plugin status
This commit is contained in:
Michael Crosby 2013-11-15 10:15:59 -08:00
commit 7cad77b1e2
7 changed files with 44 additions and 9 deletions

View file

@ -52,15 +52,17 @@ type APIInfo struct {
Debug bool Debug bool
Containers int Containers int
Images int Images int
NFd int `json:",omitempty"` Driver string `json:",omitempty"`
NGoroutines int `json:",omitempty"` DriverStatus [][2]string `json:",omitempty"`
MemoryLimit bool `json:",omitempty"` NFd int `json:",omitempty"`
SwapLimit bool `json:",omitempty"` NGoroutines int `json:",omitempty"`
IPv4Forwarding bool `json:",omitempty"` MemoryLimit bool `json:",omitempty"`
LXCVersion string `json:",omitempty"` SwapLimit bool `json:",omitempty"`
NEventsListener int `json:",omitempty"` IPv4Forwarding bool `json:",omitempty"`
KernelVersion string `json:",omitempty"` LXCVersion string `json:",omitempty"`
IndexServerAddress string `json:",omitempty"` NEventsListener int `json:",omitempty"`
KernelVersion string `json:",omitempty"`
IndexServerAddress string `json:",omitempty"`
} }
type APITop struct { type APITop struct {

View file

@ -103,6 +103,10 @@ func (a *AufsDriver) String() string {
return "aufs" return "aufs"
} }
func (d *AufsDriver) Status() [][2]string {
return nil
}
// Three folders are created for each id // Three folders are created for each id
// mnt, layers, and diff // mnt, layers, and diff
func (a *AufsDriver) Create(id, parent string) error { func (a *AufsDriver) Create(id, parent string) error {

View file

@ -460,6 +460,10 @@ func (cli *DockerCli) CmdInfo(args ...string) error {
fmt.Fprintf(cli.out, "Containers: %d\n", out.Containers) fmt.Fprintf(cli.out, "Containers: %d\n", out.Containers)
fmt.Fprintf(cli.out, "Images: %d\n", out.Images) fmt.Fprintf(cli.out, "Images: %d\n", out.Images)
fmt.Fprintf(cli.out, "Driver: %s\n", out.Driver)
for _, pair := range out.DriverStatus {
fmt.Fprintf(cli.out, " %s: %s\n", pair[0], pair[1])
}
if out.Debug || os.Getenv("DEBUG") != "" { if out.Debug || os.Getenv("DEBUG") != "" {
fmt.Fprintf(cli.out, "Debug mode (server): %v\n", out.Debug) fmt.Fprintf(cli.out, "Debug mode (server): %v\n", out.Debug)
fmt.Fprintf(cli.out, "Debug mode (client): %v\n", os.Getenv("DEBUG") != "") fmt.Fprintf(cli.out, "Debug mode (client): %v\n", os.Getenv("DEBUG") != "")

View file

@ -37,6 +37,21 @@ func (d *Driver) String() string {
return "devicemapper" return "devicemapper"
} }
func (d *Driver) Status() [][2]string {
s := d.DeviceSet.Status()
status := [][2]string{
{"Pool Name", s.PoolName},
{"Data file", s.DataLoopback},
{"Metadata file", s.MetadataLoopback},
{"Data Space Used", fmt.Sprintf("%.1f Mb", float64(s.Data.Used)/(1024*1024))},
{"Data Space Total", fmt.Sprintf("%.1f Mb", float64(s.Data.Total)/(1024*1024))},
{"Metadata Space Used", fmt.Sprintf("%.1f Mb", float64(s.Metadata.Used)/(1024*1024))},
{"Metadata Space Total", fmt.Sprintf("%.1f Mb", float64(s.Metadata.Total)/(1024*1024))},
}
return status
}
func (d *Driver) Cleanup() error { func (d *Driver) Cleanup() error {
return d.DeviceSet.Shutdown() return d.DeviceSet.Shutdown()
} }

View file

@ -11,12 +11,16 @@ import (
type InitFunc func(root string) (Driver, error) type InitFunc func(root string) (Driver, error)
type Driver interface { type Driver interface {
String() string
Create(id, parent string) error Create(id, parent string) error
Remove(id string) error Remove(id string) error
Get(id string) (dir string, err error) Get(id string) (dir string, err error)
Size(id string) (bytes int64, err error) Size(id string) (bytes int64, err error)
Status() [][2]string
Cleanup() error Cleanup() error
} }

View file

@ -27,6 +27,10 @@ func (d *Driver) String() string {
return "dummy" return "dummy"
} }
func (d *Driver) Status() [][2]string {
return nil
}
func (d *Driver) Cleanup() error { func (d *Driver) Cleanup() error {
return nil return nil
} }

View file

@ -375,6 +375,8 @@ func (srv *Server) DockerInfo() *APIInfo {
return &APIInfo{ return &APIInfo{
Containers: len(srv.runtime.List()), Containers: len(srv.runtime.List()),
Images: imgcount, Images: imgcount,
Driver: srv.runtime.driver.String(),
DriverStatus: srv.runtime.driver.Status(),
MemoryLimit: srv.runtime.capabilities.MemoryLimit, MemoryLimit: srv.runtime.capabilities.MemoryLimit,
SwapLimit: srv.runtime.capabilities.SwapLimit, SwapLimit: srv.runtime.capabilities.SwapLimit,
IPv4Forwarding: !srv.runtime.capabilities.IPv4ForwardingDisabled, IPv4Forwarding: !srv.runtime.capabilities.IPv4ForwardingDisabled,