Files
kata-containers/cli/pause.go
Graham whaley e757a592c1 SPDX: update cli and arch files to use SPDX
Many cli and arch files were using the 'older style' fairly full
Apache license text. The project standard is the shorter SPDX style.
Convert them over.

Fixes: #225

Signed-off-by: Graham whaley <graham.whaley@intel.com>
2018-04-17 17:30:44 +01:00

58 lines
1.4 KiB
Go

// Copyright (c) 2014,2015,2016 Docker, Inc.
// Copyright (c) 2017 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0
//
package main
import (
"github.com/urfave/cli"
)
var noteText = `Use "` + name + ` list" to identify container statuses.`
var pauseCLICommand = cli.Command{
Name: "pause",
Usage: "suspend all processes in a container",
ArgsUsage: `<container-id>
Where "<container-id>" is the container name to be paused.`,
Description: `The pause command suspends all processes in a container.
` + noteText,
Action: func(context *cli.Context) error {
return toggleContainerPause(context.Args().First(), true)
},
}
var resumeCLICommand = cli.Command{
Name: "resume",
Usage: "unpause all previously paused processes in a container",
ArgsUsage: `<container-id>
Where "<container-id>" is the container name to be resumed.`,
Description: `The resume command unpauses all processes in a container.
` + noteText,
Action: func(context *cli.Context) error {
return toggleContainerPause(context.Args().First(), false)
},
}
func toggleContainerPause(containerID string, pause bool) (err error) {
// Checks the MUST and MUST NOT from OCI runtime specification
_, sandboxID, err := getExistingContainerInfo(containerID)
if err != nil {
return err
}
if pause {
_, err = vci.PauseSandbox(sandboxID)
} else {
_, err = vci.ResumeSandbox(sandboxID)
}
return err
}