Merge pull request #3613 from vieux/deprecated_viz_job

move viz to a job
This commit is contained in:
Victor Vieux 2014-01-15 14:47:56 -08:00
commit f213e2dd6c
4 changed files with 29 additions and 25 deletions

View File

@ -4,16 +4,16 @@
TODO "/events": getEvents, N TODO "/events": getEvents, N
ok "/info": getInfo, 1 ok "/info": getInfo, 1
ok "/version": getVersion, 1 ok "/version": getVersion, 1
... "/images/json": getImagesJSON, N ok "/images/json": getImagesJSON, N
TODO "/images/viz": getImagesViz, 0 yes ok "/images/viz": getImagesViz, 0 yes
TODO "/images/search": getImagesSearch, N #3615 "/images/search": getImagesSearch, N
#3490 "/images/{name:.*}/get": getImagesGet, 0 ok "/images/{name:.*}/get": getImagesGet, 0
TODO "/images/{name:.*}/history": getImagesHistory, N ok "/images/{name:.*}/history": getImagesHistory, N
TODO "/images/{name:.*}/json": getImagesByName, 1 TODO "/images/{name:.*}/json": getImagesByName, 1
TODO "/containers/ps": getContainersJSON, N TODO "/containers/ps": getContainersJSON, N
TODO "/containers/json": getContainersJSON, 1 TODO "/containers/json": getContainersJSON, 1
ok "/containers/{name:.*}/export": getContainersExport, 0 ok "/containers/{name:.*}/export": getContainersExport, 0
TODO "/containers/{name:.*}/changes": getContainersChanges, N ... "/containers/{name:.*}/changes": getContainersChanges, N
TODO "/containers/{name:.*}/json": getContainersByName, 1 TODO "/containers/{name:.*}/json": getContainersByName, 1
TODO "/containers/{name:.*}/top": getContainersTop, N TODO "/containers/{name:.*}/top": getContainersTop, N
#3512 "/containers/{name:.*}/attach/ws": wsContainersAttach, 0 yes #3512 "/containers/{name:.*}/attach/ws": wsContainersAttach, 0 yes
@ -23,22 +23,22 @@ TODO "/auth": postAuth, 0
ok "/commit": postCommit, 0 ok "/commit": postCommit, 0
TODO "/build": postBuild, 0 yes TODO "/build": postBuild, 0 yes
TODO "/images/create": postImagesCreate, N yes yes (pull) TODO "/images/create": postImagesCreate, N yes yes (pull)
TODO "/images/{name:.*}/insert": postImagesInsert, N yes yes #3559 "/images/{name:.*}/insert": postImagesInsert, N yes yes
TODO "/images/load": postImagesLoad, 1 yes (stdin) TODO "/images/load": postImagesLoad, 1 yes (stdin)
TODO "/images/{name:.*}/push": postImagesPush, N yes TODO "/images/{name:.*}/push": postImagesPush, N yes
ok "/images/{name:.*}/tag": postImagesTag, 0 ok "/images/{name:.*}/tag": postImagesTag, 0
ok "/containers/create": postContainersCreate, 0 ok "/containers/create": postContainersCreate, 0
ok "/containers/{name:.*}/kill": postContainersKill, 0 ok "/containers/{name:.*}/kill": postContainersKill, 0
#3476 "/containers/{name:.*}/restart": postContainersRestart, 0 ok "/containers/{name:.*}/restart": postContainersRestart, 0
ok "/containers/{name:.*}/start": postContainersStart, 0 ok "/containers/{name:.*}/start": postContainersStart, 0
ok "/containers/{name:.*}/stop": postContainersStop, 0 ok "/containers/{name:.*}/stop": postContainersStop, 0
ok "/containers/{name:.*}/wait": postContainersWait, 0 ok "/containers/{name:.*}/wait": postContainersWait, 0
ok "/containers/{name:.*}/resize": postContainersResize, 0 ok "/containers/{name:.*}/resize": postContainersResize, 0
#3512 "/containers/{name:.*}/attach": postContainersAttach, 0 yes #3512 "/containers/{name:.*}/attach": postContainersAttach, 0 yes
TODO "/containers/{name:.*}/copy": postContainersCopy, 0 yes #3560 "/containers/{name:.*}/copy": postContainersCopy, 0 yes
**DELETE** **DELETE**
#3180 "/containers/{name:.*}": deleteContainers, 0 ok "/containers/{name:.*}": deleteContainers, 0
TODO "/images/{name:.*}": deleteImages, N TODO "/images/{name:.*}": deleteImages, N
**OPTIONS** **OPTIONS**

