Esempio n. 1
0
def get_osutil(distro_name=DISTRO_NAME,
               distro_code_name=DISTRO_CODE_NAME,
               distro_version=DISTRO_VERSION,
               distro_full_name=DISTRO_FULL_NAME):

    if distro_name == "arch":
        return ArchUtil()

    if distro_name == "clear linux software for intel architecture":
        return ClearLinuxUtil()

    if distro_name == "ubuntu":
        if Version(distro_version) == Version("12.04") or Version(distro_version) == Version("12.10"):
            return Ubuntu12OSUtil()
        elif Version(distro_version) == Version("14.04") or Version(distro_version) == Version("14.10"):
            return Ubuntu14OSUtil()
        elif distro_full_name == "Snappy Ubuntu Core":
            return UbuntuSnappyOSUtil()
        else:
            return UbuntuOSUtil()

    if distro_name == "alpine":
        return AlpineOSUtil()

    if distro_name == "kali":
        return DebianOSUtil()

    if distro_name == "coreos" or distro_code_name == "coreos":
        return CoreOSUtil()

    if distro_name == "suse":
        if distro_full_name == 'SUSE Linux Enterprise Server' \
                and Version(distro_version) < Version('12') \
                or distro_full_name == 'openSUSE' and Version(distro_version) < Version('13.2'):
            return SUSE11OSUtil()
        else:
            return SUSEOSUtil()

    elif distro_name == "debian":
        return DebianOSUtil()

    elif distro_name == "redhat" \
            or distro_name == "centos" \
            or distro_name == "oracle":
        if Version(distro_version) < Version("7"):
            return Redhat6xOSUtil()
        else:
            return RedhatOSUtil()

    elif distro_name == "euleros":
        return RedhatOSUtil()

    elif distro_name == "freebsd":
        return FreeBSDOSUtil()

    elif distro_name == "bigip":
        return BigIpOSUtil()

    else:
        logger.warn("Unable to load distro implementation for {0}. Using "
                    "default distro implementation instead.",
                    distro_name)
        return DefaultOSUtil()
Esempio n. 2
0
def get_osutil(distro_name=DISTRO_NAME,
               distro_version=DISTRO_VERSION,
               distro_full_name=DISTRO_FULL_NAME):
    if distro_name == "ubuntu":
        if Version(distro_version) == Version("12.04") or \
           Version(distro_version) == Version("12.10"):
            return Ubuntu12OSUtil()
        elif Version(distro_version) == Version("14.04") or \
             Version(distro_version) == Version("14.10"):
            return Ubuntu14OSUtil()
        elif distro_full_name == "Snappy Ubuntu Core":
            return UbuntuSnappyOSUtil()
        else:
            return UbuntuOSUtil()
    if distro_name == "alpine":
        return AlpineOSUtil()
    if distro_name == "kali":
        return DebianOSUtil()
    if distro_name == "coreos":
        return CoreOSUtil()
    if distro_name == "suse":
        if distro_full_name=='SUSE Linux Enterprise Server' and \
           Version(distro_version) < Version('12') or \
           distro_full_name == 'openSUSE' and \
           Version(distro_version) < Version('13.2'):
            return SUSE11OSUtil()
        else:
            return SUSEOSUtil()
    elif distro_name == "debian":
        return DebianOSUtil()
    elif distro_name == "redhat" or distro_name == "centos" or \
            distro_name == "oracle":
        if Version(distro_version) < Version("7"):
            return Redhat6xOSUtil()
        else:
            return RedhatOSUtil()
    elif distro_name == "freebsd":
        return FreeBSDOSUtil()
    else:
        logger.warn("Unable to load distro implementation for {0}.",
                    distro_name)
        logger.warn("Use default distro implementation instead.")
        return DefaultOSUtil()
Esempio n. 3
0
 def version_gt(self, other):
     self_version = self.ext_handler.properties.version
     other_version = other.ext_handler.properties.version
     return Version(self_version) > Version(other_version)
Esempio n. 4
0
    def test_version_compare(self):
        self.assertTrue(Version("1.0") < Version("1.1"))
        self.assertTrue(Version("1.9") < Version("1.10"))
        self.assertTrue(Version("1.9.9") < Version("1.10.0"))
        self.assertTrue(Version("1.0.0.0") < Version("1.2.0.0"))

        self.assertTrue(Version("1.0") <= Version("1.1"))
        self.assertTrue(Version("1.1") > Version("1.0"))
        self.assertTrue(Version("1.1") >= Version("1.0"))

        self.assertTrue(Version("1.0") == Version("1.0"))
        self.assertTrue(Version("1.0") >= Version("1.0"))
        self.assertTrue(Version("1.0") <= Version("1.0"))

        self.assertTrue(Version("1.9") < "1.10")
        self.assertTrue("1.9" < Version("1.10"))