HEX
Server: nginx/1.22.0
System: Linux iZuf6jdxbygmf6cco977lcZ 5.10.84-10.4.al8.x86_64 #1 SMP Tue Apr 12 12:31:07 CST 2022 x86_64
User: root (0)
PHP: 7.4.29
Disabled: passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,readlink,symlink,popepassthru,stream_socket_server,fsocket,popen
Upload Files
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