5
api.go
View File

@ -238,10 +238,7 @@ func getImagesViz(srv *Server, version float64, w http.ResponseWriter, r *http.R
w.WriteHeader(http.StatusNotFound) w.WriteHeader(http.StatusNotFound)
return fmt.Errorf("This is now implemented in the client.") return fmt.Errorf("This is now implemented in the client.")
} }
srv.Eng.ServeHTTP(w, r)
if err := srv.ImagesViz(w); err != nil {
return err
}
return nil return nil
} }

View File

@ -16,8 +16,10 @@ import (
// as the exit status. // as the exit status.
// //
func (eng *Engine) ServeHTTP(w http.ResponseWriter, r *http.Request) { func (eng *Engine) ServeHTTP(w http.ResponseWriter, r *http.Request) {
jobName := path.Base(r.URL.Path) var (
jobArgs, exists := r.URL.Query()["a"] jobName = path.Base(r.URL.Path)
jobArgs, exists = r.URL.Query()["a"]
)
if !exists { if !exists {
jobArgs = []string{} jobArgs = []string{}
} }

View File

@ -135,6 +135,10 @@ func jobInitApi(job *engine.Job) engine.Status {
job.Error(err) job.Error(err)
return engine.StatusErr return engine.StatusErr
} }
if err := job.Eng.Register("viz", srv.ImagesViz); err != nil {
job.Error(err)
return engine.StatusErr
}
return engine.StatusOK return engine.StatusOK
} }
@ -538,12 +542,12 @@ func (srv *Server) ImageInsert(name, url, path string, out io.Writer, sf *utils.
return nil return nil
} }
func (srv *Server) ImagesViz(out io.Writer) error { func (srv *Server) ImagesViz(job *engine.Job) engine.Status {
images, _ := srv.runtime.graph.Map() images, _ := srv.runtime.graph.Map()
if images == nil { if images == nil {
return nil return engine.StatusOK
} }
out.Write([]byte("digraph docker {\n")) job.Stdout.Write([]byte("digraph docker {\n"))
var ( var (
parentImage *Image parentImage *Image
@ -552,12 +556,13 @@ func (srv *Server) ImagesViz(out io.Writer) error {
for _, image := range images { for _, image := range images {
parentImage, err = image.GetParent() parentImage, err = image.GetParent()
if err != nil { if err != nil {
return fmt.Errorf("Error while getting parent image: %v", err) job.Errorf("Error while getting parent image: %v", err)
return engine.StatusErr
} }
if parentImage != nil { if parentImage != nil {
out.Write([]byte(" \"" + parentImage.ID + "\" -> \"" + image.ID + "\"\n")) job.Stdout.Write([]byte(" \"" + parentImage.ID + "\" -> \"" + image.ID + "\"\n"))
} else { } else {
out.Write([]byte(" base -> \"" + image.ID + "\" [style=invis]\n")) job.Stdout.Write([]byte(" base -> \"" + image.ID + "\" [style=invis]\n"))
} }
} }
@ -570,10 +575,10 @@ func (srv *Server) ImagesViz(out io.Writer) error {
} }
for id, repos := range reporefs { for id, repos := range reporefs {
out.Write([]byte(" \"" + id + "\" [label=\"" + id + "\\n" + strings.Join(repos, "\\n") + "\",shape=box,fillcolor=\"paleturquoise\",style=\"filled,rounded\"];\n")) job.Stdout.Write([]byte(" \"" + id + "\" [label=\"" + id + "\\n" + strings.Join(repos, "\\n") + "\",shape=box,fillcolor=\"paleturquoise\",style=\"filled,rounded\"];\n"))
} }
out.Write([]byte(" base [style=invisible]\n}\n")) job.Stdout.Write([]byte(" base [style=invisible]\n}\n"))
return nil return engine.StatusOK
} }
func (srv *Server) Images(job *engine.Job) engine.Status { func (srv *Server) Images(job *engine.Job) engine.Status {