summaryrefslogtreecommitdiff
path: root/pkg/varlinkapi/containers.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/varlinkapi/containers.go')
-rw-r--r--pkg/varlinkapi/containers.go45
1 files changed, 38 insertions, 7 deletions
diff --git a/pkg/varlinkapi/containers.go b/pkg/varlinkapi/containers.go
index 9468719fc..43ab3c995 100644
--- a/pkg/varlinkapi/containers.go
+++ b/pkg/varlinkapi/containers.go
@@ -67,11 +67,6 @@ func (i *LibpodAPI) GetContainer(call ioprojectatomicpodman.VarlinkCall, name st
return call.ReplyGetContainer(makeListContainer(ctr.ID(), batchInfo))
}
-// CreateContainer ...
-func (i *LibpodAPI) CreateContainer(call ioprojectatomicpodman.VarlinkCall) error {
- return call.ReplyMethodNotImplemented("CreateContainer")
-}
-
// InspectContainer ...
func (i *LibpodAPI) InspectContainer(call ioprojectatomicpodman.VarlinkCall, name string) error {
runtime, err := libpodruntime.GetRuntime(i.Cli)
@@ -264,8 +259,26 @@ func (i *LibpodAPI) ResizeContainerTty(call ioprojectatomicpodman.VarlinkCall) e
}
// StartContainer ...
-func (i *LibpodAPI) StartContainer(call ioprojectatomicpodman.VarlinkCall) error {
- return call.ReplyMethodNotImplemented("StartContainer")
+func (i *LibpodAPI) StartContainer(call ioprojectatomicpodman.VarlinkCall, name string) error {
+ runtime, err := libpodruntime.GetRuntime(i.Cli)
+ if err != nil {
+ return call.ReplyRuntimeError(err.Error())
+ }
+ ctr, err := runtime.LookupContainer(name)
+ if err != nil {
+ return call.ReplyContainerNotFound(name)
+ }
+ state, err := ctr.State()
+ if err != nil {
+ return call.ReplyErrorOccurred(err.Error())
+ }
+ if state == libpod.ContainerStateRunning || state == libpod.ContainerStatePaused {
+ return call.ReplyErrorOccurred("container is alrady running or paused")
+ }
+ if err := ctr.Start(getContext()); err != nil {
+ return call.ReplyErrorOccurred(err.Error())
+ }
+ return call.ReplyStartContainer(ctr.ID())
}
// StopContainer ...
@@ -429,3 +442,21 @@ func (i *LibpodAPI) DeleteStoppedContainers(call ioprojectatomicpodman.VarlinkCa
}
return call.ReplyDeleteStoppedContainers(deletedContainers)
}
+
+// GetAttachSockets ...
+func (i *LibpodAPI) GetAttachSockets(call ioprojectatomicpodman.VarlinkCall, name string) error {
+ runtime, err := libpodruntime.GetRuntime(i.Cli)
+ if err != nil {
+ return call.ReplyRuntimeError(err.Error())
+ }
+ ctr, err := runtime.LookupContainer(name)
+ if err != nil {
+ return call.ReplyContainerNotFound(name)
+ }
+ s := ioprojectatomicpodman.Sockets{
+ Container_id: ctr.ID(),
+ Io_socket: ctr.AttachSocketPath(),
+ Control_socket: ctr.ControlSocketPath(),
+ }
+ return call.ReplyGetAttachSockets(s)
+}