Beispiel #1
0
def get_distro_series_info_row(series):
    """Returns the distro series row information from python-distro-info.
    """
    info = UbuntuDistroInfo()
    for row in info._avail(info._date):
        if row['series'] == series:
            return row
    return None
Beispiel #2
0
 def get_release_title(self, release):
     info = UbuntuDistroInfo()
     for row in info._avail(info._date):
         row_dict = row
         if not isinstance(row, dict):
             row_dict = row.__dict__
         if row_dict['series'] == release:
             return info._format("fullname", row)
     return None
Beispiel #3
0
 def test_get_supported_commissioning_releases_excludes_non_lts(self):
     supported = ['precise', 'trusty', 'vivid', 'wily', 'xenial']
     self.patch_autospec(UbuntuDistroInfo,
                         "supported").return_value = supported
     osystem = UbuntuOS()
     releases = osystem.get_supported_commissioning_releases()
     self.assertIsInstance(releases, list)
     udi = UbuntuDistroInfo()
     non_lts_releases = [name for name in supported if not udi.is_lts(name)]
     for release in non_lts_releases:
         self.assertNotIn(release, releases)
Beispiel #4
0
def get_distro_series_info_row(series):
    """Returns the distro series row information from python-distro-info."""
    info = UbuntuDistroInfo()
    for row in info._avail(info._date):
        # LP: #1711191 - distro-info 0.16+ no longer returns dictionaries or
        # lists, and it now returns objects instead. As such, we need to
        # handle both cases for backwards compatibility.
        if not isinstance(row, dict):
            row = row.__dict__
        if row["series"] == series:
            return row
    return None
Beispiel #5
0
    def is_distro_valid(self, distro, force=False):
        if force:
            return UbuntuDistroInfo().valid(distro)

        if distro == self.get_host_distro_release():
            return True

        supported_distros = UbuntuDistroInfo().supported()

        try:
            supported_distros.index(distro)
        except ValueError:
            return False

        return True
Beispiel #6
0
    def is_distro_valid(self, distro, force=False):
        if force:
            return UbuntuDistroInfo().valid(distro)

        if distro == self.get_host_distro_release():
            return True

        supported_distros = UbuntuDistroInfo().supported()

        try:
            supported_distros.index(distro)
        except ValueError:
            return False

        return True
Beispiel #7
0
def get_release_from_distro_info(string):
    """Convert an Ubuntu release or version into a release dict.

    This data is pulled from the UbuntuDistroInfo library which contains
    additional information such as the release, EOL, and code name."""
    ubuntu = UbuntuDistroInfo()
    release_found = False
    # We can only look at release names for 12.04+ as previous versions
    # have overlapping first letters(e.g Warty and Wily) which break looking
    # up old style kernels(e.g hwe-w).
    try:
        ubuntu_rows = ubuntu._rows
    except AttributeError:
        ubuntu_rows = [row.__dict__ for row in ubuntu._releases]
    for row in ubuntu_rows:
        if (
            int(row["version"].split(".")[0]) >= 12
            and row["series"].startswith(string)
            or row["version"].startswith(string)
        ):
            release_found = True
            break
    if release_found:
        return row
    else:
        return None
Beispiel #8
0
 def make_boot_sources(self):
     kernels = []
     ubuntu = UbuntuDistroInfo()
     for row in ubuntu._rows:
         release_year = int(row['version'].split('.')[0])
         if release_year < 12:
             continue
         elif release_year < 16:
             style = row['series'][0]
         else:
             style = row['version']
         for kflavor in [
                 'generic', 'lowlatency', 'edge', 'lowlatency-edge'
         ]:
             if kflavor == 'generic':
                 kernel = "hwe-%s" % style
             else:
                 kernel = "hwe-%s-%s" % (style, kflavor)
             arch = factory.make_name('arch')
             architecture = "%s/%s" % (arch, kernel)
             release = row['series'].split(' ')[0]
             factory.make_usable_boot_resource(
                 name="ubuntu/" + release,
                 kflavor=kflavor,
                 extra={'subarches': kernel},
                 architecture=architecture,
                 rtype=BOOT_RESOURCE_TYPE.SYNCED)
             factory.make_BootSourceCache(os="ubuntu",
                                          arch=arch,
                                          subarch=kernel,
                                          release=release)
             kernels.append((kernel, '%s (%s)' % (release, kernel)))
     return kernels
