Revision 17463d22
b/lib/cmdlib.py | ||
---|---|---|
2064 | 2064 |
else: |
2065 | 2065 |
self.new_hvparams[hv_name].update(hv_dict) |
2066 | 2066 |
|
2067 |
# os hypervisor parameters |
|
2068 |
self.new_os_hvp = objects.FillDict(cluster.os_hvp, {}) |
|
2069 |
if self.op.os_hvp: |
|
2070 |
if not isinstance(self.op.os_hvp, dict): |
|
2071 |
raise errors.OpPrereqError("Invalid 'os_hvp' parameter on input", |
|
2072 |
errors.ECODE_INVAL) |
|
2073 |
for os_name, hvs in self.op.os_hvp.items(): |
|
2074 |
if not isinstance(hvs, dict): |
|
2075 |
raise errors.OpPrereqError(("Invalid 'os_hvp' parameter on" |
|
2076 |
" input"), errors.ECODE_INVAL) |
|
2077 |
if os_name not in self.new_os_hvp: |
|
2078 |
self.new_os_hvp[os_name] = hvs |
|
2079 |
else: |
|
2080 |
for hv_name, hv_dict in hvs.items(): |
|
2081 |
if hv_name not in self.new_os_hvp[os_name]: |
|
2082 |
self.new_os_hvp[os_name][hv_name] = hv_dict |
|
2083 |
else: |
|
2084 |
self.new_os_hvp[os_name][hv_name].update(hv_dict) |
|
2085 |
|
|
2067 | 2086 |
if self.op.enabled_hypervisors is not None: |
2068 | 2087 |
self.hv_list = self.op.enabled_hypervisors |
2069 | 2088 |
if not self.hv_list: |
... | ... | |
2106 | 2125 |
" state, not changing") |
2107 | 2126 |
if self.op.hvparams: |
2108 | 2127 |
self.cluster.hvparams = self.new_hvparams |
2128 |
if self.op.os_hvp: |
|
2129 |
self.cluster.os_hvp = self.new_os_hvp |
|
2109 | 2130 |
if self.op.enabled_hypervisors is not None: |
2110 | 2131 |
self.cluster.enabled_hypervisors = self.op.enabled_hypervisors |
2111 | 2132 |
if self.op.beparams: |
... | ... | |
3336 | 3357 |
|
3337 | 3358 |
""" |
3338 | 3359 |
cluster = self.cfg.GetClusterInfo() |
3360 |
os_hvp = {} |
|
3361 |
|
|
3362 |
# Filter just for enabled hypervisors |
|
3363 |
for os_name, hv_dict in cluster.os_hvp.items(): |
|
3364 |
os_hvp[os_name] = {} |
|
3365 |
for hv_name, hv_params in hv_dict.items(): |
|
3366 |
if hv_name in cluster.enabled_hypervisors: |
|
3367 |
os_hvp[os_name][hv_name] = hv_params |
|
3368 |
|
|
3339 | 3369 |
result = { |
3340 | 3370 |
"software_version": constants.RELEASE_VERSION, |
3341 | 3371 |
"protocol_version": constants.PROTOCOL_VERSION, |
... | ... | |
3349 | 3379 |
"enabled_hypervisors": cluster.enabled_hypervisors, |
3350 | 3380 |
"hvparams": dict([(hypervisor_name, cluster.hvparams[hypervisor_name]) |
3351 | 3381 |
for hypervisor_name in cluster.enabled_hypervisors]), |
3382 |
"os_hvp": os_hvp, |
|
3352 | 3383 |
"beparams": cluster.beparams, |
3353 | 3384 |
"nicparams": cluster.nicparams, |
3354 | 3385 |
"candidate_pool_size": cluster.candidate_pool_size, |
b/lib/objects.py | ||
---|---|---|
858 | 858 |
"file_storage_dir", |
859 | 859 |
"enabled_hypervisors", |
860 | 860 |
"hvparams", |
861 |
"os_hvp", |
|
861 | 862 |
"beparams", |
862 | 863 |
"nicparams", |
863 | 864 |
"candidate_pool_size", |
... | ... | |
878 | 879 |
self.hvparams[hypervisor] = FillDict( |
879 | 880 |
constants.HVC_DEFAULTS[hypervisor], self.hvparams[hypervisor]) |
880 | 881 |
|
882 |
# TODO: Figure out if it's better to put this into OS than Cluster |
|
883 |
if self.os_hvp is None: |
|
884 |
self.os_hvp = {} |
|
885 |
|
|
881 | 886 |
self.beparams = UpgradeGroupedParams(self.beparams, |
882 | 887 |
constants.BEC_DEFAULTS) |
883 | 888 |
migrate_default_bridge = not self.nicparams |
... | ... | |
940 | 945 |
skip_keys = constants.HVC_GLOBALS |
941 | 946 |
else: |
942 | 947 |
skip_keys = [] |
943 |
return FillDict(self.hvparams.get(instance.hypervisor, {}), |
|
944 |
instance.hvparams, skip_keys=skip_keys) |
|
948 |
|
|
949 |
# We fill the list from least to most important override |
|
950 |
fill_stack = [ |
|
951 |
self.hvparams.get(instance.hypervisor, {}), |
|
952 |
self.os_hvp.get(instance.os, {}).get(instance.hypervisor, {}), |
|
953 |
instance.hvparams, |
|
954 |
] |
|
955 |
|
|
956 |
ret_dict = {} |
|
957 |
for o_dict in fill_stack: |
|
958 |
ret_dict = FillDict(ret_dict, o_dict, skip_keys=skip_keys) |
|
959 |
|
|
960 |
return ret_dict |
|
945 | 961 |
|
946 | 962 |
def FillBE(self, instance): |
947 | 963 |
"""Fill an instance's beparams dict. |
b/lib/opcodes.py | ||
---|---|---|
301 | 301 |
"vg_name", |
302 | 302 |
"enabled_hypervisors", |
303 | 303 |
"hvparams", |
304 |
"os_hvp", |
|
304 | 305 |
"beparams", |
305 | 306 |
"nicparams", |
306 | 307 |
"candidate_pool_size", |
b/scripts/gnt-cluster | ||
---|---|---|
527 | 527 |
op = opcodes.OpSetClusterParams(vg_name=vg_name, |
528 | 528 |
enabled_hypervisors=hvlist, |
529 | 529 |
hvparams=hvparams, |
530 |
os_hvp=None, |
|
530 | 531 |
beparams=beparams, |
531 | 532 |
nicparams=nicparams, |
532 | 533 |
candidate_pool_size=opts.candidate_pool_size) |
Also available in: Unified diff