LGTM, thanks.

On Mon, Oct 7, 2013 at 6:39 PM, Klaus Aehlig <[email protected]> wrote:

> In order for 'gnt-cluster upgrade --resume' to determine whether the
> configuration
> is already upgraded, it needs to compare whether a configuration version
> is compatible
> with a Ganeti target version. Provide a utility function for this.
>
> Signed-off-by: Klaus Aehlig <[email protected]>
> ---
>  lib/utils/version.py                     | 15 +++++++++++++++
>  test/py/ganeti.utils.version_unittest.py |  7 +++++++
>  2 files changed, 22 insertions(+)
>
> diff --git a/lib/utils/version.py b/lib/utils/version.py
> index 325636d..9ae4838 100644
> --- a/lib/utils/version.py
> +++ b/lib/utils/version.py
> @@ -137,3 +137,18 @@ def ShouldCfgdowngrade(version,
> current=CURRENT_VERSION):
>
>    """
>    return version[0] == current[0] and version[1] == current[1] - 1
> +
> +
> +def IsCorrectConfigVersion(targetversion, configversion):
> +  """Decide whether configuration version is compatible with the target.
> +
> +  @param targetversion: The version to upgrade to as (major, minor,
> revision)
> +  @type targetversion: tuple
> +  @param configversion: The version of the current configuration
> +  @type configversion: tuple
> +  @rtype: bool
> +  @return: True, if the configversion fits with the target version.
> +
> +  """
> +  return (configversion[0] == targetversion[0] and
> +          configversion[1] == targetversion[1])
> diff --git a/test/py/ganeti.utils.version_unittest.py b/test/py/
> ganeti.utils.version_unittest.py
> index 64eea71..06b878f 100755
> --- a/test/py/ganeti.utils.version_unittest.py
> +++ b/test/py/ganeti.utils.version_unittest.py
> @@ -65,5 +65,12 @@ class ShouldCfgdowngradeTest(unittest.TestCase):
>          self.assertFalse(version.ShouldCfgdowngrade((2,10,0),
> current=(3,10,0)))
>
>
> +class IsCorrectConfigVersionTest(unittest.TestCase):
> +    def testIsCorrectConfigVersion(self):
> +        self.assertTrue(version.IsCorrectConfigVersion((2,10,1),
> (2,10,0)))
> +        self.assertFalse(version.IsCorrectConfigVersion((2,11,0),
> (2,10,0)))
> +        self.assertFalse(version.IsCorrectConfigVersion((3,10,0),
> (2,10,0)))
> +
> +
>  if __name__ == "__main__":
>    testutils.GanetiTestProgram()
> --
> 1.8.4
>
>


-- 
Thomas Thrainer | Software Engineer | [email protected] |

Google Germany GmbH
Dienerstr. 12
80331 München

Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg
Geschäftsführer: Graham Law, Christine Elizabeth Flores

Reply via email to