summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2018-11-14 06:46:59 -0500
committerDaniel J Walsh <dwalsh@redhat.com>2018-11-15 20:15:52 -0500
commitdba45a13c0e1829fb08613fc51cd1099bc7c7d25 (patch)
tree0301f71a5237a8bd74d9ca60a0e79a1ac5ad1248 /contrib
parent236408bbbc14f6b637c4e9be19093d1a37b83f9c (diff)
downloadpodman-dba45a13c0e1829fb08613fc51cd1099bc7c7d25.tar.gz
podman-dba45a13c0e1829fb08613fc51cd1099bc7c7d25.tar.bz2
podman-dba45a13c0e1829fb08613fc51cd1099bc7c7d25.zip
Add version command to pypodman
pypodman does not currently support the version command. We want to have as close to the same functionality between podman and pypodman, so adding this command. Also had to fix some validate errors. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'contrib')
-rw-r--r--contrib/python/pypodman/pypodman/lib/actions/__init__.py2
-rw-r--r--contrib/python/pypodman/pypodman/lib/actions/version_action.py41
2 files changed, 43 insertions, 0 deletions
diff --git a/contrib/python/pypodman/pypodman/lib/actions/__init__.py b/contrib/python/pypodman/pypodman/lib/actions/__init__.py
index 2668cd8ff..bc863ce6d 100644
--- a/contrib/python/pypodman/pypodman/lib/actions/__init__.py
+++ b/contrib/python/pypodman/pypodman/lib/actions/__init__.py
@@ -22,6 +22,7 @@ from pypodman.lib.actions.rm_action import Rm
from pypodman.lib.actions.rmi_action import Rmi
from pypodman.lib.actions.run_action import Run
from pypodman.lib.actions.search_action import Search
+from pypodman.lib.actions.version_action import Version
__all__ = [
'Attach',
@@ -47,4 +48,5 @@ __all__ = [
'Rmi',
'Run',
'Search',
+ 'Version',
]
diff --git a/contrib/python/pypodman/pypodman/lib/actions/version_action.py b/contrib/python/pypodman/pypodman/lib/actions/version_action.py
new file mode 100644
index 000000000..12b6dc576
--- /dev/null
+++ b/contrib/python/pypodman/pypodman/lib/actions/version_action.py
@@ -0,0 +1,41 @@
+"""Remote client command for reporting on Podman service."""
+import json
+import sys
+
+import podman
+import yaml
+from pypodman.lib import AbstractActionBase
+
+
+class Version(AbstractActionBase):
+ """Class for reporting on Podman Service."""
+
+ @classmethod
+ def subparser(cls, parent):
+ """Add Version command to parent parser."""
+ parser = parent.add_parser(
+ 'version', help='report version on podman service')
+ parser.set_defaults(class_=cls, method='version')
+
+ def __init__(self, args):
+ """Construct Version class."""
+ super().__init__(args)
+
+ def version(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:
+ version = info._asdict()['podman']
+ host = info._asdict()['host']
+ print("Version {}".format(version['podman_version']))
+ print("Go Version {}".format(version['go_version']))
+ print("Git Commit {}".format(version['git_commit']))
+ print("OS/Arch {}/{}".format(host["os"], host["arch"]))