Beispiel #9
0
 def make_boot_source_cache(self):
     # Disable boot sources signals otherwise the test fails due to unrun
     # post-commit tasks at the end of the test.
     self.useFixture(SignalsDisabled("bootsources"))
     ubuntu = UbuntuDistroInfo()
     try:
         ubuntu_rows = ubuntu._rows
     except AttributeError:
         ubuntu_rows = [row.__dict__ for row in ubuntu._releases]
     supported_releases = [
         release
         for release in ubuntu_rows
         if int(release["version"].split(".")[0]) >= 12
     ]
     release = random.choice(supported_releases)
     ga_or_hwe = random.choice(["hwe", "ga"])
     subarch = "%s-%s" % (ga_or_hwe, release["version"].split(" ")[0])
     factory.make_BootSourceCache(
         os="ubuntu",
         arch=factory.make_name("arch"),
         subarch=subarch,
         release=release["series"],
         release_codename=release["codename"],
         release_title=release["version"],
         support_eol=release.get("eol_server", release.get("eol-server")),
     )
     return release
Beispiel #10
0
 def make_boot_source_cache(self):
     # Disable boot sources signals otherwise the test fails due to unrun
     # post-commit tasks at the end of the test.
     self.useFixture(SignalsDisabled("bootsources"))
     ubuntu = UbuntuDistroInfo()
     try:
         ubuntu_rows = ubuntu._rows
     except AttributeError:
         ubuntu_rows = [row.__dict__ for row in ubuntu._releases]
     supported_releases = [
         release for release in ubuntu_rows
         if int(release['version'].split('.')[0]) >= 12
     ]
     release = random.choice(supported_releases)
     ga_or_hwe = random.choice(['hwe', 'ga'])
     subarch = "%s-%s" % (ga_or_hwe, release['version'].split(' ')[0])
     factory.make_BootSourceCache(
         os='ubuntu',
         arch=factory.make_name('arch'),
         subarch=subarch,
         release=release['series'],
         release_codename=release['codename'],
         release_title=release['version'],
         support_eol=release.get('eol_server', release.get('eol-server')),
     )
     return release
Beispiel #11
0
 def make_kernel_string(self,
                        can_be_release_or_version=False,
                        generic_only=False):
     ubuntu = UbuntuDistroInfo()
     # Only select from MAAS supported releases so we don't have to deal
     # with versions name overlap(e.g Warty and Wily).
     try:
         ubuntu_rows = ubuntu._rows
     except AttributeError:
         ubuntu_rows = [row.__dict__ for row in ubuntu._releases]
     supported_releases = [
         release for release in ubuntu_rows
         if int(release["version"].split(".")[0]) >= 12
     ]
     release = random.choice(supported_releases)
     # Remove 'LTS' from version if it exists
     version_str = release["version"].split(" ")[0]
     strings = [
         "hwe-%s" % release["series"][0],
         "hwe-%s" % version_str,
         "hwe-%s-edge" % version_str,
     ]
     if not generic_only:
         strings += [
             "hwe-%s-lowlatency" % version_str,
             "hwe-%s-lowlatency-edge" % version_str,
         ]
     if can_be_release_or_version:
         strings += [release["series"], version_str]
     return random.choice(strings)
Beispiel #12
0
 def pick_release(self):
     ubuntu = UbuntuDistroInfo()
     supported_releases = [
         release for release in ubuntu._rows
         if int(release['version'].split('.')[0]) >= 12
     ]
     return random.choice(supported_releases)
