Revision d1a7d66f

b/lib/backend.py
712 712
  """
713 713
  inst_os = OSFromDisk(instance.os)
714 714

  
715
  create_env = OSEnvironment(instance)
715
  create_env = OSEnvironment(instance, inst_os)
716 716
  if reinstall:
717 717
    create_env['INSTANCE_REINSTALL'] = "1"
718 718

  
......
744 744
  """
745 745
  inst_os = OSFromDisk(instance.os)
746 746

  
747
  rename_env = OSEnvironment(instance)
747
  rename_env = OSEnvironment(instance, inst_os)
748 748
  rename_env['OLD_INSTANCE_NAME'] = old_name
749 749

  
750 750
  logfile = "%s/rename-%s-%s-%s-%d.log" % (constants.LOG_OS_DIR, instance.os,
......
1569 1569
    # push the error up
1570 1570
    return status, api_versions
1571 1571

  
1572
  if constants.OS_API_VERSION not in api_versions:
1572
  if not constants.OS_API_VERSIONS.intersection(api_versions):
1573 1573
    return False, ("API version mismatch for path '%s': found %s, want %s." %
1574
                   (os_dir, api_versions, constants.OS_API_VERSION))
1574
                   (os_dir, api_versions, constants.OS_API_VERSIONS))
1575 1575

  
1576 1576
  # OS Scripts dictionary, we will populate it with the actual script names
1577 1577
  os_scripts = dict.fromkeys(constants.OS_SCRIPTS)
......
1628 1628
  return payload
1629 1629

  
1630 1630

  
1631
def OSEnvironment(instance, debug=0):
1631
def OSEnvironment(instance, os, debug=0):
1632 1632
  """Calculate the environment for an os script.
1633 1633

  
1634 1634
  @type instance: L{objects.Instance}
1635 1635
  @param instance: target instance for the os script run
1636
  @type os: L{objects.OS}
1637
  @param os: operating system for which the environment is being built
1636 1638
  @type debug: integer
1637 1639
  @param debug: debug level (0 or 1, for OS Api 10)
1638 1640
  @rtype: dict
......
1642 1644

  
1643 1645
  """
1644 1646
  result = {}
1645
  result['OS_API_VERSION'] = '%d' % constants.OS_API_VERSION
1647
  api_version = max(constants.OS_API_VERSIONS.intersection(os.api_versions))
1648
  result['OS_API_VERSION'] = '%d' % api_version
1646 1649
  result['INSTANCE_NAME'] = instance.name
1647 1650
  result['INSTANCE_OS'] = instance.os
1648 1651
  result['HYPERVISOR'] = instance.hypervisor
......
1759 1762
  @rtype: None
1760 1763

  
1761 1764
  """
1762
  export_env = OSEnvironment(instance)
1763

  
1764 1765
  inst_os = OSFromDisk(instance.os)
1766
  export_env = OSEnvironment(instance, inst_os)
1767

  
1765 1768
  export_script = inst_os.export_script
1766 1769

  
1767 1770
  logfile = "%s/exp-%s-%s-%s.log" % (constants.LOG_OS_DIR, inst_os.name,
......
1903 1906
  @return: each boolean represent the success of importing the n-th disk
1904 1907

  
1905 1908
  """
1906
  import_env = OSEnvironment(instance)
1907 1909
  inst_os = OSFromDisk(instance.os)
1910
  import_env = OSEnvironment(instance, inst_os)
1908 1911
  import_script = inst_os.import_script
1909 1912

  
1910 1913
  logfile = "%s/import-%s-%s-%s.log" % (constants.LOG_OS_DIR, instance.os,
b/lib/cmdlib.py
2577 2577
      "software_version": constants.RELEASE_VERSION,
2578 2578
      "protocol_version": constants.PROTOCOL_VERSION,
2579 2579
      "config_version": constants.CONFIG_VERSION,
2580
      "os_api_version": constants.OS_API_VERSION,
2580
      "os_api_version": max(constants.OS_API_VERSIONS),
2581 2581
      "export_version": constants.EXPORT_VERSION,
2582 2582
      "architecture": (platform.architecture()[0], platform.machine()),
2583 2583
      "name": cluster.cluster_name,
b/lib/constants.py
26 26
# various versions
27 27
PROTOCOL_VERSION = 20
28 28
RELEASE_VERSION = _autoconf.PACKAGE_VERSION
29
OS_API_VERSION = 10
29
OS_API_V10 = 10
30
OS_API_V15 = 15
31
OS_API_VERSIONS = frozenset([OS_API_V10, OS_API_V15])
30 32
EXPORT_VERSION = 0
31 33
RAPI_VERSION = 2
32 34

  
b/qa/qa_os.py
72 72
  if valid:
73 73
    parts.append(sq(["ln", "-fs", "/bin/true", "create"]))
74 74

  
75
  parts.append(sq(["echo", str(constants.OS_API_VERSION)]) +
75
  parts.append(sq(["echo", str(constants.OS_API_V10)]) +
76 76
               " >ganeti_api_version")
77 77

  
78 78
  cmd = ' && '.join(parts)

Also available in: Unified diff