Revision 41044e04 tools/cfgupgrade
b/tools/cfgupgrade | ||
---|---|---|
104 | 104 |
|
105 | 105 |
def _FillIPolicySpecs(default_ipolicy, ipolicy): |
106 | 106 |
if "minmax" in ipolicy: |
107 |
for (key, spec) in ipolicy["minmax"].items(): |
|
108 |
for (par, val) in default_ipolicy["minmax"][key].items(): |
|
107 |
for (key, spec) in ipolicy["minmax"][0].items():
|
|
108 |
for (par, val) in default_ipolicy["minmax"][0][key].items():
|
|
109 | 109 |
if par not in spec: |
110 | 110 |
spec[par] = val |
111 | 111 |
|
... | ... | |
120 | 120 |
minmax[key] = ipolicy[key] |
121 | 121 |
del ipolicy[key] |
122 | 122 |
if minmax: |
123 |
ipolicy["minmax"] = minmax
|
|
123 |
ipolicy["minmax"] = [minmax]
|
|
124 | 124 |
if isgroup and "std" in ipolicy: |
125 | 125 |
del ipolicy["std"] |
126 | 126 |
_FillIPolicySpecs(default_ipolicy, ipolicy) |
... | ... | |
260 | 260 |
UpgradeInstances(config_data) |
261 | 261 |
|
262 | 262 |
|
263 |
def DowngradeIPolicy(ipolicy): |
|
263 |
def DowngradeIPolicy(ipolicy, owner):
|
|
264 | 264 |
# Downgrade IPolicy to 2.7 (stable) |
265 | 265 |
minmax_keys = ["min", "max"] |
266 | 266 |
specs_is_split = any((k in ipolicy) for k in minmax_keys) |
267 | 267 |
if not specs_is_split: |
268 | 268 |
if "minmax" in ipolicy: |
269 |
minmax = ipolicy["minmax"] |
|
269 |
if type(ipolicy["minmax"]) is not list: |
|
270 |
raise Error("Invalid minmax type in %s ipolicy: %s" % |
|
271 |
(owner, type(ipolicy["minmax"]))) |
|
272 |
if len(ipolicy["minmax"]) > 1: |
|
273 |
logging.warning("Discarding some limit specs values from %s policy", |
|
274 |
owner) |
|
275 |
minmax = ipolicy["minmax"][0] |
|
270 | 276 |
del ipolicy["minmax"] |
271 | 277 |
else: |
272 | 278 |
minmax = {} |
... | ... | |
281 | 287 |
for group in config_data["nodegroups"].values(): |
282 | 288 |
ipolicy = group.get("ipolicy", None) |
283 | 289 |
if ipolicy is not None: |
284 |
DowngradeIPolicy(ipolicy) |
|
290 |
DowngradeIPolicy(ipolicy, "group \"%s\"" % group.get("name"))
|
|
285 | 291 |
|
286 | 292 |
|
287 | 293 |
def DowngradeEnabledTemplates(cluster): |
... | ... | |
300 | 306 |
DowngradeEnabledTemplates(cluster) |
301 | 307 |
ipolicy = cluster.get("ipolicy", None) |
302 | 308 |
if ipolicy: |
303 |
DowngradeIPolicy(ipolicy) |
|
309 |
DowngradeIPolicy(ipolicy, "cluster")
|
|
304 | 310 |
|
305 | 311 |
|
306 | 312 |
def DowngradeAll(config_data): |
Also available in: Unified diff