Revision 1bdcbbab

b/lib/backend.py
1930 1930
  return payload
1931 1931

  
1932 1932

  
1933
def OSCoreEnv(inst_os, debug=0):
1933
def OSCoreEnv(inst_os, os_params, debug=0):
1934 1934
  """Calculate the basic environment for an os script.
1935 1935

  
1936 1936
  @type inst_os: L{objects.OS}
1937 1937
  @param inst_os: operating system for which the environment is being built
1938
  @type os_params: dict
1939
  @param os_params: the OS parameters
1938 1940
  @type debug: integer
1939 1941
  @param debug: debug level (0 or 1, for OS Api 10)
1940 1942
  @rtype: dict
......
1958 1960
      variant = inst_os.supported_variants[0]
1959 1961
    result['OS_VARIANT'] = variant
1960 1962

  
1963
  # OS params
1964
  for pname, pvalue in os_params.items():
1965
    result['OSP_%s' % pname.upper()] = pvalue
1966

  
1961 1967
  return result
1962 1968

  
1963 1969

  
......
1976 1982
      cannot be found
1977 1983

  
1978 1984
  """
1979
  result = OSCoreEnv(inst_os, debug)
1985
  result = OSCoreEnv(inst_os, instance.osparams, debug=debug)
1980 1986

  
1981 1987
  result['INSTANCE_NAME'] = instance.name
1982 1988
  result['INSTANCE_OS'] = instance.os
b/lib/objects.py
657 657
    "hypervisor",
658 658
    "hvparams",
659 659
    "beparams",
660
    "osparams",
660 661
    "admin_up",
661 662
    "nics",
662 663
    "disks",
......
812 813
          del self.hvparams[key]
813 814
        except KeyError:
814 815
          pass
816
    if self.osparams is None:
817
      self.osparams = {}
815 818

  
816 819

  
817 820
class OS(ConfigObject):
......
869 872
    "hvparams",
870 873
    "os_hvp",
871 874
    "beparams",
875
    "osparams",
872 876
    "nicparams",
873 877
    "candidate_pool_size",
874 878
    "modify_etc_hosts",
......
893 897
    if self.os_hvp is None:
894 898
      self.os_hvp = {}
895 899

  
900
    # osparams added before 2.2
901
    if self.osparams is None:
902
      self.osparams = {}
903

  
896 904
    self.beparams = UpgradeGroupedParams(self.beparams,
897 905
                                         constants.BEC_DEFAULTS)
898 906
    migrate_default_bridge = not self.nicparams
......
1043 1051
    """
1044 1052
    return FillDict(self.nicparams.get(constants.PP_DEFAULT, {}), nicparams)
1045 1053

  
1054
  def SimpleFillOS(self, os_name, os_params):
1055
    """Fill an instance's osparams dict with cluster defaults.
1056

  
1057
    @type os_name: string
1058
    @param os_name: the OS name to use
1059
    @type os_params: dict
1060
    @param os_params: the dict to fill with default values
1061
    @rtype: dict
1062
    @return: a copy of the instance's osparams with missing keys filled from
1063
        the cluster defaults
1064

  
1065
    """
1066
    name_only = os_name.split("+", 1)[0]
1067
    # base OS
1068
    result = self.osparams.get(name_only, {})
1069
    # OS with variant
1070
    result = FillDict(result, self.osparams.get(os_name, {}))
1071
    # specified params
1072
    return FillDict(result, os_params)
1073

  
1046 1074

  
1047 1075
class BlockDevStatus(ConfigObject):
1048 1076
  """Config object representing the status of a block device."""
b/lib/rpc.py
329 329
    self._cfg = cfg
330 330
    self.port = utils.GetDaemonPort(constants.NODED)
331 331

  
332
  def _InstDict(self, instance, hvp=None, bep=None):
332
  def _InstDict(self, instance, hvp=None, bep=None, osp=None):
333 333
    """Convert the given instance to a dict.
334 334

  
335 335
    This is done via the instance's ToDict() method and additionally
......
341 341
    @param hvp: a dictionary with overridden hypervisor parameters
342 342
    @type bep: dict or None
343 343
    @param bep: a dictionary with overridden backend parameters
344
    @type osp: dict or None
345
    @param osp: a dictionary with overriden os parameters
344 346
    @rtype: dict
345 347
    @return: the instance dict, with the hvparams filled with the
346 348
        cluster defaults
......
354 356
    idict["beparams"] = cluster.FillBE(instance)
355 357
    if bep is not None:
356 358
      idict["beparams"].update(bep)
359
    idict["osparams"] = cluster.SimpleFillOS(instance.os, instance.osparams)
360
    if osp is not None:
361
      idict["osparams"].update(osp)
357 362
    for nic in idict["nics"]:
358 363
      nic['nicparams'] = objects.FillDict(
359 364
        cluster.nicparams[constants.PP_DEFAULT],

Also available in: Unified diff