933 |
933 |
obj.tcpudp_port_pool = set(obj.tcpudp_port_pool)
|
934 |
934 |
return obj
|
935 |
935 |
|
|
936 |
def GetHVDefaults(self, hypervisor, os_name=None, skip_keys=None):
|
|
937 |
"""Get the default hypervisor parameters for the cluster.
|
|
938 |
|
|
939 |
@param hypervisor: the hypervisor name
|
|
940 |
@param os_name: if specified, we'll also update the defaults for this OS
|
|
941 |
@param skip_keys: if passed, list of keys not to use
|
|
942 |
@return: the defaults dict
|
|
943 |
|
|
944 |
"""
|
|
945 |
if skip_keys is None:
|
|
946 |
skip_keys = []
|
|
947 |
|
|
948 |
fill_stack = [self.hvparams.get(hypervisor, {})]
|
|
949 |
if os_name is not None:
|
|
950 |
os_hvp = self.os_hvp.get(os_name, {}).get(hypervisor, {})
|
|
951 |
fill_stack.append(os_hvp)
|
|
952 |
|
|
953 |
ret_dict = {}
|
|
954 |
for o_dict in fill_stack:
|
|
955 |
ret_dict = FillDict(ret_dict, o_dict, skip_keys=skip_keys)
|
|
956 |
|
|
957 |
return ret_dict
|
|
958 |
|
|
959 |
|
936 |
960 |
def FillHV(self, instance, skip_globals=False):
|
937 |
961 |
"""Fill an instance's hvparams dict.
|
938 |
962 |
|
... | ... | |
951 |
975 |
else:
|
952 |
976 |
skip_keys = []
|
953 |
977 |
|
954 |
|
# We fill the list from least to most important override
|
955 |
|
fill_stack = [
|
956 |
|
self.hvparams.get(instance.hypervisor, {}),
|
957 |
|
self.os_hvp.get(instance.os, {}).get(instance.hypervisor, {}),
|
958 |
|
instance.hvparams,
|
959 |
|
]
|
960 |
|
|
961 |
|
ret_dict = {}
|
962 |
|
for o_dict in fill_stack:
|
963 |
|
ret_dict = FillDict(ret_dict, o_dict, skip_keys=skip_keys)
|
964 |
|
|
965 |
|
return ret_dict
|
|
978 |
def_dict = self.GetHVDefaults(instance.hypervisor, instance.os,
|
|
979 |
skip_keys=skip_keys)
|
|
980 |
return FillDict(def_dict, instance.hvparams, skip_keys=skip_keys)
|
966 |
981 |
|
967 |
982 |
def FillBE(self, instance):
|
968 |
983 |
"""Fill an instance's beparams dict.
|