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/ps.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 contrib/python/cmd/ps.py (limited to 'contrib/python/cmd/ps.py') diff --git a/contrib/python/cmd/ps.py b/contrib/python/cmd/ps.py new file mode 100644 index 000000000..85db5489e --- /dev/null +++ b/contrib/python/cmd/ps.py @@ -0,0 +1,19 @@ +from pman import PodmanRemote +from utils import write_out, convert_size, stringTimeToHuman + +def cli(subparser): + imagesp = subparser.add_parser("ps", + help=("list containers")) + imagesp.add_argument("all", action="store_true", help="list all containers") + imagesp.set_defaults(_class=Ps, func='display_all_containers') + + +class Ps(PodmanRemote): + + def display_all_containers(self): + col_fmt = "{0:15}{1:32}{2:22}{3:14}{4:12}{5:30}{6:20}" + write_out(col_fmt.format("CONTAINER ID", "IMAGE", "COMMAND", "CREATED", "STATUS", "PORTS", "NAMES")) + + for i in self.client.containers.list(): + command = " ".join(i["command"]) + write_out(col_fmt.format(i["id"][0:12], i["image"][0:30], command[0:20], stringTimeToHuman(i["createdat"]), i["status"], "", i["names"][0:20])) -- cgit v1.2.3-54-g00ecf