2014-02-19 18:27:57 -05:00
|
|
|
package builtins
|
|
|
|
|
|
|
|
import (
|
2014-05-12 17:38:20 -04:00
|
|
|
"runtime"
|
|
|
|
|
|
|
|
"github.com/dotcloud/docker/api"
|
|
|
|
apiserver "github.com/dotcloud/docker/api/server"
|
2014-04-17 17:43:01 -04:00
|
|
|
"github.com/dotcloud/docker/daemon/networkdriver/bridge"
|
2014-05-12 17:38:20 -04:00
|
|
|
"github.com/dotcloud/docker/dockerversion"
|
2014-03-20 17:51:28 -04:00
|
|
|
"github.com/dotcloud/docker/engine"
|
2014-04-27 18:06:09 -04:00
|
|
|
"github.com/dotcloud/docker/registry"
|
2014-03-11 13:40:06 -04:00
|
|
|
"github.com/dotcloud/docker/server"
|
2014-05-12 17:38:20 -04:00
|
|
|
"github.com/dotcloud/docker/utils"
|
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-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-12 17:38:20 -04:00
|
|
|
return eng.Register("serveapi", apiserver.ServeApi)
|
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{}
|
|
|
|
v.Set("Version", dockerversion.VERSION)
|
|
|
|
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)
|
|
|
|
if kernelVersion, err := utils.GetKernelVersion(); err == nil {
|
|
|
|
v.Set("KernelVersion", kernelVersion.String())
|
|
|
|
}
|
|
|
|
if _, err := v.WriteTo(job.Stdout); err != nil {
|
|
|
|
return job.Error(err)
|
|
|
|
}
|
|
|
|
return engine.StatusOK
|
|
|
|
}
|