summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2018-11-16 05:02:08 -0800
committerGitHub <noreply@github.com>2018-11-16 05:02:08 -0800
commit43de95df34a88d2ded4b62ab0c1763a33acac07e (patch)
tree5eb659f00c9e446418f915eaf2c850ca1b6bf42a
parent39ef6d43d0b5a614228898180025835836673a8c (diff)
parentdba45a13c0e1829fb08613fc51cd1099bc7c7d25 (diff)
downloadpodman-43de95df34a88d2ded4b62ab0c1763a33acac07e.tar.gz
podman-43de95df34a88d2ded4b62ab0c1763a33acac07e.tar.bz2
podman-43de95df34a88d2ded4b62ab0c1763a33acac07e.zip
Merge pull request #1813 from rhatdan/version
Add version command to pypodman
-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"]))