2014-02-19 23:27:57 +00:00
|
|
|
package builtins
|
|
|
|
|
|
|
|
import (
|
2014-05-12 21:38:20 +00:00
|
|
|
"runtime"
|
|
|
|
|
2014-07-24 22:19:50 +00:00
|
|
|
"github.com/docker/docker/api"
|
|
|
|
apiserver "github.com/docker/docker/api/server"
|
2015-02-04 21:22:38 +00:00
|
|
|
"github.com/docker/docker/autogen/dockerversion"
|
2014-07-24 22:19:50 +00:00
|
|
|
"github.com/docker/docker/daemon/networkdriver/bridge"
|
|
|
|
"github.com/docker/docker/engine"
|
2014-07-31 11:50:59 +00:00
|
|
|
"github.com/docker/docker/events"
|
2014-07-29 00:23:38 +00:00
|
|
|
"github.com/docker/docker/pkg/parsers/kernel"
|
2014-02-19 23:27:57 +00:00
|
|
|
)
|
|
|
|
|
2014-05-03 00:54:52 +00:00
|
|
|
func Register(eng *engine.Engine) error {
|
|
|
|
if err := daemon(eng); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if err := remote(eng); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2014-07-31 11:50:59 +00:00
|
|
|
if err := events.New().Install(eng); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2014-05-12 21:38:20 +00:00
|
|
|
if err := eng.Register("version", dockerVersion); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2014-08-20 15:31:24 +00:00
|
|
|
|
|
|
|
return nil
|
2014-02-19 23:27:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// remote: a RESTful api for cross-docker communication
|
2014-05-03 00:54:52 +00:00
|
|
|
func remote(eng *engine.Engine) error {
|
2014-05-03 00:11:20 +00:00
|
|
|
if err := eng.Register("serveapi", apiserver.ServeApi); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return eng.Register("acceptconnections", apiserver.AcceptConnections)
|
2014-02-19 23:27:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// daemon: a default execution and storage backend for Docker on Linux,
|
|
|
|
// with the following underlying components:
|
|
|
|
//
|
|
|
|
// * Pluggable storage drivers including aufs, vfs, lvm and btrfs.
|
|
|
|
// * Pluggable execution drivers including lxc and chroot.
|
|
|
|
//
|
|
|
|
// In practice `daemon` still includes most core Docker components, including:
|
|
|
|
//
|
|
|
|
// * The reference registry client implementation
|
|
|
|
// * Image management
|
|
|
|
// * The build facility
|
|
|
|
// * Logging
|
|
|
|
//
|
|
|
|
// These components should be broken off into plugins of their own.
|
|
|
|
//
|
2014-05-03 00:54:52 +00:00
|
|
|
func daemon(eng *engine.Engine) error {
|
|
|
|
return eng.Register("init_networkdriver", bridge.InitDriver)
|
2014-02-19 23:27:57 +00:00
|
|
|
}
|
2014-05-12 21:38:20 +00:00
|
|
|
|
|
|
|
// builtins jobs independent of any subsystem
|
|
|
|
func dockerVersion(job *engine.Job) engine.Status {
|
|
|
|
v := &engine.Env{}
|
2014-06-08 23:06:47 +00:00
|
|
|
v.SetJson("Version", dockerversion.VERSION)
|
2014-05-12 21:38:20 +00:00
|
|
|
v.SetJson("ApiVersion", api.APIVERSION)
|
2014-09-15 23:35:07 +00:00
|
|
|
v.SetJson("GitCommit", dockerversion.GITCOMMIT)
|
2014-05-12 21:38:20 +00:00
|
|
|
v.Set("GoVersion", runtime.Version())
|
|
|
|
v.Set("Os", runtime.GOOS)
|
|
|
|
v.Set("Arch", runtime.GOARCH)
|
2014-07-29 00:23:38 +00:00
|
|
|
if kernelVersion, err := kernel.GetKernelVersion(); err == nil {
|
2014-05-12 21:38:20 +00:00
|
|
|
v.Set("KernelVersion", kernelVersion.String())
|
|
|
|
}
|
|
|
|
if _, err := v.WriteTo(job.Stdout); err != nil {
|
|
|
|
return job.Error(err)
|
|
|
|
}
|
|
|
|
return engine.StatusOK
|
|
|
|
}
|