blob: 3c854a3585c05790c76cf9d3f512adbfcd653544 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
"""Remote client command for reporting on Podman service."""
import json
import sys
import podman
import yaml
from pypodman.lib import AbstractActionBase
class Info(AbstractActionBase):
"""Class for reporting on Podman Service."""
@classmethod
def subparser(cls, parent):
"""Add Info command to parent parser."""
parser = parent.add_parser(
'info', help='report info on podman service')
parser.add_argument(
'--format',
choices=('json', 'yaml'),
help="Alter the output for a format like 'json' or 'yaml'."
" (default: yaml)")
parser.set_defaults(class_=cls, method='info')
def info(self):
"""Report on Podman Service."""
try:
info = self.client.system.info()
except podman.ErrorOccurred as e:
sys.stdout.flush()
print(
'{}'.format(e.reason).capitalize(),
file=sys.stderr,
flush=True)
return 1
else:
if self._args.format == 'json':
print(json.dumps(info._asdict(), indent=2), flush=True)
else:
print(
yaml.dump(
dict(info._asdict()),
canonical=False,
default_flow_style=False),
flush=True)
|