File: //lib/python3.6/site-packages/cloudinit/distros/sles.py
# Copyright (C) 2017 SUSE LLC
#
# Author: Robert Schweikert <rjschwei@suse.com>
#
# This file is part of cloud-init. See LICENSE file for license information.
from cloudinit.distros import opensuse
from cloudinit import log as logging
LOG = logging.getLogger(__name__)
class Distro(opensuse.Distro):
def __init__(self, name, cfg, paths):
opensuse.Distro.__init__(self, name, cfg, paths)
self.cname = 'SLES'
def get_release(self):
# SLES 'lsb_releas -rs' only display major version
# override the default get_release() method
return self.get_fn_release()
def get_fn_release(self):
check_file = '/etc/SuSE-release'
major, minor = '', ''
if os.path.exists(check_file):
for i in util.load_file(check_file).splitlines():
if i.strip().startswith('VERSION'):
major = i.split('=')[1].strip()
if i.strip().startswith('PATCHLEVEL'):
minor = i.split('=')[1].strip()
if (major and minor):
return '.'.join([major, minor])
check_files = ('/etc/issue', '/etc/issue.net')
reg = re.compile('Welcome to SUSE Linux Enterprise Server (\d+)+ SP(\d+)')
for fn in check_files:
if os.path.exists(fn):
out = reg.findall(util.load_file(fn))
if out: return '.'.join(out[0])
return ''
# vi: ts=4 expandtab