Commit 5275a77f authored by Thomas Thrainer's avatar Thomas Thrainer
Browse files

Remove physical_id field from disks during upgrade



The physical_id field is no longer supported in disk objects, so remove
it during upgrades.
Signed-off-by: default avatarThomas Thrainer <thomasth@google.com>
Reviewed-by: default avatarJose A. Lopes <jabolopes@google.com>
parent fd424c8a
......@@ -392,6 +392,12 @@ class TestCfgupgrade(unittest.TestCase):
_RunUpgrade(self.tmpdir, False, True, downgrade=True)
oldconf = self._LoadTestDataConfig(oldconfname)
newconf = self._LoadConfig()
# downgrade from 2.10 to 2.9 does not add physical_id to disks, which is ok
for inst in oldconf["instances"].values():
for disk in inst["disks"]:
del disk["physical_id"]
self.assertEqual(oldconf, newconf)
def testDowngradeFullConfigBackwardFrom_2_7(self):
......
......@@ -173,6 +173,14 @@ def GetExclusiveStorageValue(config_data):
return ret
def RemovePhysicalId(disk):
if "children" in disk:
for d in disk["children"]:
RemovePhysicalId(d)
if "physical_id" in disk:
del disk["physical_id"]
def UpgradeInstances(config_data):
network2uuid = dict((n["name"], n["uuid"])
for n in config_data["networks"].values())
......@@ -194,6 +202,8 @@ def UpgradeInstances(config_data):
raise Error("Instance '%s' doesn't have a disks entry?!" % instance)
disks = iobj["disks"]
for idx, dobj in enumerate(disks):
RemovePhysicalId(dobj)
expected = "disk/%s" % idx
current = dobj.get("iv_name", "")
if current != expected:
......
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