Пример #1
0
 def test_get_supported_commissioning_releases(self):
     self.patch_autospec(UbuntuDistroInfo, "is_lts").return_value = True
     self.patch_autospec(UbuntuDistroInfo, "supported").return_value = [
         'precise', 'trusty', 'vivid', 'wily', 'xenial'
     ]
     osystem = UbuntuOS()
     releases = osystem.get_supported_commissioning_releases()
     self.assertIsInstance(releases, list)
     self.assertSequenceEqual(['vivid', 'wily', 'xenial'], releases)
Пример #2
0
 def test_get_supported_commissioning_releases_excludes_precise(self):
     """Make sure we remove 'precise' from the list."""
     self.patch_autospec(UbuntuDistroInfo, "supported").return_value = [
         'precise', 'trusty', 'vivid', 'wily', 'xenial'
     ]
     osystem = UbuntuOS()
     releases = osystem.get_supported_commissioning_releases()
     self.assertIsInstance(releases, list)
     self.assertNotIn('precise', releases)
Пример #3
0
def inner_start_up(master=False):
    """Startup jobs that must run serialized w.r.t. other starting servers."""
    # Register our MAC data type with psycopg.
    register_mac_type(connection.cursor())

    # All commissioning and testing scripts are stored in the database. For
    # a commissioning ScriptSet to be created Scripts must exist first. Call
    # this early, only on the master process, to ensure they exist and are
    # only created once. If get_or_create_running_controller() is called before
    # this it will fail on first run.
    if master:
        load_builtin_scripts()

    # Ensure the this region is represented in the database. The first regiond
    # to pass through inner_start_up on this host can do this; it should NOT
    # be restricted to masters only. This also ensures that the MAAS ID is set
    # on the filesystem; it will be done in a post-commit hook and will thus
    # happen before `locks.startup` is released.
    node = RegionController.objects.get_or_create_running_controller()
    # Update region version
    ControllerInfo.objects.set_version(node, get_running_version())
    # Ensure that uuid is created after creating
    RegionController.objects.get_or_create_uuid()

    # Only perform the following if the master process for the
    # region controller.
    if master:
        # Freshen the kms SRV records.
        dns_kms_setting_changed()

        # Make sure the commissioning distro series is still a supported LTS.
        commissioning_distro_series = Config.objects.get_config(
            name="commissioning_distro_series"
        )
        ubuntu = UbuntuOS()
        if commissioning_distro_series not in (
            ubuntu.get_supported_commissioning_releases()
        ):
            Config.objects.set_config(
                "commissioning_distro_series",
                ubuntu.get_default_commissioning_release(),
            )
            Notification.objects.create_info_for_admins(
                "Ubuntu %s is no longer a supported commissioning "
                "series. Ubuntu %s has been automatically selected."
                % (
                    commissioning_distro_series,
                    ubuntu.get_default_commissioning_release(),
                ),
                ident="commissioning_release_deprecated",
            )

        with RegionConfiguration.open() as config:
            Config.objects.set_config("maas_url", config.maas_url)

        # Update deprecation notifications if needed
        sync_deprecation_notifications()
Пример #4
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)
Пример #5
0
 def test_get_supported_commissioning_releases(self):
     self.patch_autospec(UbuntuDistroInfo, "is_lts").return_value = True
     self.patch_autospec(UbuntuDistroInfo, "supported").return_value = [
         "precise",
         "trusty",
         "vivid",
         "wily",
         "xenial",
     ]
     osystem = UbuntuOS()
     releases = osystem.get_supported_commissioning_releases()
     self.assertIsInstance(releases, list)
     self.assertSequenceEqual(["vivid", "wily", "xenial"], releases)
Пример #6
0
 def test_get_supported_commissioning_releases_excludes_deprecated(self):
     """Make sure we remove 'precise' from the list."""
     self.patch_autospec(UbuntuDistroInfo, "supported").return_value = [
         "precise",
         "trusty",
         "vivid",
         "wily",
         "xenial",
     ]
     osystem = UbuntuOS()
     releases = osystem.get_supported_commissioning_releases()
     self.assertIsInstance(releases, list)
     self.assertNotIn("precise", releases)
     self.assertNotIn("trusty", releases)