Beispiel #13
0
    def get_distro_codename(self, distro):
        ubuntu_distro_info = UbuntuDistroInfo()

        for row in ubuntu_distro_info._rows:
            if row['series'] == distro:
                return row['codename']

        return None
Beispiel #14
0
 def pick_release(self):
     ubuntu = UbuntuDistroInfo()
     try:
         ubuntu_rows = ubuntu._rows
     except AttributeError:
         ubuntu_rows = [row.__dict__ for row in ubuntu._releases]
     supported_releases = [
         release for release in ubuntu_rows
         if int(release["version"].split(".")[0]) >= 12
     ]
     return random.choice(supported_releases)
Beispiel #15
0
def get_uploads_per_release(email):
    """
    Takes an email and returns an ordered dict of uploads per release.
    """
    uploads_per_release = OrderedDict([])
    for d in UbuntuDistroInfo().all:
        release_uploads = len(Uploads.objects.filter(
            email_changer=email).filter(release__icontains=d))
        if uploads_per_release or release_uploads > 0:
            uploads_per_release[d] = release_uploads
    return uploads_per_release
Beispiel #16
0
def get_uploads_per_release(email):
    """
    Takes an email and returns an ordered dict of uploads per release.
    """
    uploads_per_release = OrderedDict([])
    person = get_object_or_404(Person, email=email, authoritative_person=None)
    for d in UbuntuDistroInfo().all:
        release_uploads = len(Activity.objects.filter(
            person=person).filter(release__icontains=d))
        if uploads_per_release or release_uploads > 0:
            uploads_per_release[d] = release_uploads
    return uploads_per_release
Beispiel #17
0
def check_supported_distribution(changes, profile, interface):
    """
    The ``supported-distribution`` checker is a stock dput checker that checks
    packages intended for upload for a valid upload distribution.

    Profile key: supported-distribution
    """
    suite = changes['Distribution']
    if profile.get('codenames'):
        if '-' in suite:
            release, pocket = suite.split('-', 1)
        else:
            release, pocket = suite, 'release'

        codenames = profile['codenames']
        if codenames == 'ubuntu':
            distro_info = UbuntuDistroInfo()
            pockets = profile['supported-distribution']
            logger.critical(pockets)
            if pocket not in pockets['known']:
                raise UnknownDistribution("Unkown pocket: %s" % pocket)
            if pocket not in pockets['allowed']:
                raise UnknownDistribution(
                    "Uploads aren't permitted to pocket: %s" % pocket)
        elif codenames == 'debian':
            distro_info = DebianDistroInfo()
        else:
            raise UnknownDistribution("distro-info doesn't know about %s"
                                      % codenames)

        try:
            codename = distro_info.codename(release, default=release)
            if codename not in distro_info.all:
                raise UnsupportedDistribution('Unknown release %s' % release)
            if codename not in distro_info.supported():
                raise UnsupportedDistribution('Unsupported release %s'
                                              % release)
        except DistroDataOutdated:
            logger.warn('distro-info is outdated, '
                        'unable to check supported releases')
Beispiel #18
0
class UbuntuRelease(object):
    all_codenames = UbuntuDistroInfo().all

    def __init__(self, codename):
        if codename not in UbuntuRelease.all_codenames:
            raise ValueError("Unknown codename '{}'".format(codename))
        self.codename = codename

    def __eq__(self, other):
        return UbuntuRelease.all_codenames.index(
            self.codename) == UbuntuRelease.all_codenames.index(other)

    def __le__(self, other):
        return UbuntuRelease.all_codenames.index(
            self.codename) <= UbuntuRelease.all_codenames.index(other)
Beispiel #19
0
def _get_release_names():
    global _DEBIAN_RELEASES, _UBUNTU_RELEASES
    try:
        from distro_info import DebianDistroInfo, UbuntuDistroInfo
    except ImportError:
        warning("distro_info not available. Unable to retrieve current "
            "list of releases.")
        _DEBIAN_RELEASES = []
        _UBUNTU_RELEASES = []
    else:
        # distro info is not available
        _DEBIAN_RELEASES = DebianDistroInfo().all
        _UBUNTU_RELEASES = UbuntuDistroInfo().all

    _DEBIAN_RELEASES.extend(['stable', 'testing', 'unstable', 'frozen'])
