]> 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)
committerJakub Libosvar <libosvar@redhat.com>
Tue, 1 Apr 2014 18:23:41 +0000 (20:23 +0200)
Related-Bug: #1291535

Change-Id: I57e18c0b95904f318e3fff08cd18b32e28f48834

neutron/agent/linux/ovs_lib.py

index e1172234f8f2677280442914f949684812e84ff7..b9670d5350317f4148f5683abb577751cf73e5a3 100644 (file)
@@ -14,6 +14,7 @@
 #    under the License.
 
 import distutils.version as dist_version
+import os
 import re
 
 from oslo.config import cfg
@@ -480,13 +481,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."))