diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2018-12-05 14:55:27 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-05 14:55:27 -0800 |
commit | 6bb56a1c972da9755ac5c7ec5bc5b04a0b92c9b7 (patch) | |
tree | 42afde43902bf998ba218c76d67d01ea7ec771c3 /pkg/varlinkapi/mount.go | |
parent | bbcbf03f7307d75e69de17db06edc7d54c190ffc (diff) | |
parent | 5c02dda869390725a799339b094f548d327c9122 (diff) | |
download | podman-6bb56a1c972da9755ac5c7ec5bc5b04a0b92c9b7.tar.gz podman-6bb56a1c972da9755ac5c7ec5bc5b04a0b92c9b7.tar.bz2 podman-6bb56a1c972da9755ac5c7ec5bc5b04a0b92c9b7.zip |
Merge pull request #1924 from baude/mroevarlinkendpoints
Adding more varlink endpoints
Diffstat (limited to 'pkg/varlinkapi/mount.go')
-rw-r--r-- | pkg/varlinkapi/mount.go | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/pkg/varlinkapi/mount.go b/pkg/varlinkapi/mount.go new file mode 100644 index 000000000..84e6b2709 --- /dev/null +++ b/pkg/varlinkapi/mount.go @@ -0,0 +1,49 @@ +package varlinkapi + +import ( + "github.com/containers/libpod/cmd/podman/varlink" +) + +// ListContainerMounts ... +func (i *LibpodAPI) ListContainerMounts(call iopodman.VarlinkCall) error { + var mounts []string + allContainers, err := i.Runtime.GetAllContainers() + if err != nil { + return call.ReplyErrorOccurred(err.Error()) + } + for _, container := range allContainers { + mounted, mountPoint, err := container.Mounted() + if err != nil { + return call.ReplyErrorOccurred(err.Error()) + } + if mounted { + mounts = append(mounts, mountPoint) + } + } + return call.ReplyListContainerMounts(mounts) +} + +// MountContainer ... +func (i *LibpodAPI) MountContainer(call iopodman.VarlinkCall, name string) error { + container, err := i.Runtime.LookupContainer(name) + if err != nil { + return call.ReplyErrorOccurred(err.Error()) + } + path, err := container.Mount() + if err != nil { + return call.ReplyErrorOccurred(err.Error()) + } + return call.ReplyMountContainer(path) +} + +// UnmountContainer ... +func (i *LibpodAPI) UnmountContainer(call iopodman.VarlinkCall, name string, force bool) error { + container, err := i.Runtime.LookupContainer(name) + if err != nil { + return call.ReplyErrorOccurred(err.Error()) + } + if err := container.Unmount(force); err != nil { + return call.ReplyErrorOccurred(err.Error()) + } + return call.ReplyUnmountContainer() +} |