diff --git a/Atomic/ps.py b/Atomic/containers.py similarity index 92% rename from Atomic/ps.py rename to Atomic/containers.py index 51c6f30b..efebc8a3 100644 --- a/Atomic/ps.py +++ b/Atomic/containers.py @@ -6,11 +6,15 @@ from dateutil.parser import parse as dateparse def cli(subparser): - # atomic ps - pss = subparser.add_parser("ps", - help=_("list the containers"), - epilog="By default this shows only the running containers.") - pss.set_defaults(_class=Ps, func='ps_tty') + # atomic containers + c = subparser.add_parser("containers") + containers_subparser = c.add_subparsers(title='images subcommands', + description="operate on images", + help='additional help') + pss = containers_subparser.add_parser("list", + help=_("list the containers"), + epilog="By default this shows only the running containers.") + pss.set_defaults(_class=Containers, func='ps_tty') pss.add_argument("-a", "--all", action='store_true',dest="all", default=False, help=_("show all containers")) pss.add_argument("-f", "--filter", metavar='FILTER', action='append', dest="filter", @@ -27,7 +31,7 @@ def cli(subparser): util.add_opt(pss) -class Ps(Atomic): +class Containers(Atomic): def ps_tty(self): all_container_info = self.ps() diff --git a/atomic b/atomic index bd0fdcb6..1a265453 100755 --- a/atomic +++ b/atomic @@ -41,7 +41,7 @@ from Atomic import info from Atomic import install from Atomic import help as Help from Atomic import run -from Atomic import ps +from Atomic import containers from Atomic import pull from Atomic import push from Atomic import stop @@ -139,7 +139,7 @@ def create_parser(help_text): install.cli(subparser) images.cli(subparser) mount.cli(subparser) - ps.cli(subparser) + containers.cli(subparser) push.cli(subparser) pull.cli(subparser) run.cli(subparser) diff --git a/docs/atomic-ps.1.md b/atomic-containers.1.md similarity index 79% rename from docs/atomic-ps.1.md rename to atomic-containers.1.md index 5af8e860..8d43257d 100644 --- a/docs/atomic-ps.1.md +++ b/atomic-containers.1.md @@ -2,10 +2,21 @@ % Giuseppe Scrivano % June 2016 # NAME -atomic-ps - list locally installed containers +atomic-containers - operations on container # SYNOPSIS -**atomic ps** +**atomic containers COMMAND [OPTIONS] [CONTAINERS...]** + +atomic images allows the user to view and operate on containers + +# COMMANDS +**list** +By default, will list all running containers on your system. + +Using --all will list all the installed containers. + + +# list OPTIONS [**-h|--help**] [**-a|--all**] [**-f|--filter**] @@ -14,12 +25,6 @@ atomic-ps - list locally installed containers [**--no-trunc**] [**-q|--quiet**] -# DESCRIPTION -**atomic ps**, by default, will list all running containers on your -system. - -Using --all will list all the installed containers. - # OPTIONS: **-h** **--help** Print usage statement diff --git a/atomic_dbus.py b/atomic_dbus.py index a505760a..b623d10a 100755 --- a/atomic_dbus.py +++ b/atomic_dbus.py @@ -14,7 +14,7 @@ from Atomic.storage import Storage from Atomic.diff import Diff from Atomic.scan import Scan -from Atomic.ps import Ps +from Atomic.containers import Containers class atomic_dbus(slip.dbus.service.Object): default_polkit_auth_required = "org.atomic.readwrite" @@ -267,11 +267,11 @@ def VulnerableInfo(self): self.atomic.set_args(args) return self.atomic.get_all_vulnerable_info() - # The Ps method will list all containers on the system. + # The containers.Ps method will list all containers on the system. @slip.dbus.polkit.require_auth("org.atomic.read") @dbus.service.method("org.atomic", in_signature='', out_signature='s') def Ps(self): - ps = Ps() + ps = Containers() ps.useTTY = False args = self.Args() ps.set_args(args) diff --git a/bash/atomic b/bash/atomic index b313ca78..247ff48b 100644 --- a/bash/atomic +++ b/bash/atomic @@ -313,7 +313,25 @@ _atomic_pull() { esac } -_atomic_ps() { +_atomic_containers() { + local subcommands=" + list + " + + __atomic_subcommands "$subcommands" && return + + case "$cur" in + -*) + COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) + ;; + *) + COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) ) + ;; + esac + return 0 +} + +_atomic_containers_list() { local options_with_args=" --filter -f " @@ -996,6 +1014,7 @@ _atomic() { local commands=( cluster + containers host diff info @@ -1004,7 +1023,6 @@ _atomic() { storage mount pull - ps rhost run scan diff --git a/docs/atomic-containers.1.md b/docs/atomic-containers.1.md new file mode 100644 index 00000000..1d73228f --- /dev/null +++ b/docs/atomic-containers.1.md @@ -0,0 +1,58 @@ +% ATOMIC(1) Atomic Man Pages +% Giuseppe Scrivano +% June 2016 +# NAME +atomic-containers - operations on containers + +# SYNOPSIS +**atomic containers COMMAND [OPTIONS] [CONTAINERS...]** + +atomic containers allows the user to view and operate on containers + +# COMMANDS +**list** + +list containers on your system. + +# list OPTIONS +[**-h|--help**] +[**-a|--all**] +[**-f|--filter**] +[**--json**] +[**-n|--noheading**] +[**--no-trunc**] +[**-q|--quiet**] + +# DESCRIPTION +**atomic containers list**, by default, will list all running containers on your +system. + +Using --all will list all the installed containers. + +# OPTIONS: +**-h** **--help** + Print usage statement + +**-a** **--all** + Print all the installed containers + +**-f** **--filter** + Filter output based on given filters, example usage: `--filter id=foo` will list all containers that has "foo" as part of their ID. + + Filterables: `container (id)`, `image`, `command`, `created`, `status`, `runtime` + +**--json** + Print in a machine parsable format + +**-n** **--noheading** + Do not print heading when listing the containers + +**--no-trunc** + Do not truncate output + +**-q** **--quiet** + Only display container IDs + +# HISTORY +June 2016, Originally compiled by Giuseppe Scrivano (gscrivan at redhat dot com) +July 2016, Added sub-commands filter, no-trunc and quiet (jerzhang at redhat dot com) diff --git a/tests/integration/test_ps.sh b/tests/integration/test_containers_list.sh similarity index 83% rename from tests/integration/test_ps.sh rename to tests/integration/test_containers_list.sh index b62c0365..37dce3a9 100755 --- a/tests/integration/test_ps.sh +++ b/tests/integration/test_containers_list.sh @@ -16,11 +16,10 @@ IFS=$'\n\t' OUTPUT=$(/bin/true) -${ATOMIC} ps --all -q -f runtime=Docker | sort > atomic.ps.out +${ATOMIC} containers list --all -q -f runtime=Docker | sort > atomic.ps.out docker ps --all -q | sort > docker.ps.out diff docker.ps.out atomic.ps.out -${ATOMIC} ps -q -f runtime=Docker | sort > atomic.ps.out +${ATOMIC} containers list -q -f runtime=Docker | sort > atomic.ps.out docker ps -q | sort > docker.ps.out diff docker.ps.out atomic.ps.out - diff --git a/tests/integration/test_system_containers.sh b/tests/integration/test_system_containers.sh index 6d497a10..a247e470 100755 --- a/tests/integration/test_system_containers.sh +++ b/tests/integration/test_system_containers.sh @@ -92,35 +92,35 @@ test -e /etc/tmpfiles.d/${NAME}.conf ${ATOMIC} update --container ${NAME} > update.out assert_matches "Latest version already installed" update.out -${ATOMIC} ps --no-trunc > ps.out +${ATOMIC} containers list --no-trunc > ps.out assert_matches "test-system" ps.out -${ATOMIC} ps --json > ps.out +${ATOMIC} containers list --json > ps.out assert_matches "test-system" ps.out -${ATOMIC} ps --all > ps.out +${ATOMIC} containers list --all > ps.out assert_matches "test-system" ps.out -${ATOMIC} ps --all --no-trunc > ps.out +${ATOMIC} containers list --all --no-trunc > ps.out assert_matches "test-system" ps.out -${ATOMIC} ps --no-trunc --filter id=test-system > ps.out +${ATOMIC} containers list --no-trunc --filter id=test-system > ps.out assert_matches "test-system" ps.out -${ATOMIC} ps --no-trunc > ps.out +${ATOMIC} containers list --no-trunc > ps.out assert_matches "test-system" ps.out -${ATOMIC} ps --no-trunc --quiet > ps.out +${ATOMIC} containers list --no-trunc --quiet > ps.out assert_matches "test-system" ps.out -${ATOMIC} ps -aq --no-trunc --filter id=test-system > ps.out +${ATOMIC} containers list -aq --no-trunc --filter id=test-system > ps.out assert_matches "test-system" ps.out -${ATOMIC} ps -aq --no-trunc --filter id=non-existing-system > ps.out +${ATOMIC} containers list -aq --no-trunc --filter id=non-existing-system > ps.out assert_not_matches "test-system" ps.out -${ATOMIC} ps --all --no-trunc --filter id=test-system | grep "test-system" > ps.out +${ATOMIC} containers list --all --no-trunc --filter id=test-system | grep "test-system" > ps.out # Check the command is included in the output assert_matches "run.sh" ps.out systemctl stop ${NAME} -${ATOMIC} ps --all | grep "test-system" > ps.out +${ATOMIC} containers list --all | grep "test-system" > ps.out assert_matches "exited" ps.out -${ATOMIC} ps --quiet > ps.out +${ATOMIC} containers list --quiet > ps.out assert_not_matches "test-system" ps.out test -e /etc/systemd/system/${NAME}.service @@ -143,7 +143,7 @@ assert_matches 8082 ${ATOMIC_OSTREE_CHECKOUT_PATH}/${NAME}.1/config.json # Test if a container with a remote rootfs can be installed/updated ${ATOMIC} --debug install --name=${NAME}-remote --rootfs=${ATOMIC_OSTREE_CHECKOUT_PATH}/${NAME}.1 --set=RECEIVER=${SECRET}-remote --system oci:atomic-test-system -${ATOMIC} --debug ps --no-trunc > ps.out +${ATOMIC} --debug containers list --no-trunc > ps.out assert_matches "remote" ps.out test -e /etc/systemd/system/${NAME}-remote.service