diff options
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/kpod/pause.go | 38 | ||||
-rw-r--r-- | cmd/kpod/unpause.go | 38 |
2 files changed, 38 insertions, 38 deletions
diff --git a/cmd/kpod/pause.go b/cmd/kpod/pause.go index 094013e6d..dede89443 100644 --- a/cmd/kpod/pause.go +++ b/cmd/kpod/pause.go @@ -2,10 +2,10 @@ package main import ( "fmt" + "os" + "github.com/pkg/errors" - "github.com/projectatomic/libpod/libkpod" "github.com/urfave/cli" - "os" ) var ( @@ -24,35 +24,35 @@ var ( ) func pauseCmd(c *cli.Context) error { + runtime, err := getRuntime(c) + if err != nil { + return errors.Wrapf(err, "could not get runtime") + } + defer runtime.Shutdown(false) + args := c.Args() if len(args) < 1 { return errors.Errorf("you must provide at least one container name or id") } - config, err := getConfig(c) - if err != nil { - return errors.Wrapf(err, "could not get config") - } - server, err := libkpod.New(config) - if err != nil { - return errors.Wrapf(err, "could not get container server") - } - defer server.Shutdown() - if err := server.Update(); err != nil { - return errors.Wrapf(err, "could not update list of containers") - } var lastError error - for _, container := range c.Args() { - cid, err := server.ContainerPause(container) + for _, arg := range args { + ctr, err := runtime.LookupContainer(arg) if err != nil { if lastError != nil { fmt.Fprintln(os.Stderr, lastError) } - lastError = errors.Wrapf(err, "failed to pause container %v", container) + lastError = errors.Wrapf(err, "error looking up container %q", arg) + continue + } + if err = ctr.Pause(); err != nil { + if lastError != nil { + fmt.Fprintln(os.Stderr, lastError) + } + lastError = errors.Wrapf(err, "failed to pause container %v", ctr.ID()) } else { - fmt.Println(cid) + fmt.Println(ctr.ID()) } } - return lastError } diff --git a/cmd/kpod/unpause.go b/cmd/kpod/unpause.go index 47a2e3778..6deed7e77 100644 --- a/cmd/kpod/unpause.go +++ b/cmd/kpod/unpause.go @@ -2,10 +2,10 @@ package main import ( "fmt" + "os" + "github.com/pkg/errors" - "github.com/projectatomic/libpod/libkpod" "github.com/urfave/cli" - "os" ) var ( @@ -24,35 +24,35 @@ var ( ) func unpauseCmd(c *cli.Context) error { + runtime, err := getRuntime(c) + if err != nil { + return errors.Wrapf(err, "could not get runtime") + } + defer runtime.Shutdown(false) + args := c.Args() if len(args) < 1 { return errors.Errorf("you must provide at least one container name or id") } - config, err := getConfig(c) - if err != nil { - return errors.Wrapf(err, "could not get config") - } - server, err := libkpod.New(config) - if err != nil { - return errors.Wrapf(err, "could not get container server") - } - defer server.Shutdown() - if err := server.Update(); err != nil { - return errors.Wrapf(err, "could not update list of containers") - } var lastError error - for _, container := range c.Args() { - cid, err := server.ContainerUnpause(container) + for _, arg := range args { + ctr, err := runtime.LookupContainer(arg) if err != nil { if lastError != nil { fmt.Fprintln(os.Stderr, lastError) } - lastError = errors.Wrapf(err, "failed to unpause container %v", container) + lastError = errors.Wrapf(err, "error looking up container %q", arg) + continue + } + if err = ctr.Unpause(); err != nil { + if lastError != nil { + fmt.Fprintln(os.Stderr, lastError) + } + lastError = errors.Wrapf(err, "failed to unpause container %v", ctr.ID()) } else { - fmt.Println(cid) + fmt.Println(ctr.ID()) } } - return lastError } |