From e290a22dc935c2472e08be7362b7d3b0f6303615 Mon Sep 17 00:00:00 2001 From: Antonio Murdaca Date: Thu, 9 Apr 2015 23:51:22 +0200 Subject: [PATCH] Remove job from resize&execResize Signed-off-by: Antonio Murdaca --- api/server/server.go | 33 +++++++++++++++++++++++++++++++-- daemon/daemon.go | 2 -- daemon/resize.go | 44 +------------------------------------------- 3 files changed, 32 insertions(+), 47 deletions(-) diff --git a/api/server/server.go b/api/server/server.go index 97bf08bb06..912af638ce 100644 --- a/api/server/server.go +++ b/api/server/server.go @@ -1005,9 +1005,26 @@ func postContainersResize(eng *engine.Engine, version version.Version, w http.Re if vars == nil { return fmt.Errorf("Missing parameter") } - if err := eng.Job("resize", vars["name"], r.Form.Get("h"), r.Form.Get("w")).Run(); err != nil { + + height, err := strconv.Atoi(r.Form.Get("h")) + if err != nil { + return nil + } + width, err := strconv.Atoi(r.Form.Get("w")) + if err != nil { + return nil + } + + d := getDaemon(eng) + cont, err := d.Get(vars["name"]) + if err != nil { return err } + + if err := cont.Resize(height, width); err != nil { + return err + } + return nil } @@ -1363,9 +1380,21 @@ func postContainerExecResize(eng *engine.Engine, version version.Version, w http if vars == nil { return fmt.Errorf("Missing parameter") } - if err := eng.Job("execResize", vars["name"], r.Form.Get("h"), r.Form.Get("w")).Run(); err != nil { + + height, err := strconv.Atoi(r.Form.Get("h")) + if err != nil { + return nil + } + width, err := strconv.Atoi(r.Form.Get("w")) + if err != nil { + return nil + } + + d := getDaemon(eng) + if err := d.ContainerExecResize(vars["name"], height, width); err != nil { return err } + return nil } diff --git a/daemon/daemon.go b/daemon/daemon.go index 36d05cd92c..06e9bb440a 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -125,7 +125,6 @@ func (daemon *Daemon) Install(eng *engine.Engine) error { "info": daemon.CmdInfo, "kill": daemon.ContainerKill, "logs": daemon.ContainerLogs, - "resize": daemon.ContainerResize, "restart": daemon.ContainerRestart, "start": daemon.ContainerStart, "stop": daemon.ContainerStop, @@ -133,7 +132,6 @@ func (daemon *Daemon) Install(eng *engine.Engine) error { "wait": daemon.ContainerWait, "execCreate": daemon.ContainerExecCreate, "execStart": daemon.ContainerExecStart, - "execResize": daemon.ContainerExecResize, "execInspect": daemon.ContainerExecInspect, } { if err := eng.Register(name, method); err != nil { diff --git a/daemon/resize.go b/daemon/resize.go index fce06753e0..060634b13b 100644 --- a/daemon/resize.go +++ b/daemon/resize.go @@ -1,48 +1,6 @@ package daemon -import ( - "fmt" - "strconv" - - "github.com/docker/docker/engine" -) - -func (daemon *Daemon) ContainerResize(job *engine.Job) error { - if len(job.Args) != 3 { - return fmt.Errorf("Not enough arguments. Usage: %s CONTAINER HEIGHT WIDTH\n", job.Name) - } - name := job.Args[0] - height, err := strconv.Atoi(job.Args[1]) - if err != nil { - return err - } - width, err := strconv.Atoi(job.Args[2]) - if err != nil { - return err - } - container, err := daemon.Get(name) - if err != nil { - return err - } - if err := container.Resize(height, width); err != nil { - return err - } - return nil -} - -func (daemon *Daemon) ContainerExecResize(job *engine.Job) error { - if len(job.Args) != 3 { - return fmt.Errorf("Not enough arguments. Usage: %s EXEC HEIGHT WIDTH\n", job.Name) - } - name := job.Args[0] - height, err := strconv.Atoi(job.Args[1]) - if err != nil { - return err - } - width, err := strconv.Atoi(job.Args[2]) - if err != nil { - return err - } +func (daemon *Daemon) ContainerExecResize(name string, height, width int) error { execConfig, err := daemon.getExecConfig(name) if err != nil { return err