Beispiel #20
0
 def make_boot_sources(self):
     kernels = []
     ubuntu = UbuntuDistroInfo()
     # LP: #1711191 - distro-info 0.16+ no longer returns dictionaries or
     # lists, and it now returns objects instead. As such, we need to
     # handle both cases for backwards compatibility.
     try:
         ubuntu_rows = ubuntu._rows
     except AttributeError:
         ubuntu_rows = [row.__dict__ for row in ubuntu._releases]
     for row in ubuntu_rows:
         release_year = int(row["version"].split(".")[0])
         if release_year < 12:
             continue
         elif release_year < 16:
             style = row["series"][0]
         else:
             style = row["version"]
         for kflavor in [
                 "generic",
                 "lowlatency",
                 "edge",
                 "lowlatency-edge",
         ]:
             if kflavor == "generic":
                 kernel = "hwe-%s" % style
             else:
                 kernel = "hwe-%s-%s" % (style, kflavor)
             arch = factory.make_name("arch")
             architecture = "%s/%s" % (arch, kernel)
             release = row["series"].split(" ")[0]
             factory.make_usable_boot_resource(
                 name="ubuntu/" + release,
                 kflavor=kflavor,
                 extra={"subarches": kernel},
                 architecture=architecture,
                 rtype=BOOT_RESOURCE_TYPE.SYNCED,
             )
             factory.make_BootSourceCache(os="ubuntu",
                                          arch=arch,
                                          subarch=kernel,
                                          release=release)
             kernels.append((kernel, "%s (%s)" % (release, kernel)))
     return kernels
Beispiel #21
0
 def make_kernel_string(
         self, can_be_release_or_version=False, generic_only=False):
     ubuntu = UbuntuDistroInfo()
     # Only select from MAAS supported releases so we don't have to deal
     # with versions name overlap(e.g Warty and Wily).
     supported_releases = [
         release for release in ubuntu._rows
         if int(release['version'].split('.')[0]) >= 12
     ]
     release = random.choice(supported_releases)
     # Remove 'LTS' from version if it exists
     version_str = release['version'].split(' ')[0]
     strings = [
         "hwe-%s" % release['series'][0], "hwe-%s" % version_str,
         "hwe-%s-edge" % version_str,
     ]
     if not generic_only:
         strings += [
             "hwe-%s-lowlatency" % version_str,
             "hwe-%s-lowlatency-edge" % version_str,
         ]
     if can_be_release_or_version:
         strings += [release['series'], version_str]
     return random.choice(strings)
