Commit 082a7f91 authored by Guido Trotter's avatar Guido Trotter
Browse files

OS API: support for multiple versions in an OS

Allow multiple api versions in an OS. This is according to the OS API
changes design doc, by which an OS can support multiple versions of the
Ganeti API and if one is supported by Ganeti it will work. Since up to
version 5 of the API mandates an OS could support only one version, this
change is retrocompatible with it and requires no version bump up.

Reviewed-by: iustinp
parent 2eb78bc8
......@@ -292,7 +292,6 @@ def VerifyNode(what, cluster_name):
connectivity with
- hypervisor: list with hypervisors to run the verify for
result = {}
......@@ -1169,21 +1168,21 @@ def _OSOndiskVersion(name, os_dir):
f = open(api_file)
api_version =
api_versions = f.readlines()
except EnvironmentError, err:
raise errors.InvalidOS(name, os_dir, "error while reading the"
" API version (%s)" % _ErrnoOrStr(err))
api_version = api_version.strip()
api_versions = [version.strip() for version in api_versions]
api_version = int(api_version)
api_versions = [int(version) for version in api_versions]
except (TypeError, ValueError), err:
raise errors.InvalidOS(name, os_dir,
"API version is not integer (%s)" % str(err))
return api_version
return api_versions
def DiagnoseOS(top_dirs=None):
......@@ -1238,12 +1237,12 @@ def OSFromDisk(name, base_dir=None):
os_dir = os.path.sep.join([base_dir, name])
api_version = _OSOndiskVersion(name, os_dir)
api_versions = _OSOndiskVersion(name, os_dir)
if api_version != constants.OS_API_VERSION:
if constants.OS_API_VERSION not in api_versions:
raise errors.InvalidOS(name, os_dir, "API version mismatch"
" (found %s want %s)"
% (api_version, constants.OS_API_VERSION))
% (api_versions, constants.OS_API_VERSION))
# OS Scripts dictionary, we will populate it with the actual script names
os_scripts = {'create': '', 'export': '', 'import': '', 'rename': ''}
......@@ -1271,7 +1270,7 @@ def OSFromDisk(name, base_dir=None):
def GrowBlockDevice(disk, amount):
......@@ -649,7 +649,7 @@ class OS(ConfigObject):
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