diff options
author | baude <bbaude@redhat.com> | 2018-05-16 12:38:17 -0500 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-05-21 19:26:56 +0000 |
commit | 82feafecdda8040432c008d9b79e4f973009adfc (patch) | |
tree | 8edffbe531bcf47c40b34cd003e4063142fbc84f /pkg/varlinkapi/containers.go | |
parent | 687b165a737742e1f1930cd9782002d857e07aaf (diff) | |
download | podman-82feafecdda8040432c008d9b79e4f973009adfc.tar.gz podman-82feafecdda8040432c008d9b79e4f973009adfc.tar.bz2 podman-82feafecdda8040432c008d9b79e4f973009adfc.zip |
podman create, start, getattachsocket
First pass at implement API endpoints for create and start.
Signed-off-by: baude <bbaude@redhat.com>
Closes: #805
Approved by: baude
Diffstat (limited to 'pkg/varlinkapi/containers.go')
-rw-r--r-- | pkg/varlinkapi/containers.go | 45 |
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) +} |