Revision 4d33e134
b/tools/cfgupgrade | ||
---|---|---|
318 | 318 |
ChangeDiskNodeIndices(disk) |
319 | 319 |
|
320 | 320 |
|
321 |
def ChangeInstanceIndices(config_data, old_key_field, new_key_field): |
|
322 |
insts_by_old_key = {} |
|
323 |
insts_by_new_key = {} |
|
324 |
for (_, inst) in config_data["instances"].items(): |
|
325 |
insts_by_old_key[inst[old_key_field]] = inst |
|
326 |
insts_by_new_key[inst[new_key_field]] = inst |
|
327 |
|
|
328 |
config_data["instances"] = insts_by_new_key |
|
329 |
|
|
330 |
|
|
321 | 331 |
def UpgradeNodeIndices(config_data): |
322 | 332 |
ChangeNodeIndices(config_data, "name", "uuid") |
323 | 333 |
|
324 | 334 |
|
335 |
def UpgradeInstanceIndices(config_data): |
|
336 |
ChangeInstanceIndices(config_data, "name", "uuid") |
|
337 |
|
|
338 |
|
|
325 | 339 |
def UpgradeAll(config_data): |
326 | 340 |
config_data["version"] = constants.BuildVersion(TARGET_MAJOR, |
327 | 341 |
TARGET_MINOR, 0) |
... | ... | |
333 | 347 |
UpgradeGroups(config_data) |
334 | 348 |
UpgradeInstances(config_data) |
335 | 349 |
UpgradeNodeIndices(config_data) |
350 |
UpgradeInstanceIndices(config_data) |
|
336 | 351 |
|
337 | 352 |
|
338 | 353 |
def DowngradeDisks(disks, owner): |
... | ... | |
358 | 373 |
ChangeNodeIndices(config_data, "uuid", "name") |
359 | 374 |
|
360 | 375 |
|
376 |
def DowngradeInstanceIndices(config_data): |
|
377 |
ChangeInstanceIndices(config_data, "uuid", "name") |
|
378 |
|
|
379 |
|
|
361 | 380 |
def DowngradeAll(config_data): |
362 | 381 |
# Any code specific to a particular version should be labeled that way, so |
363 | 382 |
# it can be removed when updating to the next version. |
... | ... | |
365 | 384 |
DOWNGRADE_MINOR, 0) |
366 | 385 |
DowngradeInstances(config_data) |
367 | 386 |
DowngradeNodeIndices(config_data) |
387 |
DowngradeInstanceIndices(config_data) |
|
368 | 388 |
|
369 | 389 |
|
370 | 390 |
def main(): |
Also available in: Unified diff