1
# Copyright 2014 Microsoft Corporation
3
# Licensed under the Apache License, Version 2.0 (the "License");
4
# you may not use this file except in compliance with the License.
5
# You may obtain a copy of the License at
7
# http://www.apache.org/licenses/LICENSE-2.0
9
# Unless required by applicable law or agreed to in writing, software
10
# distributed under the License is distributed on an "AS IS" BASIS,
11
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
# See the License for the specific language governing permissions and
13
# limitations under the License.
15
# Requires Python 2.4+ and Openssl 1.0+
18
import azurelinuxagent.logger as logger
19
from azurelinuxagent.utils.textutil import Version
20
from azurelinuxagent.metadata import DISTRO_NAME, DISTRO_VERSION, \
22
from azurelinuxagent.distro.default.distro import DefaultDistro
23
from azurelinuxagent.distro.ubuntu.distro import UbuntuDistro, \
27
from azurelinuxagent.distro.redhat.distro import RedhatDistro, Redhat6xDistro
28
from azurelinuxagent.distro.coreos.distro import CoreOSDistro
29
from azurelinuxagent.distro.suse.distro import SUSE11Distro, SUSEDistro
30
from azurelinuxagent.distro.debian.distro import DebianDistro
31
from azurelinuxagent.distro.freebsd.distro import FreeBSDDistro
33
def get_distro(distro_name=DISTRO_NAME, distro_version=DISTRO_VERSION,
34
distro_full_name=DISTRO_FULL_NAME):
35
if distro_name == "ubuntu":
36
if Version(distro_version) == Version("12.04") or \
37
Version(distro_version) == Version("12.10"):
38
return Ubuntu12Distro()
39
elif Version(distro_version) == Version("14.04") or \
40
Version(distro_version) == Version("14.10"):
41
return Ubuntu14Distro()
42
elif distro_full_name == "Snappy Ubuntu Core":
43
return UbuntuSnappyDistro()
46
if distro_name == "coreos":
48
if distro_name == "suse":
49
if distro_full_name=='SUSE Linux Enterprise Server' and \
50
Version(distro_version) < Version('12') or \
51
distro_full_name == 'openSUSE' and \
52
Version(distro_version) < Version('13.2'):
56
elif distro_name == "debian":
58
elif distro_name == "redhat" or distro_name == "centos" or \
59
distro_name == "oracle":
60
if Version(distro_version) < Version("7"):
61
return Redhat6xDistro()
64
elif distro_name == "freebsd":
65
return FreeBSDDistro()
67
logger.warn("Unable to load distro implemetation for {0}.", distro_name)
68
logger.warn("Use default distro implemetation instead.")
69
return DefaultDistro()