distribution: Add support for Cumulus Linux (#52309)
* Refactored code * Added support for Cumulus Linux 2.5.4 * Added support for Cumulus Linux 3.7.3 * Test added Fixes: #29969 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
parent
677c04c01d
commit
db03f88b63
2 changed files with 71 additions and 24 deletions
|
@ -1,17 +1,7 @@
|
||||||
# This file is part of Ansible
|
# -*- coding: utf-8 -*-
|
||||||
#
|
|
||||||
# Ansible is free software: you can redistribute it and/or modify
|
# Copyright: (c) Ansible Project
|
||||||
# it under the terms of the GNU General Public License as published by
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# Ansible is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
from __future__ import (absolute_import, division, print_function)
|
from __future__ import (absolute_import, division, print_function)
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
@ -146,7 +136,7 @@ class DistributionFiles:
|
||||||
return parsed, dist_file_dict
|
return parsed, dist_file_dict
|
||||||
except AttributeError as exc:
|
except AttributeError as exc:
|
||||||
print('exc: %s' % exc)
|
print('exc: %s' % exc)
|
||||||
# this should never happen, but if it does fail quitely and not with a traceback
|
# this should never happen, but if it does fail quietly and not with a traceback
|
||||||
return False, dist_file_dict
|
return False, dist_file_dict
|
||||||
|
|
||||||
return True, dist_file_dict
|
return True, dist_file_dict
|
||||||
|
@ -161,14 +151,14 @@ class DistributionFiles:
|
||||||
def _guess_distribution(self):
|
def _guess_distribution(self):
|
||||||
# try to find out which linux distribution this is
|
# try to find out which linux distribution this is
|
||||||
dist = (get_distribution(), get_distribution_version(), get_distribution_codename())
|
dist = (get_distribution(), get_distribution_version(), get_distribution_codename())
|
||||||
distribution_guess = {}
|
distribution_guess = {
|
||||||
distribution_guess['distribution'] = dist[0] or 'NA'
|
'distribution': dist[0] or 'NA',
|
||||||
distribution_guess['distribution_version'] = dist[1] or 'NA'
|
'distribution_version': dist[1] or 'NA',
|
||||||
distribution_guess['distribution_major_version'] = \
|
# distribution_release can be the empty string
|
||||||
distribution_guess['distribution_version'].split('.')[0] or 'NA'
|
'distribution_release': 'NA' if dist[2] is None else dist[2]
|
||||||
# distribution_release can be the empty string
|
}
|
||||||
distribution_guess['distribution_release'] = 'NA' if dist[2] is None else dist[2]
|
|
||||||
|
|
||||||
|
distribution_guess['distribution_major_version'] = distribution_guess['distribution_version'].split('.')[0] or 'NA'
|
||||||
return distribution_guess
|
return distribution_guess
|
||||||
|
|
||||||
def process_dist_files(self):
|
def process_dist_files(self):
|
||||||
|
@ -344,6 +334,17 @@ class DistributionFiles:
|
||||||
if version:
|
if version:
|
||||||
debian_facts['distribution_version'] = version.group(1)
|
debian_facts['distribution_version'] = version.group(1)
|
||||||
debian_facts['distribution_major_version'] = version.group(1)
|
debian_facts['distribution_major_version'] = version.group(1)
|
||||||
|
elif 'Cumulus' in data:
|
||||||
|
debian_facts['distribution'] = 'Cumulus Linux'
|
||||||
|
version = re.search(r"VERSION_ID=(.*)", data)
|
||||||
|
if version:
|
||||||
|
major, _minor, _dummy_ver = version.group(1).split(".")
|
||||||
|
debian_facts['distribution_version'] = version.group(1)
|
||||||
|
debian_facts['distribution_major_version'] = major
|
||||||
|
|
||||||
|
release = re.search(r'VERSION="(.*)"', data)
|
||||||
|
if release:
|
||||||
|
debian_facts['distribution_release'] = release.groups()[0]
|
||||||
else:
|
else:
|
||||||
return False, debian_facts
|
return False, debian_facts
|
||||||
|
|
||||||
|
@ -459,7 +460,7 @@ class Distribution(object):
|
||||||
'Ascendos', 'CloudLinux', 'PSBM', 'OracleLinux', 'OVS',
|
'Ascendos', 'CloudLinux', 'PSBM', 'OracleLinux', 'OVS',
|
||||||
'OEL', 'Amazon', 'Virtuozzo', 'XenServer', 'Alibaba'],
|
'OEL', 'Amazon', 'Virtuozzo', 'XenServer', 'Alibaba'],
|
||||||
'Debian': ['Debian', 'Ubuntu', 'Raspbian', 'Neon', 'KDE neon',
|
'Debian': ['Debian', 'Ubuntu', 'Raspbian', 'Neon', 'KDE neon',
|
||||||
'Linux Mint', 'SteamOS', 'Devuan', 'Kali'],
|
'Linux Mint', 'SteamOS', 'Devuan', 'Kali', 'Cumulus Linux'],
|
||||||
'Suse': ['SuSE', 'SLES', 'SLED', 'openSUSE', 'openSUSE Tumbleweed',
|
'Suse': ['SuSE', 'SLES', 'SLED', 'openSUSE', 'openSUSE Tumbleweed',
|
||||||
'SLES_SAP', 'SUSE_LINUX', 'openSUSE Leap'],
|
'SLES_SAP', 'SUSE_LINUX', 'openSUSE Leap'],
|
||||||
'Archlinux': ['Archlinux', 'Antergos', 'Manjaro'],
|
'Archlinux': ['Archlinux', 'Antergos', 'Manjaro'],
|
||||||
|
|
|
@ -1110,7 +1110,53 @@ PRIVACY_POLICY_URL="http://www.intel.com/privacy"
|
||||||
"os_family": "Archlinux",
|
"os_family": "Archlinux",
|
||||||
"distribution_version": "NA"
|
"distribution_version": "NA"
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
'name': "Cumulus Linux 3.7.3",
|
||||||
|
'input': {
|
||||||
|
'/etc/os-release': """NAME="Cumulus Linux"
|
||||||
|
VERSION_ID=3.7.3
|
||||||
|
VERSION="Cumulus Linux 3.7.3"
|
||||||
|
PRETTY_NAME="Cumulus Linux"
|
||||||
|
ID=cumulus-linux
|
||||||
|
ID_LIKE=debian
|
||||||
|
CPE_NAME=cpe:/o:cumulusnetworks:cumulus_linux:3.7.3
|
||||||
|
HOME_URL="http://www.cumulusnetworks.com/"
|
||||||
|
SUPPORT_URL="http://support.cumulusnetworks.com/"
|
||||||
|
"""
|
||||||
|
},
|
||||||
|
'platform.dist': ('debian', '8.11', ''),
|
||||||
|
'result': {
|
||||||
|
'distribution': 'Cumulus Linux',
|
||||||
|
'distribution_major_version': '3',
|
||||||
|
'distribution_release': 'Cumulus Linux 3.7.3',
|
||||||
|
'os_family': 'Debian',
|
||||||
|
'distribution_version': '3.7.3',
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': "Cumulus Linux 2.5.4",
|
||||||
|
'input': {
|
||||||
|
'/etc/os-release': """NAME="Cumulus Linux"
|
||||||
|
VERSION_ID=2.5.4
|
||||||
|
VERSION="2.5.4-6dc6e80-201510091936-build"
|
||||||
|
PRETTY_NAME="Cumulus Linux"
|
||||||
|
ID=cumulus-linux
|
||||||
|
ID_LIKE=debian
|
||||||
|
CPE_NAME=cpe:/o:cumulusnetworks:cumulus_linux:2.5.4-6dc6e80-201510091936-build
|
||||||
|
HOME_URL="http://www.cumulusnetworks.com/"
|
||||||
|
SUPPORT_URL="http://support.cumulusnetworks.com/"
|
||||||
|
"""
|
||||||
|
},
|
||||||
|
'platform.dist': ('', '', ''),
|
||||||
|
'result': {
|
||||||
|
'distribution': 'Cumulus Linux',
|
||||||
|
'distribution_major_version': '2',
|
||||||
|
'distribution_release': '2.5.4-6dc6e80-201510091936-build',
|
||||||
|
'os_family': 'Debian',
|
||||||
|
'distribution_version': '2.5.4',
|
||||||
|
}
|
||||||
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue