def run() -> Union[str, None]:
        """
        Implementation of `get_iso_version` command.

        Returns
        -------
        Union[str, None]:
            Return string with SW upgrade ISO version if it is higher then
            release version. Return None if SW upgrade ISO version is equal
            to release version. Raise exception otherwise

        """

        release_ver = GetRelease.cortx_version()
        upgrade_ver = GetSWUpgradeInfo.cortx_version()

        if upgrade_ver is None:
            return None  # There are no configured upgrade repos

        release_ver_parsed = version.parse(release_ver)
        upgrade_ver_parsed = version.parse(upgrade_ver)

        if upgrade_ver_parsed > release_ver_parsed:
            return str(upgrade_ver)
        elif upgrade_ver_parsed == release_ver_parsed:
            return None
        else:  # upgrade_ver < release_ver
            raise ProvisionerError(
                "Upgrade version is lower than currently installed one")
Example #2
0
def test_SSLCertsUpdateError_str():
    prov_obj = ProvisionerError()
    rollback_error = 'some-error'

    obj = SSLCertsUpdateError(prov_obj, rollback_error)

    assert str(obj) == "SSL Cert update failed: {!r}".format(obj)
Example #3
0
def test_SSLCertsUpdateError_repr():
    reason = ProvisionerError()
    rollback_error = 'some-error'

    obj = SSLCertsUpdateError(reason, rollback_error)

    assert repr(obj) == "{}(reason={!r}, rollback_error={!r})".format(
        obj.__class__.__name__, reason, rollback_error)
Example #4
0
 def get_color_pair(color_code):
     if not config.color_codes.get(color_code, None):
         raise ProvisionerError(f"Color code {color_code} not defined")
     return curses.color_pair(color_code)
def test_serialize_prvsnr_exception():
    exc1 = ProvisionerError(123)
    exc2 = loads(dumps({'exc': exc1}))['exc']
    assert type(exc1) is type(exc2)
    assert exc1.args == exc2.args