api: add sandbox pause and resume API

By exporting the existing sandbox operations.

Signed-off-by: Peng Tao <bergwolf@gmail.com>
This commit is contained in:
Peng Tao 2018-04-17 17:22:28 +08:00
parent eb23771d5a
commit 5165de0d76
3 changed files with 18 additions and 4 deletions

View File

@ -46,6 +46,8 @@ type VCSandbox interface {
ID() string
SetAnnotations(annotations map[string]string) error
Pause() error
Resume() error
Release() error
}

View File

@ -54,3 +54,13 @@ func (p *Sandbox) GetContainer(containerID string) vc.VCContainer {
func (p *Sandbox) Release() error {
return nil
}
// Pause implements the VCSandbox function of the same name.
func (p *Sandbox) Pause() error {
return nil
}
// Resume implements the VCSandbox function of the same name.
func (p *Sandbox) Resume() error {
return nil
}

View File

@ -929,7 +929,8 @@ func (s *Sandbox) stop() error {
return s.setSandboxState(StateStopped)
}
func (s *Sandbox) pause() error {
// Pause pauses the sandbox
func (s *Sandbox) Pause() error {
if err := s.hypervisor.pauseSandbox(); err != nil {
return err
}
@ -937,7 +938,8 @@ func (s *Sandbox) pause() error {
return s.pauseSetStates()
}
func (s *Sandbox) resume() error {
// Resume resumes the sandbox
func (s *Sandbox) Resume() error {
if err := s.hypervisor.resumeSandbox(); err != nil {
return err
}
@ -1079,9 +1081,9 @@ func togglePauseSandbox(sandboxID string, pause bool) (*Sandbox, error) {
}
if pause {
err = p.pause()
err = p.Pause()
} else {
err = p.resume()
err = p.Resume()
}
if err != nil {