Beispiel #22
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        ubuntu = UbuntuDistroInfo()
        # We can't test with releases older than Precise as they have duplicate
        # names(e.g Wily and Warty) which will break the old style kernel
        # tests.
        try:
            ubuntu_rows = ubuntu._rows
        except AttributeError:
            ubuntu_rows = [row.__dict__ for row in ubuntu._releases]
        valid_releases = [
            row
            for row in ubuntu_rows
            if int(row["version"].split(".")[0]) >= 12
        ]
        release = random.choice(valid_releases)
        # Remove 'LTS' from version if it exists
        version_str = release["version"].split(" ")[0]
        # Convert the version into a list of ints
        version_tuple = tuple([int(seg) for seg in version_str.split(".")])

        self.scenarios = (
            (
                "Release name",
                {
                    "string": release["series"],
                    "expected": version_tuple + tuple([0]),
                },
            ),
            (
                "Release version",
                {
                    "string": version_str,
                    "expected": version_tuple + tuple([0]),
                },
            ),
            (
                "Old style kernel",
                {
                    "string": "hwe-%s" % release["series"][0],
                    "expected": version_tuple + tuple([0]),
                },
            ),
            (
                "GA kernel",
                {
                    "string": "ga-%s" % version_str,
                    "expected": version_tuple + tuple([0]),
                },
            ),
            (
                "GA low latency kernel",
                {
                    "string": "ga-%s-lowlatency" % version_str,
                    "expected": version_tuple + tuple([0]),
                },
            ),
            (
                "New style kernel",
                {
                    "string": "hwe-%s" % version_str,
                    "expected": version_tuple + tuple([1]),
                },
            ),
            (
                "New style edge kernel",
                {
                    "string": "hwe-%s-edge" % version_str,
                    "expected": version_tuple + tuple([2]),
                },
            ),
            (
                "New style low latency kernel",
                {
                    "string": "hwe-%s-lowlatency" % version_str,
                    "expected": version_tuple + tuple([1]),
                },
            ),
            (
                "New style edge low latency kernel",
                {
                    "string": "hwe-%s-lowlatency-edge" % version_str,
                    "expected": version_tuple + tuple([2]),
                },
            ),
            (
                "Rolling kernel",
                {"string": "hwe-rolling", "expected": tuple([999, 999, 1])},
            ),
            (
                "Rolling edge kernel",
                {
                    "string": "hwe-rolling-edge",
                    "expected": tuple([999, 999, 2]),
                },
            ),
            (
                "Rolling lowlatency kernel",
                {
                    "string": "hwe-rolling-lowlatency",
                    "expected": tuple([999, 999, 1]),
                },
            ),
            (
                "Rolling lowlatency edge kernel",
                {
                    "string": "hwe-rolling-lowlatency-edge",
                    "expected": tuple([999, 999, 2]),
                },
            ),
        )
class UbuntuDistroInfoTestCase(unittest.TestCase):
    """TestCase object for distro_info.UbuntuDistroInfo"""

    #pylint: disable=C0103
    def setUp(self):
        self._distro_info = UbuntuDistroInfo()
        self._date = datetime.date(2011, 1, 10)

    #pylint: enable=C0103
    def test_all(self):
        """Test: List all known Ubuntu distributions."""
        all_distros = set(["warty", "hoary", "breezy", "dapper", "edgy",
                           "feisty", "gutsy", "hardy", "intrepid", "jaunty",
                           "karmic", "lucid", "maverick", "natty"])
        self.assertEqual(all_distros - set(self._distro_info.all), set())

    def test_devel(self):
        """Test: Get latest development Ubuntu distribution."""
        self.assertEqual(self._distro_info.devel(self._date), "natty")

    def test_lts(self):
        """Test: Get latest long term support (LTS) Ubuntu distribution."""
        self.assertEqual(self._distro_info.lts(self._date), "lucid")

    def test_stable(self):
        """Test: Get latest stable Ubuntu distribution."""
        self.assertEqual(self._distro_info.stable(self._date), "maverick")

    def test_supported(self):
        """Test: List all supported Ubuntu distribution."""
        supported = ["dapper", "hardy", "karmic", "lucid", "maverick", "natty"]
        self.assertEqual(self._distro_info.supported(self._date), supported)

    def test_unsupported(self):
        """Test: List all unsupported Ubuntu distributions."""
        unsupported = ["warty", "hoary", "breezy", "edgy", "feisty", "gutsy",
                       "intrepid", "jaunty"]
        self.assertEqual(self._distro_info.unsupported(self._date), unsupported)

    def test_current_unsupported(self):
        """Test: List all unsupported Ubuntu distributions today."""
        unsupported = set(["warty", "hoary", "breezy", "edgy", "feisty",
                           "gutsy", "intrepid", "jaunty"])
        self.assertEqual(unsupported -
                         set(self._distro_info.unsupported()), set())

    def test_valid(self):
        """Test: Check for valid Ubuntu distribution."""
        self.assertTrue(self._distro_info.valid("lucid"))
        self.assertFalse(self._distro_info.valid("42"))

    def test_is_lts(self):
        """Test: Check if Ubuntu distribution is an LTS."""
        self.assertTrue(self._distro_info.is_lts("lucid"))
        self.assertFalse(self._distro_info.is_lts("42"))
        self.assertFalse(self._distro_info.is_lts("warty"))

    def test_codename(self):
        """Test: Check result set to codename."""
        self.assertEqual(self._distro_info.lts(self._date, "codename"), "lucid")
        self.assertEqual(self._distro_info.devel(self._date, result="codename"),
                         "natty")

    def test_fullname(self):
        """Test: Check result set to fullname."""
        self.assertEqual(self._distro_info.stable(self._date, "fullname"),
                         'Ubuntu 10.10 "Maverick Meerkat"')
        self.assertEqual(self._distro_info.lts(self._date, result="fullname"),
                         'Ubuntu 10.04 LTS "Lucid Lynx"')

    def test_release(self):
        """Test: Check result set to release."""
        self.assertEqual(self._distro_info.devel(self._date, "release"),
                         "11.04")
        self.assertEqual(self._distro_info.lts(self._date, result="release"),
                         "10.04 LTS")
