return payload
-def OSCoreEnv(inst_os, debug=0):
+def OSCoreEnv(inst_os, os_params, debug=0):
"""Calculate the basic environment for an os script.
@type inst_os: L{objects.OS}
@param inst_os: operating system for which the environment is being built
+ @type os_params: dict
+ @param os_params: the OS parameters
@type debug: integer
@param debug: debug level (0 or 1, for OS Api 10)
@rtype: dict
variant = inst_os.supported_variants[0]
result['OS_VARIANT'] = variant
+ # OS params
+ for pname, pvalue in os_params.items():
+ result['OSP_%s' % pname.upper()] = pvalue
+
return result
cannot be found
"""
- result = OSCoreEnv(inst_os, debug)
+ result = OSCoreEnv(inst_os, instance.osparams, debug=debug)
result['INSTANCE_NAME'] = instance.name
result['INSTANCE_OS'] = instance.os
"hypervisor",
"hvparams",
"beparams",
+ "osparams",
"admin_up",
"nics",
"disks",
del self.hvparams[key]
except KeyError:
pass
+ if self.osparams is None:
+ self.osparams = {}
class OS(ConfigObject):
"hvparams",
"os_hvp",
"beparams",
+ "osparams",
"nicparams",
"candidate_pool_size",
"modify_etc_hosts",
if self.os_hvp is None:
self.os_hvp = {}
+ # osparams added before 2.2
+ if self.osparams is None:
+ self.osparams = {}
+
self.beparams = UpgradeGroupedParams(self.beparams,
constants.BEC_DEFAULTS)
migrate_default_bridge = not self.nicparams
"""
return FillDict(self.nicparams.get(constants.PP_DEFAULT, {}), nicparams)
+ def SimpleFillOS(self, os_name, os_params):
+ """Fill an instance's osparams dict with cluster defaults.
+
+ @type os_name: string
+ @param os_name: the OS name to use
+ @type os_params: dict
+ @param os_params: the dict to fill with default values
+ @rtype: dict
+ @return: a copy of the instance's osparams with missing keys filled from
+ the cluster defaults
+
+ """
+ name_only = os_name.split("+", 1)[0]
+ # base OS
+ result = self.osparams.get(name_only, {})
+ # OS with variant
+ result = FillDict(result, self.osparams.get(os_name, {}))
+ # specified params
+ return FillDict(result, os_params)
+
class BlockDevStatus(ConfigObject):
"""Config object representing the status of a block device."""
self._cfg = cfg
self.port = utils.GetDaemonPort(constants.NODED)
- def _InstDict(self, instance, hvp=None, bep=None):
+ def _InstDict(self, instance, hvp=None, bep=None, osp=None):
"""Convert the given instance to a dict.
This is done via the instance's ToDict() method and additionally
@param hvp: a dictionary with overridden hypervisor parameters
@type bep: dict or None
@param bep: a dictionary with overridden backend parameters
+ @type osp: dict or None
+ @param osp: a dictionary with overriden os parameters
@rtype: dict
@return: the instance dict, with the hvparams filled with the
cluster defaults
idict["beparams"] = cluster.FillBE(instance)
if bep is not None:
idict["beparams"].update(bep)
+ idict["osparams"] = cluster.SimpleFillOS(instance.os, instance.osparams)
+ if osp is not None:
+ idict["osparams"].update(osp)
for nic in idict["nics"]:
nic['nicparams'] = objects.FillDict(
cluster.nicparams[constants.PP_DEFAULT],