Revision 1bdcbbab lib/objects.py
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.""" |
Also available in: Unified diff