Beispiel #24
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import os, re
from flask import Flask, Response, Markup, request, render_template, make_response

from distro_info import DebianDistroInfo, UbuntuDistroInfo

debian = DebianDistroInfo()
ubuntu = UbuntuDistroInfo()

supported = list(reversed(debian.supported())) + list(
    reversed(ubuntu.supported()))

app = Flask(__name__)
_pattern = re.compile("^([0-9a-f]{8})$")


def get_file_path(remote_addr, file_name, series=None, code=None):
    if code and code == "default":
        return os.path.join(app.root_path, file_name)

    ip_addr = ''
    if code and _pattern.match(code):
        for i in (0, 2, 4, 6):
            ip_addr = ip_addr + str(int("0x" + code[i:i + 2], 16)) + '.'
        else:
            ip_addr = ip_addr[:-1]

    if series and series in supported:
        if ip_addr:
 def setUp(self):
     self._distro_info = UbuntuDistroInfo()
     self._date = datetime.date(2011, 1, 10)
Beispiel #26
0
 def get_lts_release(self):
     return UbuntuDistroInfo().lts()
Beispiel #27
0
 def test_get_release_title(self):
     osystem = UbuntuOS()
     info = UbuntuDistroInfo()
     release = random.choice(info.all)
     self.assertEqual(osystem.get_release_title(release),
                      self.get_release_title(release))
Beispiel #28
0
 def test_is_release_supported(self):
     osystem = UbuntuOS()
     info = UbuntuDistroInfo()
     self.assertTrue(osystem.is_release_supported(random.choice(info.all)))
Beispiel #29
0
def sponsor_patch(bug_number, build, builder, edit, keyid, lpinstance, update,
                  upload, workdir):
    workdir = os.path.realpath(os.path.expanduser(workdir))
    _create_and_change_into(workdir)

    launchpad = Launchpad.login_with("sponsor-patch", lpinstance)
    bug = launchpad.bugs[bug_number]

    (patch, branch) = get_patch_or_branch(bug)
    task = get_open_ubuntu_bug_task(launchpad, bug, branch)

    dsc_file = task.download_source()

    _download_and_change_into(task, dsc_file, patch, branch)

    source_package = SourcePackage(task.package, builder, workdir, branch)

    if is_sync(bug) and not edit:
        successful = source_package.reload_changelog()

        if successful:
            source_package.check_sync_request_version(bug_number, task)
            previous_version = task.get_previous_version()
            successful = source_package.check_version(previous_version)

        if successful:
            if build:
                dist = UbuntuDistroInfo().devel()
                successful = source_package.build(update, dist)
                update = False
            else:
                # We are going to run lintian, so we need a source package
                successful = source_package.build_source(
                    None, upload, previous_version)

        if successful:
            series = task.get_debian_source_series()
            if source_package.sync(upload, series, bug_number, bug.owner.name):
                return
            else:
                edit = True
        else:
            edit = True

    if patch:
        edit |= patch.apply(task)
    elif branch:
        edit |= merge_branch(branch)

    while True:
        if edit:
            edit_source()
        # All following loop executions require manual editing.
        edit = True

        _update_maintainer_field()
        if not source_package.reload_changelog():
            continue

        if not source_package.check_version(task.get_version()):
            continue

        _update_timestamp()

        if not source_package.build_source(keyid, upload,
                                           task.get_previous_version()):
            continue

        source_package.generate_debdiff(dsc_file)

        # Make sure that the Launchpad bug will be closed
        if not source_package.is_fixed(bug):
            continue

        if not source_package.check_target(upload, launchpad):
            continue

        if build:
            successful_built = source_package.build(update)
            update = False
            if not successful_built:
                continue

        if not source_package.ask_and_upload(upload):
            continue

        # Leave while loop if everything worked
        break
