Commit 16e81432 authored by Klaus Aehlig's avatar Klaus Aehlig
Browse files

Add function to determine current configuration version



The 'gnt-cluster upgrade --resume' command needs to determine whether the
configuration has already been updated or not, in order to decide at which
phase to resume. So provide a function to determine the version of the
configuration on file.
Signed-off-by: default avatarKlaus Aehlig <aehlig@google.com>
Reviewed-by: default avatarThomas Thrainer <thomasth@google.com>
parent 36cfb584
......@@ -45,6 +45,7 @@ from ganeti import compat
from ganeti import netutils
from ganeti import ssconf
from ganeti import pathutils
from ganeti import serializer
from ganeti import qlang
......@@ -1746,6 +1747,22 @@ def _ExecuteCommands(fns):
fn()
def _GetConfigVersion():
"""Determine the version the configuration file currently has.
@rtype: tuple or None
@return: (major, minor, revision) if the version can be determined,
None otherwise
"""
config_data = serializer.LoadJson(utils.ReadFile(pathutils.CLUSTER_CONF_FILE))
try:
config_version = config_data["version"]
except KeyError:
return None
return utils.SplitVersion(config_version)
def _ReadIntentToUpgrade():
"""Read the file documenting the intent to upgrade the cluster.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment