Beispiel #1
0
 def test_snap_cohort_from_update(self):
     c1 = factory.make_RackController()
     c2 = factory.make_RackController()
     ControllerInfo.objects.set_versions_info(
         c1,
         SnapVersionsInfo(
             current={
                 "version": "3.0.0-111-g.aaa",
                 "revision": "1234"
             },
             cohort="abc",
             update={
                 "version": "3.0.2-333-g.ccc",
                 "revision": "7890"
             },
         ),
     )
     ControllerInfo.objects.set_versions_info(
         c2,
         SnapVersionsInfo(
             current={
                 "version": "3.0.1-222-g.bbb",
                 "revision": "5678"
             },
             cohort="xyz",
         ),
     )
     target_version = get_target_version()
     self.assertEqual(target_version.snap_cohort, "abc")
Beispiel #2
0
 def test_snap_cohort_multiple_cohorts_target_version(self):
     c1 = factory.make_RackController()
     c2 = factory.make_RackController()
     ControllerInfo.objects.set_versions_info(
         c1,
         SnapVersionsInfo(
             current={
                 "version": "3.0.0-111-g.aaa",
                 "revision": "1234"
             },
             cohort="abc",
         ),
     )
     ControllerInfo.objects.set_versions_info(
         c2,
         SnapVersionsInfo(
             current={
                 "version": "3.0.0-111-g.aaa",
                 "revision": "1234"
             },
             cohort="xyz",
         ),
     )
     target_version = get_target_version()
     self.assertEqual(target_version.snap_cohort, "")
Beispiel #3
0
 def test_snap_channel(self):
     c1 = factory.make_RackController()
     c2 = factory.make_RackController()
     ControllerInfo.objects.set_versions_info(
         c1,
         SnapVersionsInfo(
             current={
                 "version": "3.0.0-111-g.aaa",
                 "revision": "1234"
             },
             channel={
                 "track": "3.0",
                 "risk": "stable"
             },
         ),
     )
     ControllerInfo.objects.set_versions_info(
         c2,
         SnapVersionsInfo(
             current={
                 "version": "3.0.0-111-g.aaa",
                 "revision": "1234"
             },
             channel={
                 "track": "3.0",
                 "risk": "beta"
             },
         ),
     )
     target_version = get_target_version()
     # the most stable channel is returned
     self.assertEqual(
         target_version.snap_channel,
         SnapChannel("3.0", "stable"),
     )
Beispiel #4
0
 def test_snap_channel_ignores_deb(self):
     c1 = factory.make_RackController()
     c2 = factory.make_RackController()
     ControllerInfo.objects.set_versions_info(
         c1,
         SnapVersionsInfo(
             current={
                 "version": "3.0.0-111-g.aaa",
                 "revision": "1234"
             },
             channel={
                 "track": "3.0",
                 "risk": "stable"
             },
         ),
     )
     ControllerInfo.objects.set_versions_info(
         c2,
         DebVersionsInfo(
             current={
                 "version": "3.0.0~beta1-001-g.bbb",
                 "origin": "http://archive.ubuntu.com/ focal/main",
             },
             update={
                 "version": "3.0.0-111-g.aaa",
                 "origin": "http://archive.ubuntu.com/ focal/main",
             },
         ),
     )
     target_version = get_target_version()
     self.assertEqual(
         target_version.snap_channel,
         SnapChannel("3.0", "stable"),
     )
Beispiel #5
0
 def test_update_return_earliest_reported(self):
     c1 = factory.make_RackController()
     c2 = factory.make_RackController()
     c3 = factory.make_RackController()
     ControllerInfo.objects.set_versions_info(
         c1,
         DebVersionsInfo(
             current={"version": "2.9.0-001-g.zzz"},
             update={"version": "3.0.0~alpha1-111-g.aaa"},
         ),
     )
     ControllerInfo.objects.set_versions_info(
         c2,
         DebVersionsInfo(
             current={"version": "2.9.0-001-g.zzz"},
             update={"version": "3.0.0-333-g.ccc"},
         ),
     )
     ControllerInfo.objects.set_versions_info(
         c3,
         DebVersionsInfo(
             current={"version": "2.9.0-001-g.zzz"},
             update={"version": "3.0.0-333-g.ccc"},
         ),
     )
     target_version = get_target_version()
     self.assertEqual(
         target_version.version,
         MAASVersion.from_string("3.0.0-333-g.ccc"),
     )
     self.assertEqual(
         target_version.first_reported,
         c2.info.update_first_reported,
     )
