]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Use os.uname() instead of calling uname in subprocess
authorJakub Libosvar <libosvar@redhat.com>
Tue, 1 Apr 2014 14:41:38 +0000 (16:41 +0200)
committerThomas Goirand <thomas@goirand.fr>
Mon, 9 Jun 2014 15:06:55 +0000 (23:06 +0800)
Related-Bug: #1291535

Change-Id: I57e18c0b95904f318e3fff08cd18b32e28f48834
(cherry picked from commit 22a0692c2e9b0276c6b4dd2f66cedc70f7f835a5)

neutron/agent/linux/ovs_lib.py

index 64cf1baf447e722df0a83ae7de45350720ba6838..9fc2c81622f2f3d320f92d2ea8f87853204161fb 100644 (file)
@@ -14,6 +14,7 @@
 #    under the License.
 
 import distutils.version as dist_version
+import os
 import re
 
 from oslo.config import cfg
@@ -485,13 +486,9 @@ def get_installed_ovs_klm_version():
 
 
 def get_installed_kernel_version():
-    args = ["uname", "-r"]
     try:
-        cmd = utils.execute(args)
-        for line in cmd.split('\n'):
-            ver = re.findall("\d+\.\d+\.\d+", line)
-            return ver[0]
-    except Exception:
+        return os.uname()[2].split('-', 1)[0]
+    except IndexError:
         LOG.exception(_("Unable to retrieve installed Linux kernel version."))