Commit 0de1e688 authored by Klaus Aehlig's avatar Klaus Aehlig

When assigning UUIDs to disks, do so recursively

Old versions of Ganeti (in particular, 2.5 and earlier) did not
have UUIDs assigned to objects. If we happen to find such an old
configuration, we assign UUIDs now, during the upgrade. However,
we must do this recursively, as disks might have children. Note
that before Ganeti 2.12 this didn't matter, as the UUIDs of the
children where never used or enforced. With the strict type checking
introduced by the switch to haskell, we have to care about those
little details.
Signed-off-by: default avatarKlaus Aehlig <aehlig@google.com>
Reviewed-by: default avatarHrvoje Ribicic <riba@google.com>
parent 074ef161
......@@ -241,6 +241,14 @@ def _ConvertNicNameToUuid(iobj, network2uuid):
nic["network"] = uuid
def AssignUuid(disk):
if not "uuid" in disk:
disk["uuid"] = utils.io.NewUUID()
if "children" in disk:
for d in disk["children"]:
AssignUuid(d)
def _ConvertDiskAndCheckMissingSpindles(iobj, instance):
missing_spindles = False
if "disks" not in iobj:
......@@ -265,8 +273,7 @@ def _ConvertDiskAndCheckMissingSpindles(iobj, instance):
if not "spindles" in dobj:
missing_spindles = True
if not "uuid" in dobj:
dobj["uuid"] = utils.io.NewUUID()
AssignUuid(dobj)
return missing_spindles
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment