Revision 73e0328b lib/objects.py
b/lib/objects.py | ||
---|---|---|
961 | 961 |
|
962 | 962 |
return ret_dict |
963 | 963 |
|
964 |
def SimpleFillHV(self, hv_name, os_name, hvparams, skip_globals=False): |
|
965 |
"""Fill a given hvparams dict with cluster defaults. |
|
966 |
|
|
967 |
@type hv_name: string |
|
968 |
@param hv_name: the hypervisor to use |
|
969 |
@type os_name: string |
|
970 |
@param os_name: the OS to use for overriding the hypervisor defaults |
|
971 |
@type skip_globals: boolean |
|
972 |
@param skip_globals: if True, the global hypervisor parameters will |
|
973 |
not be filled |
|
974 |
@rtype: dict |
|
975 |
@return: a copy of the given hvparams with missing keys filled from |
|
976 |
the cluster defaults |
|
977 |
|
|
978 |
""" |
|
979 |
if skip_globals: |
|
980 |
skip_keys = constants.HVC_GLOBALS |
|
981 |
else: |
|
982 |
skip_keys = [] |
|
983 |
|
|
984 |
def_dict = self.GetHVDefaults(hv_name, os_name, skip_keys=skip_keys) |
|
985 |
return FillDict(def_dict, hvparams, skip_keys=skip_keys) |
|
964 | 986 |
|
965 | 987 |
def FillHV(self, instance, skip_globals=False): |
966 |
"""Fill an instance's hvparams dict. |
|
988 |
"""Fill an instance's hvparams dict with cluster defaults.
|
|
967 | 989 |
|
968 | 990 |
@type instance: L{objects.Instance} |
969 | 991 |
@param instance: the instance parameter to fill |
... | ... | |
975 | 997 |
the cluster defaults |
976 | 998 |
|
977 | 999 |
""" |
978 |
if skip_globals: |
|
979 |
skip_keys = constants.HVC_GLOBALS |
|
980 |
else: |
|
981 |
skip_keys = [] |
|
1000 |
return self.SimpleFillHV(instance.hypervisor, instance.os, |
|
1001 |
instance.hvparams, skip_globals) |
|
982 | 1002 |
|
983 |
def_dict = self.GetHVDefaults(instance.hypervisor, instance.os, |
|
984 |
skip_keys=skip_keys) |
|
985 |
return FillDict(def_dict, instance.hvparams, skip_keys=skip_keys) |
|
1003 |
def SimpleFillBE(self, beparams): |
|
1004 |
"""Fill a given beparams dict with cluster defaults. |
|
1005 |
|
|
1006 |
@type beparam: dict |
|
1007 |
@param beparam: the dict to fill |
|
1008 |
@rtype: dict |
|
1009 |
@return: a copy of the passed in beparams with missing keys filled |
|
1010 |
from the cluster defaults |
|
1011 |
|
|
1012 |
""" |
|
1013 |
return FillDict(self.beparams.get(constants.PP_DEFAULT, {}), beparams) |
|
986 | 1014 |
|
987 | 1015 |
def FillBE(self, instance): |
988 |
"""Fill an instance's beparams dict. |
|
1016 |
"""Fill an instance's beparams dict with cluster defaults.
|
|
989 | 1017 |
|
990 | 1018 |
@type instance: L{objects.Instance} |
991 | 1019 |
@param instance: the instance parameter to fill |
... | ... | |
994 | 1022 |
the cluster defaults |
995 | 1023 |
|
996 | 1024 |
""" |
997 |
return FillDict(self.beparams.get(constants.PP_DEFAULT, {}), |
|
998 |
instance.beparams) |
|
1025 |
return self.SimpleFillBE(instance.beparams) |
|
1026 |
|
|
1027 |
def SimpleFillNIC(self, nicparams): |
|
1028 |
"""Fill a given nicparams dict with cluster defaults. |
|
1029 |
|
|
1030 |
@type nicparam: dict |
|
1031 |
@param nicparam: the dict to fill |
|
1032 |
@rtype: dict |
|
1033 |
@return: a copy of the passed in nicparams with missing keys filled |
|
1034 |
from the cluster defaults |
|
1035 |
|
|
1036 |
""" |
|
1037 |
return FillDict(self.nicparams.get(constants.PP_DEFAULT, {}), nicparams) |
|
999 | 1038 |
|
1000 | 1039 |
|
1001 | 1040 |
class BlockDevStatus(ConfigObject): |
Also available in: Unified diff