Commit d1a7d66f authored by Guido Trotter's avatar Guido Trotter
Browse files

Introduce OS api version 15



Also, since Ganeti 2.1 will be compatible with both 10 and 15, change
the OS_API_VERSION constant to be an OS_API_VERSIONS set, and update the
places in the code that used that constat to use something else.

In particular:
  - in the qa for now we just create a fake version 10 OS
  - in the os environment we use the highest common version
    (which means we need to pass in the os to OSEnvironment)
  - when loading an OS any common version will do
Signed-off-by: default avatarGuido Trotter <ultrotter@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 63b9b186
...@@ -712,7 +712,7 @@ def InstanceOsAdd(instance, reinstall): ...@@ -712,7 +712,7 @@ def InstanceOsAdd(instance, reinstall):
""" """
inst_os = OSFromDisk(instance.os) inst_os = OSFromDisk(instance.os)
create_env = OSEnvironment(instance) create_env = OSEnvironment(instance, inst_os)
if reinstall: if reinstall:
create_env['INSTANCE_REINSTALL'] = "1" create_env['INSTANCE_REINSTALL'] = "1"
...@@ -744,7 +744,7 @@ def RunRenameInstance(instance, old_name): ...@@ -744,7 +744,7 @@ def RunRenameInstance(instance, old_name):
""" """
inst_os = OSFromDisk(instance.os) inst_os = OSFromDisk(instance.os)
rename_env = OSEnvironment(instance) rename_env = OSEnvironment(instance, inst_os)
rename_env['OLD_INSTANCE_NAME'] = old_name rename_env['OLD_INSTANCE_NAME'] = old_name
logfile = "%s/rename-%s-%s-%s-%d.log" % (constants.LOG_OS_DIR, instance.os, logfile = "%s/rename-%s-%s-%s-%d.log" % (constants.LOG_OS_DIR, instance.os,
...@@ -1569,9 +1569,9 @@ def _TryOSFromDisk(name, base_dir=None): ...@@ -1569,9 +1569,9 @@ def _TryOSFromDisk(name, base_dir=None):
# push the error up # push the error up
return status, api_versions return status, api_versions
if constants.OS_API_VERSION not in api_versions: if not constants.OS_API_VERSIONS.intersection(api_versions):
return False, ("API version mismatch for path '%s': found %s, want %s." % return False, ("API version mismatch for path '%s': found %s, want %s." %
(os_dir, api_versions, constants.OS_API_VERSION)) (os_dir, api_versions, constants.OS_API_VERSIONS))
# OS Scripts dictionary, we will populate it with the actual script names # OS Scripts dictionary, we will populate it with the actual script names
os_scripts = dict.fromkeys(constants.OS_SCRIPTS) os_scripts = dict.fromkeys(constants.OS_SCRIPTS)
...@@ -1628,11 +1628,13 @@ def OSFromDisk(name, base_dir=None): ...@@ -1628,11 +1628,13 @@ def OSFromDisk(name, base_dir=None):
return payload return payload
def OSEnvironment(instance, debug=0): def OSEnvironment(instance, os, debug=0):
"""Calculate the environment for an os script. """Calculate the environment for an os script.
@type instance: L{objects.Instance} @type instance: L{objects.Instance}
@param instance: target instance for the os script run @param instance: target instance for the os script run
@type os: L{objects.OS}
@param os: operating system for which the environment is being built
@type debug: integer @type debug: integer
@param debug: debug level (0 or 1, for OS Api 10) @param debug: debug level (0 or 1, for OS Api 10)
@rtype: dict @rtype: dict
...@@ -1642,7 +1644,8 @@ def OSEnvironment(instance, debug=0): ...@@ -1642,7 +1644,8 @@ def OSEnvironment(instance, debug=0):
""" """
result = {} result = {}
result['OS_API_VERSION'] = '%d' % constants.OS_API_VERSION api_version = max(constants.OS_API_VERSIONS.intersection(os.api_versions))
result['OS_API_VERSION'] = '%d' % api_version
result['INSTANCE_NAME'] = instance.name result['INSTANCE_NAME'] = instance.name
result['INSTANCE_OS'] = instance.os result['INSTANCE_OS'] = instance.os
result['HYPERVISOR'] = instance.hypervisor result['HYPERVISOR'] = instance.hypervisor
...@@ -1759,9 +1762,9 @@ def ExportSnapshot(disk, dest_node, instance, cluster_name, idx): ...@@ -1759,9 +1762,9 @@ def ExportSnapshot(disk, dest_node, instance, cluster_name, idx):
@rtype: None @rtype: None
""" """
export_env = OSEnvironment(instance)
inst_os = OSFromDisk(instance.os) inst_os = OSFromDisk(instance.os)
export_env = OSEnvironment(instance, inst_os)
export_script = inst_os.export_script export_script = inst_os.export_script
logfile = "%s/exp-%s-%s-%s.log" % (constants.LOG_OS_DIR, inst_os.name, logfile = "%s/exp-%s-%s-%s.log" % (constants.LOG_OS_DIR, inst_os.name,
...@@ -1903,8 +1906,8 @@ def ImportOSIntoInstance(instance, src_node, src_images, cluster_name): ...@@ -1903,8 +1906,8 @@ def ImportOSIntoInstance(instance, src_node, src_images, cluster_name):
@return: each boolean represent the success of importing the n-th disk @return: each boolean represent the success of importing the n-th disk
""" """
import_env = OSEnvironment(instance)
inst_os = OSFromDisk(instance.os) inst_os = OSFromDisk(instance.os)
import_env = OSEnvironment(instance, inst_os)
import_script = inst_os.import_script import_script = inst_os.import_script
logfile = "%s/import-%s-%s-%s.log" % (constants.LOG_OS_DIR, instance.os, logfile = "%s/import-%s-%s-%s.log" % (constants.LOG_OS_DIR, instance.os,
......
...@@ -2577,7 +2577,7 @@ class LUQueryClusterInfo(NoHooksLU): ...@@ -2577,7 +2577,7 @@ class LUQueryClusterInfo(NoHooksLU):
"software_version": constants.RELEASE_VERSION, "software_version": constants.RELEASE_VERSION,
"protocol_version": constants.PROTOCOL_VERSION, "protocol_version": constants.PROTOCOL_VERSION,
"config_version": constants.CONFIG_VERSION, "config_version": constants.CONFIG_VERSION,
"os_api_version": constants.OS_API_VERSION, "os_api_version": max(constants.OS_API_VERSIONS),
"export_version": constants.EXPORT_VERSION, "export_version": constants.EXPORT_VERSION,
"architecture": (platform.architecture()[0], platform.machine()), "architecture": (platform.architecture()[0], platform.machine()),
"name": cluster.cluster_name, "name": cluster.cluster_name,
......
...@@ -26,7 +26,9 @@ from ganeti import _autoconf ...@@ -26,7 +26,9 @@ from ganeti import _autoconf
# various versions # various versions
PROTOCOL_VERSION = 20 PROTOCOL_VERSION = 20
RELEASE_VERSION = _autoconf.PACKAGE_VERSION RELEASE_VERSION = _autoconf.PACKAGE_VERSION
OS_API_VERSION = 10 OS_API_V10 = 10
OS_API_V15 = 15
OS_API_VERSIONS = frozenset([OS_API_V10, OS_API_V15])
EXPORT_VERSION = 0 EXPORT_VERSION = 0
RAPI_VERSION = 2 RAPI_VERSION = 2
......
...@@ -72,7 +72,7 @@ def _SetupTempOs(node, dir, valid): ...@@ -72,7 +72,7 @@ def _SetupTempOs(node, dir, valid):
if valid: if valid:
parts.append(sq(["ln", "-fs", "/bin/true", "create"])) parts.append(sq(["ln", "-fs", "/bin/true", "create"]))
parts.append(sq(["echo", str(constants.OS_API_VERSION)]) + parts.append(sq(["echo", str(constants.OS_API_V10)]) +
" >ganeti_api_version") " >ganeti_api_version")
cmd = ' && '.join(parts) cmd = ' && '.join(parts)
......
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