~ubuntu-branches/debian/stretch/waagent/stretch

« back to all changes in this revision

Viewing changes to azurelinuxagent/distro/loader.py

  • Committer: Package Import Robot
  • Author(s): Bastian Blank
  • Date: 2016-08-24 16:48:22 UTC
  • mfrom: (1.2.5)
  • Revision ID: package-import@ubuntu.com-20160824164822-vdf8m5xy5gycm1cz
Tags: 2.1.6-1
New upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright 2014 Microsoft Corporation
2
 
#
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
6
 
#
7
 
#     http://www.apache.org/licenses/LICENSE-2.0
8
 
#
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.
14
 
#
15
 
# Requires Python 2.4+ and Openssl 1.0+
16
 
#
17
 
 
18
 
import azurelinuxagent.logger as logger
19
 
from azurelinuxagent.utils.textutil import Version
20
 
from azurelinuxagent.metadata import DISTRO_NAME, DISTRO_VERSION, \
21
 
                                     DISTRO_FULL_NAME
22
 
from azurelinuxagent.distro.default.distro import DefaultDistro
23
 
from azurelinuxagent.distro.ubuntu.distro import UbuntuDistro, \
24
 
                                                 Ubuntu14Distro, \
25
 
                                                 Ubuntu12Distro, \
26
 
                                                 UbuntuSnappyDistro
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
32
 
 
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()
44
 
        else:
45
 
            return UbuntuDistro()
46
 
    if distro_name == "coreos":
47
 
        return CoreOSDistro()
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'):
53
 
            return SUSE11Distro()
54
 
        else:
55
 
            return SUSEDistro()
56
 
    elif distro_name == "debian":
57
 
        return DebianDistro()
58
 
    elif distro_name == "redhat" or distro_name == "centos" or \
59
 
            distro_name == "oracle":
60
 
        if Version(distro_version) < Version("7"):
61
 
            return Redhat6xDistro()
62
 
        else:
63
 
            return RedhatDistro()
64
 
    elif distro_name == "freebsd":
65
 
        return FreeBSDDistro()
66
 
    else:
67
 
        logger.warn("Unable to load distro implemetation for {0}.", distro_name)
68
 
        logger.warn("Use default distro implemetation instead.")
69
 
        return DefaultDistro()
70