[node-patches] Change in ovirt-node[master]: utils: Add SystemRelease

fabiand at fedoraproject.org fabiand at fedoraproject.org
Thu Apr 4 15:28:36 UTC 2013


Fabian Deutsch has uploaded a new change for review.

Change subject: utils: Add SystemRelease
......................................................................

utils: Add SystemRelease

This class can be used to retrieve informations about the underlying OS
(Fedora, RHEL, CentOS, ...)

Change-Id: I59f817e2e01ef42ef1c46a2b07d5cc56719192e9
Signed-off-by: Fabian Deutsch <fabiand at fedoraproject.org>
---
M scripts/tui/src/ovirt/node/utils/system.py
1 file changed, 30 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/18/13618/1

diff --git a/scripts/tui/src/ovirt/node/utils/system.py b/scripts/tui/src/ovirt/node/utils/system.py
index 9aa7c36..7a119ff 100644
--- a/scripts/tui/src/ovirt/node/utils/system.py
+++ b/scripts/tui/src/ovirt/node/utils/system.py
@@ -63,6 +63,36 @@
     return os.path.exists("/dev/HostVG")
 
 
+class SystemRelease(base.Base):
+    """Informations about the OS based on /etc/system-release-cpe
+
+    Use openscap_api.cpe.name_new(str) from openscap-python for an official
+    way.
+    """
+    CPE_FILE = "/etc/system-release-cpe"
+
+    VENDOR = None
+    PRODUCT = None
+    VERSION = None
+
+    def __init__(self):
+        super(SystemRelease, self).__init__()
+        self.load()
+
+    def load(self):
+        """Parse the CPE FILE
+        """
+        with open(self.CPE_FILE, "r") as f:
+            cpe_uri = f.read()
+            self.logger.debug("Read CPE URI: %s" % cpe_uri)
+            cpe_parts = cpe_uri.split(":")
+            self.logger.debug("Parsed CPE parts: %s" % cpe_parts)
+            if cpe_parts[0] != "cpe":
+                raise RuntimeError("Can not parse CPE string in %s" %
+                                   self.CPE_FILE)
+            self.VENDOR, self.PRODUCT, self.VERSION = cpe_parts[2:4]
+
+
 class ProductInformation(base.Base):
     """Return oVirt Node product informations
     """


--
To view, visit http://gerrit.ovirt.org/13618
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I59f817e2e01ef42ef1c46a2b07d5cc56719192e9
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Fabian Deutsch <fabiand at fedoraproject.org>



More information about the node-patches mailing list