Пример #7
0
def inner_start_up(master=False):
    """Startup jobs that must run serialized w.r.t. other starting servers."""
    # Register our MAC data type with psycopg.
    register_mac_type(connection.cursor())

    # Ensure the this region is represented in the database. The first regiond
    # to pass through inner_start_up on this host can do this; it should NOT
    # be restricted to masters only. This also ensures that the MAAS ID is set
    # on the filesystem; it will be done in a post-commit hook and will thus
    # happen before `locks.startup` is released.
    region = RegionController.objects.get_or_create_running_controller()
    # Ensure that uuid is created after creating
    RegionController.objects.get_or_create_uuid()

    # Only perform the following if the master process for the
    # region controller.
    if master:
        # Freshen the kms SRV records.
        dns_kms_setting_changed()

        # Add or update all builtin scripts
        load_builtin_scripts()

        # Make sure the commissioning distro series is still a supported LTS.
        commissioning_distro_series = Config.objects.get_config(
            name="commissioning_distro_series")
        ubuntu = UbuntuOS()
        if commissioning_distro_series not in (
                ubuntu.get_supported_commissioning_releases()):
            Config.objects.set_config(
                "commissioning_distro_series",
                ubuntu.get_default_commissioning_release(),
            )
            Notification.objects.create_info_for_admins(
                "Ubuntu %s is no longer a supported commissioning "
                "series. Ubuntu %s has been automatically selected." % (
                    commissioning_distro_series,
                    ubuntu.get_default_commissioning_release(),
                ),
                ident="commissioning_release_deprecated",
            )

        # Update deprecation notifications if needed
        sync_deprecation_notifications()

        # Refresh soon after this transaction is in.
        post_commit_do(reactor.callLater, 0, refreshRegion, region)

        # Create a certificate for the region.
        post_commit_do(reactor.callLater, 0, generate_certificate_if_needed)
Пример #8
0
 def test_get_supported_commissioning_releases_excludes_unsupported_lts(
         self):
     self.patch_autospec(UbuntuDistroInfo, "supported").return_value = [
         'precise', 'trusty', 'vivid', 'wily', 'xenial'
     ]
     unsupported = [
         'warty', 'hoary', 'breezy', 'dapper', 'edgy', 'feisty', 'gutsy',
         'hardy', 'intrepid', 'jaunty', 'karmic', 'lucid', 'maverick',
         'natty', 'oneiric', 'quantal', 'raring', 'saucy', 'utopic'
     ]
     self.patch_autospec(UbuntuDistroInfo,
                         "unsupported").return_value = unsupported
     osystem = UbuntuOS()
     releases = osystem.get_supported_commissioning_releases()
     self.assertIsInstance(releases, list)
     for release in unsupported:
         self.assertNotIn(release, releases)
Пример #9
0
 def test_get_supported_commissioning_releases_excludes_unsupported_lts(
     self, ):
     self.patch_autospec(UbuntuDistroInfo, "supported").return_value = [
         "precise",
         "trusty",
         "vivid",
         "wily",
         "xenial",
     ]
     unsupported = [
         "warty",
         "hoary",
         "breezy",
         "dapper",
         "edgy",
         "feisty",
         "gutsy",
         "hardy",
         "intrepid",
         "jaunty",
         "karmic",
         "lucid",
         "maverick",
         "natty",
         "oneiric",
         "quantal",
         "raring",
         "saucy",
         "utopic",
     ]
     self.patch_autospec(UbuntuDistroInfo,
                         "unsupported").return_value = unsupported
     osystem = UbuntuOS()
     releases = osystem.get_supported_commissioning_releases()
     self.assertIsInstance(releases, list)
     for release in unsupported:
         self.assertNotIn(release, releases)