2014-02-19 18:27:57 -05:00
|
|
|
package builtins
|
|
|
|
|
|
|
|
import (
|
2014-05-12 17:38:20 -04:00
|
|
|
"runtime"
|
|
|
|
|
2014-07-24 18:19:50 -04:00
|
|
|
"github.com/docker/docker/api"
|
|
|
|
apiserver "github.com/docker/docker/api/server"
|
|
|
|
"github.com/docker/docker/daemon/networkdriver/bridge"
|
|
|
|
"github.com/docker/docker/dockerversion"
|
|
|
|
"github.com/docker/docker/engine"
|
2014-07-31 07:50:59 -04:00
|
|
|
"github.com/docker/docker/events"
|
2014-07-28 20:23:38 -04:00
|
|
|
"github.com/docker/docker/pkg/parsers/kernel"
|
2014-07-24 18:19:50 -04:00
|
|
|
"github.com/docker/docker/registry"
|
|
|
|
"github.com/docker/docker/server"
|
2014-02-19 18:27:57 -05:00
|
|
|
)
|
|
|
|
|
2014-05-02 20:54:52 -04: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 07:50:59 -04:00
|
|
|
if err := events.New().Install(eng); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2014-05-12 17:38:20 -04:00
|
|
|
if err := eng.Register("version", dockerVersion); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2014-05-02 20:54:52 -04:00
|
|
|
return registry.NewService().Install(eng)
|
2014-02-19 18:27:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// remote: a RESTful api for cross-docker communication
|
2014-05-02 20:54:52 -04:00
|
|
|
func remote(eng *engine.Engine) error {
|
2014-05-02 20:11:20 -04:00
|
|
|
if err := eng.Register("serveapi", apiserver.ServeApi); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return eng.Register("acceptconnections", apiserver.AcceptConnections)
|
2014-02-19 18:27:57 -05: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-02 20:54:52 -04:00
|
|
|
func daemon(eng *engine.Engine) error {
|
|
|
|
if err := eng.Register("initserver", server.InitServer); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return eng.Register("init_networkdriver", bridge.InitDriver)
|
2014-02-19 18:27:57 -05:00
|
|
|
}
|
2014-05-12 17:38:20 -04:00
|
|
|
|
|
|
|
// builtins jobs independent of any subsystem
|
|
|
|
func dockerVersion(job *engine.Job) engine.Status {
|
|
|
|
v := &engine.Env{}
|
2014-06-08 19:06:47 -04:00
|
|
|
v.SetJson("Version", dockerversion.VERSION)
|
2014-05-12 17:38:20 -04:00
|
|
|
v.SetJson("ApiVersion", api.APIVERSION)
|
|
|
|
v.Set("GitCommit", dockerversion.GITCOMMIT)
|
|
|
|
v.Set("GoVersion", runtime.Version())
|
|
|
|
v.Set("Os", runtime.GOOS)
|
|
|
|
v.Set("Arch", runtime.GOARCH)
|
2014-07-28 20:23:38 -04:00
|
|
|
if kernelVersion, err := kernel.GetKernelVersion(); err == nil {
|
2014-05-12 17:38:20 -04:00
|
|
|
v.Set("KernelVersion", kernelVersion.String())
|
|
|
|
}
|
|
|
|
if _, err := v.WriteTo(job.Stdout); err != nil {
|
|
|
|
return job.Error(err)
|
|
|
|
}
|
|
|
|
return engine.StatusOK
|
|
|
|
}
|