Beispiel #1
0
 def test_region_installed(self):
     apt_pkg = MockAptPkg()
     current = apt_pkg._make_package_version("3.0.0~alpha1-111-g.deadbeef")
     apt_pkg._add_package("maas-region-api", current=current)
     self.assertEqual(
         get_deb_versions_info(apt_pkg=apt_pkg),
         DebVersionsInfo(
             current=DebVersion(
                 version="3.0.0~alpha1-111-g.deadbeef", origin=""
             ),
             update=None,
         ),
     )
Beispiel #2
0
 def test_origin(self):
     apt_pkg = MockAptPkg()
     current = apt_pkg._make_package_version(
         "3.0.0~alpha1-111-g.deadbeef",
         origins=(
             (500, "http://archive.ubuntu.com", "focal", "main"),
             (900, "http://mirror.example.com", "focal", "other"),
         ),
     )
     apt_pkg._add_package("maas-region-api", current=current)
     self.assertEqual(
         get_deb_versions_info(apt_pkg=apt_pkg),
         DebVersionsInfo(
             current=DebVersion(
                 version="3.0.0~alpha1-111-g.deadbeef",
                 origin="http://mirror.example.com focal/other",
             ),
             update=None,
         ),
     )
Beispiel #3
0
def get_running_version() -> MAASVersion:
    """Return the version for the running MAAS."""
    git_rev = None
    revno = 0

    version_str = ""
    if snap.running_in_snap():
        version_str = snap.get_snap_version().version
    else:
        deb_versions = deb.get_deb_versions_info()
        if deb_versions:
            version_str = deb_versions.current.version
    if not version_str:
        version_str = _get_version_from_python_package()
        git_rev = _get_maas_repo_hash()
        revno = _get_maas_repo_commit_count()

    maas_version = MAASVersion.from_string(version_str)
    if (not maas_version.git_rev) and git_rev:
        maas_version = dataclasses.replace(maas_version, git_rev=git_rev)
    if (not maas_version.revno) and revno:
        maas_version = dataclasses.replace(maas_version, revno=revno)

    return maas_version
 def _get_versions_info(self):
     versions_info = get_snap_versions_info()
     if not versions_info:
         versions_info = get_deb_versions_info()
     return versions_info
Beispiel #5
0
 def test_no_package_installed(self):
     apt_pkg = MockAptPkg()
     apt_pkg._add_package("maas-region-api")
     self.assertIsNone(get_deb_versions_info(apt_pkg=apt_pkg))
Beispiel #6
0
 def test_no_package_known(self):
     apt_pkg = MockAptPkg()
     self.assertIsNone(get_deb_versions_info(apt_pkg=apt_pkg))