Beispiel #6
0
 def target_version(self, params):
     """Return the deployment target version."""
     target_version = get_target_version()
     return {
         "version": str(target_version.version),
         "snap_channel": str(target_version.snap_channel),
         "snap_cohort": target_version.snap_cohort,
         "first_reported": target_version.first_reported,
     }
Beispiel #7
0
 def test_snap_channel_from_version(self):
     c1 = factory.make_RackController()
     ControllerInfo.objects.set_versions_info(
         c1,
         DebVersionsInfo(current={"version": "3.0.0~rc1-111-g.aaa"}, ),
     )
     target_version = get_target_version()
     self.assertEqual(
         target_version.snap_channel,
         SnapChannel("3.0", "candidate"),
     )
Beispiel #8
0
def generate_rack_controller_configuration(node):
    """Generate cloud-init configuration to install the rack controller."""
    # To determine this is a machine that's accessing the metadata after
    # initial deployment, we use 'node.netboot'. This flag is set to off after
    # curtin has installed the operating system and before the machine reboots
    # for the first time.
    if (not node.netboot and node.install_rackd
            and node.osystem in ("ubuntu", "ubuntu-core")):
        hostname = get_maas_facing_server_host(node.get_boot_rack_controller())
        maas_url = f"http://{hostname}:5240/MAAS"
        secret = Config.objects.get_config("rpc_shared_secret")
        channel = str(get_target_version().snap_channel)
        yield "runcmd", [
            f"snap install maas --channel={channel}",
            f"/snap/bin/maas init rack --maas-url {maas_url} --secret {secret}",
        ]
Beispiel #9
0
 def test_update_older_than_installed(self):
     c1 = factory.make_RackController()
     c2 = factory.make_RackController()
     ControllerInfo.objects.set_versions_info(
         c1,
         DebVersionsInfo(current={"version": "3.0.0-111-g.aaa"}, ),
     )
     ControllerInfo.objects.set_versions_info(
         c2,
         DebVersionsInfo(
             current={"version": "2.9.0-001-g.zzz"},
             update={"version": "2.9.1-010-g.bbb"},
         ),
     )
     target_version = get_target_version()
     self.assertEqual(target_version.version,
                      MAASVersion.from_string("3.0.0-111-g.aaa"))
Beispiel #10
0
 def test_snap_channel_keep_release_branch(self):
     controller = factory.make_RackController()
     ControllerInfo.objects.set_versions_info(
         controller,
         SnapVersionsInfo(
             current={
                 "version": "3.0.0-111-g.aaa",
                 "revision": "1234"
             },
             channel={
                 "track": "3.0",
                 "risk": "beta",
                 "branch": "ubuntu-20.04",
             },
         ),
     )
     target_version = get_target_version()
     self.assertEqual(
         target_version.snap_channel,
         SnapChannel("3.0", "beta", branch="ubuntu-20.04"),
     )
Beispiel #11
0
 def test_return_highest_version(self):
     c1 = factory.make_RackController()
     c2 = factory.make_RackController()
     c3 = factory.make_RackController()
     ControllerInfo.objects.set_versions_info(
         c1,
         DebVersionsInfo(current={"version": "3.0.0~alpha1-111-g.aaa"}),
     )
     ControllerInfo.objects.set_versions_info(
         c2,
         DebVersionsInfo(current={"version": "3.0.0~beta1-222-g.bbb"}),
     )
     ControllerInfo.objects.set_versions_info(
         c3,
         DebVersionsInfo(current={"version": "3.0.0-333-g.ccc"}),
     )
     target_version = get_target_version()
     self.assertEqual(
         target_version.version,
         MAASVersion.from_string("3.0.0-333-g.ccc"),
     )
Beispiel #12
0
 def test_empty(self):
     factory.make_RackController()
     self.assertIsNone(get_target_version())
Beispiel #13
0
 def _target_version(self):
     """Cache the deployment target version"""
     return get_target_version()