From 60427ab3d26bbe5a5ab00c4e7b550f111b4f72e5 Mon Sep 17 00:00:00 2001 From: baude Date: Fri, 22 Jun 2018 08:15:37 -0500 Subject: 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 Closes: #986 Approved by: rhatdan --- contrib/python/cmd/rm.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 contrib/python/cmd/rm.py (limited to 'contrib/python/cmd/rm.py') diff --git a/contrib/python/cmd/rm.py b/contrib/python/cmd/rm.py new file mode 100644 index 000000000..c9dfaa688 --- /dev/null +++ b/contrib/python/cmd/rm.py @@ -0,0 +1,22 @@ +from pman import PodmanRemote +from utils import write_out, convert_size, stringTimeToHuman + +def cli(subparser): + imagesp = subparser.add_parser("rm", + help=("delete one or more containers")) + imagesp.add_argument("--force", "-f", action="store_true", help="force delete", dest="force") + imagesp.add_argument("delete_targets", nargs='*', help="container images to delete") + imagesp.set_defaults(_class=Rm, func='remove_containers') + + +class Rm(PodmanRemote): + + def remove_containers(self): + delete_targets = getattr(self.args, "delete_targets") + if len(delete_targets) < 1: + raise ValueError("you must supply at least one container id or name to delete") + force = getattr(self.args, "force") + for d in delete_targets: + con = self.client.containers.get(d) + con.remove(force) + write_out(con["id"]) -- cgit v1.2.3-54-g00ecf