Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def unpause(self):
"""Unpause containers in provided Pod."""
idents = None if self._args.all else self._args.pod
pods = query_pods(self.client.pods, idents)
for pod in pods:
try:
pod.unpause()
print(pod.id)
except podman.PodNotFound as ex:
print(
'Pod "{}" not found'.format(ex.name),
file=sys.stderr,
flush=True)
except podman.ErrorOccurred as ex:
print(
'{}'.format(ex.reason).capitalize(),
file=sys.stderr,
flush=True)
return 1
return 0
def query_model(model, identifiers=None):
"""Retrieve all (default) or given model(s)."""
objs = []
if identifiers is None:
objs.extend(model.list())
else:
try:
for ident in identifiers:
objs.append(model.get(ident))
except (
podman.PodNotFound,
podman.ImageNotFound,
podman.ContainerNotFound,
) as ex:
print(
'"{}" not found'.format(ex.name), file=sys.stderr, flush=True)
return objs
def remove(self):
"""Remove 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.remove(self._args.force)
print(pod.id)
except podman.PodNotFound as ex:
print(
'Pod "{}" not found.'.format(ex.name),
file=sys.stderr,
flush=True)
except podman.ErrorOccurred as ex:
print(
'{}'.format(ex.reason).capitalize,
file=sys.stderr,
flush=True)
return 1
return 0
def pause(self):
"""Pause containers in provided Pod."""
idents = None if self._args.all else self._args.pod
pods = query_pods(self.client.pods, idents)
for pod in pods:
try:
pod.pause()
print(pod.id)
except podman.PodNotFound as ex:
print(
'Pod "{}" not found'.format(ex.name),
file=sys.stderr,
flush=True)
except podman.ErrorOccurred as ex:
print(
'{}'.format(ex.reason).capitalize(),
file=sys.stderr,
flush=True)
return 1
return 0
def restart(self):
"""Restart 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.restart()
print(pod.id)
except podman.PodNotFound as ex:
print(
'Pod "{}" not found.'.format(ex.name),
file=sys.stderr,
flush=True)
except podman.ErrorOccurred as ex:
print(
'{}'.format(ex.reason).capitalize(),
file=sys.stderr,
flush=True)
return 1
return 0
def kill(self):
"""Signal provided pods."""
idents = None if self._args.all else self._args.pod
pods = query_pods(self.client.pods, idents)
for pod in pods:
try:
pod.kill(self._args.signal)
print(pod.id)
except podman.PodNotFound as ex:
print(
'Pod "{}" not found.'.format(ex.name),
file=sys.stderr,
flush=True)
except podman.ErrorOccurred as e:
print(
'{}'.format(e.reason).capitalize(),
file=sys.stderr,
flush=True)
return 1
return 0