mirror of
https://github.com/containers/podman.git
synced 2025-07-15 03:02:52 +08:00

* Add support for pod -- create, inspect, kill, pause, ps, rm, restart, start, stop, top, unpause * Update pylintrc to better reflect pep8 code standards * Fix various pylint reported errors * Refactor code that determines screen width to no longer require initializing curses. Improved start up time and pushing data blob down ssh tunnel. * Correct pod-create man page, cgroupparent not boolean * Abort integration tests if podman service fails to start Signed-off-by: Jhon Honce <jhonce@redhat.com>
43 lines
1.3 KiB
Python
43 lines
1.3 KiB
Python
"""Remote client command for stopping pod and container(s)."""
|
|
import sys
|
|
|
|
import podman
|
|
from pypodman.lib import AbstractActionBase
|
|
from pypodman.lib import query_model as query_pods
|
|
|
|
|
|
class StopPod(AbstractActionBase):
|
|
"""Class for stopping pod and container(s)."""
|
|
|
|
@classmethod
|
|
def subparser(cls, parent):
|
|
"""Add Pod Stop command to parent parser."""
|
|
parser = parent.add_parser('stop', help='stop pod')
|
|
parser.add_argument(
|
|
'-a', '--all', action='store_true', help='Stop all pods')
|
|
parser.add_argument(
|
|
'pod', nargs='*', help='Pod to stop. Or, use --all')
|
|
parser.set_defaults(class_=cls, method='stop')
|
|
|
|
def __init__(self, args):
|
|
"""Contruct StopPod object."""
|
|
if args.all and args.pod:
|
|
raise ValueError('You may give a pod or use --all, not both')
|
|
super().__init__(args)
|
|
|
|
def stop(self):
|
|
"""Stop pod and container(s)."""
|
|
idents = None if self._args.all else self._args.pod
|
|
pods = query_pods(self.client.pods, idents)
|
|
|
|
for pod in pods:
|
|
try:
|
|
pod.stop()
|
|
except podman.ErrorOccurred as ex:
|
|
print(
|
|
'{}'.format(ex.reason).capitalize(),
|
|
file=sys.stderr,
|
|
flush=True)
|
|
return 1
|
|
return 0
|