Merge "Use os.uname() instead of calling uname in subprocess"
This commit is contained in:
commit
d1c205e301
@ -14,6 +14,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import distutils.version as dist_version
|
import distutils.version as dist_version
|
||||||
|
import os
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
@ -481,13 +482,9 @@ def get_installed_ovs_klm_version():
|
|||||||
|
|
||||||
|
|
||||||
def get_installed_kernel_version():
|
def get_installed_kernel_version():
|
||||||
args = ["uname", "-r"]
|
|
||||||
try:
|
try:
|
||||||
cmd = utils.execute(args)
|
return os.uname()[2].split('-', 1)[0]
|
||||||
for line in cmd.split('\n'):
|
except IndexError:
|
||||||
ver = re.findall("\d+\.\d+\.\d+", line)
|
|
||||||
return ver[0]
|
|
||||||
except Exception:
|
|
||||||
LOG.exception(_("Unable to retrieve installed Linux kernel version."))
|
LOG.exception(_("Unable to retrieve installed Linux kernel version."))
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user