Beispiel #30
0
class UbuntuOS(OperatingSystem):
    """Ubuntu operating system."""

    name = "ubuntu"
    title = "Ubuntu"

    def __init__(self):
        self.ubuntu_distro_info = UbuntuDistroInfo()

    def get_boot_image_purposes(self, arch, subarch, release, label):
        """Gets the purpose of each boot image."""
        return [
            BOOT_IMAGE_PURPOSE.COMMISSIONING,
            BOOT_IMAGE_PURPOSE.INSTALL,
            BOOT_IMAGE_PURPOSE.XINSTALL,
            BOOT_IMAGE_PURPOSE.DISKLESS,
        ]

    def is_release_supported(self, release):
        """Return True when the release is supported, False otherwise."""
        row = self.get_distro_series_info_row(release)
        return row is not None

    def get_lts_release(self):
        """Return the latest Ubuntu LTS release."""
        return self.ubuntu_distro_info.lts()

    def get_default_release(self):
        """Gets the default release to use when a release is not
        explicit."""
        return self.get_lts_release()

    def get_supported_commissioning_releases(self):
        """Gets the supported commissioning releases for Ubuntu. This
        only exists on Ubuntu, because that is the only operating
        system that supports commissioning.
        """
        unsupported_releases = ['precise']
        return [
            name for name in self.ubuntu_distro_info.supported()
            if name not in unsupported_releases
            if self.ubuntu_distro_info.is_lts(name)
        ]

    def get_default_commissioning_release(self):
        """Gets the default commissioning release for Ubuntu. This only exists
        on Ubuntu, because that is the only operating system that supports
        commissioning.
        """
        return self.get_lts_release()

    def get_distro_series_info_row(self, release):
        """Returns the distro series row information from python-distro-info.
        """
        info = self.ubuntu_distro_info
        for row in info._avail(info._date):
            if row['series'] == release:
                return row
        return None

    def get_release_title(self, release):
        """Return the title for the given release."""
        row = self.get_distro_series_info_row(release)
        if row is None:
            return None
        return self.ubuntu_distro_info._format("fullname", row)

    def get_xinstall_parameters(self, arch, subarch, release, label):
        """Return the xinstall image name and type for this operating system.

        :param arch: Architecture of boot image.
        :param subarch: Sub-architecture of boot image.
        :param release: Release of boot image.
        :param label: Label of boot image.
        :return: tuple with name of root image and image type
        """
        with ClusterConfiguration.open() as config:
            squashfs_path = os.path.join(config.tftp_root, 'ubuntu', arch,
                                         subarch, release, label, 'squashfs')
        if os.path.exists(squashfs_path):
            return ('squashfs', 'squashfs')
        else:
            return ('root-tgz', 'tgz')
Beispiel #31
0
 def setUp(self):  # pylint: disable=invalid-name
     self._distro_info = UbuntuDistroInfo()
     self._date = datetime.date(2011, 1, 10)
Beispiel #32
0
 def __init__(self):
     self.ubuntu_distro_info = UbuntuDistroInfo()