summaryrefslogtreecommitdiff
path: root/contrib/python/cmd/rmi.py
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2018-06-22 08:15:37 -0500
committerAtomic Bot <atomic-devel@projectatomic.io>2018-06-27 04:52:22 +0000
commit60427ab3d26bbe5a5ab00c4e7b550f111b4f72e5 (patch)
tree64f11dab9bcdc426956160b6b56ee536bb3aa6e8 /contrib/python/cmd/rmi.py
parent56133f7263337e9b2c9cfb1cfce35adc2366f52b (diff)
downloadpodman-60427ab3d26bbe5a5ab00c4e7b550f111b4f72e5.tar.gz
podman-60427ab3d26bbe5a5ab00c4e7b550f111b4f72e5.tar.bz2
podman-60427ab3d26bbe5a5ab00c4e7b550f111b4f72e5.zip
add podman remote client
podman client that is capable of: * images * ps * rm * rmi this is only a mockup to frame out and prove python library and ssh tunnelling usage. Signed-off-by: baude <bbaude@redhat.com> Closes: #986 Approved by: rhatdan
Diffstat (limited to 'contrib/python/cmd/rmi.py')
-rw-r--r--contrib/python/cmd/rmi.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/contrib/python/cmd/rmi.py b/contrib/python/cmd/rmi.py
new file mode 100644
index 000000000..807c5c1e4
--- /dev/null
+++ b/contrib/python/cmd/rmi.py
@@ -0,0 +1,25 @@
+from pman import PodmanRemote
+from utils import write_out, write_err
+
+def cli(subparser):
+ imagesp = subparser.add_parser("rmi",
+ help=("delete one or more images"))
+ imagesp.add_argument("--force", "-f", action="store_true", help="force delete", dest="force")
+ imagesp.add_argument("delete_targets", nargs='*', help="images to delete")
+ imagesp.set_defaults(_class=Rmi, func='remove_images')
+
+
+class Rmi(PodmanRemote):
+
+ def remove_images(self):
+ delete_targets = getattr(self.args, "delete_targets")
+ if len(delete_targets) < 1:
+ raise ValueError("you must supply at least one image id or name to delete")
+ force = getattr(self.args, "force")
+ for d in delete_targets:
+ image = self.client.images.get(d)
+ if image["containers"] > 0 and not force:
+ write_err("unable to delete {} because it has associated errors. retry with --force".format(d))
+ continue
+ image.remove(force)
+ write_out(image["id"])