(grnet) Hotplug: cfgupgrade for deprecated fields
authorDimitris Aragiorgis <dimara@grnet.gr>
Fri, 12 Jul 2013 12:34:07 +0000 (15:34 +0300)
committerDimitris Aragiorgis <dimara@grnet.gr>
Thu, 27 Mar 2014 07:58:59 +0000 (09:58 +0200)
Add cfgupgrade so that we remove any deprecated fields hotplug
implementation used in the past.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>

tools/cfgupgrade

index 6a8d5a4..0d12b3e 100755 (executable)
@@ -170,6 +170,11 @@ def UpgradeInstances(config_data):
           print("NIC with network name %s found."
                 " Substituting with uuid %s." % (name, uuid))
           nic["network"] = uuid
+      try:
+        del nic["idx"]
+        print("Deleting deprecated idx")
+      except KeyError:
+        pass
 
     if "disks" not in iobj:
       raise Error("Instance '%s' doesn't have a disks entry?!" % instance)
@@ -182,6 +187,18 @@ def UpgradeInstances(config_data):
                         " from '%s' to '%s'",
                         instance, idx, current, expected)
         dobj["iv_name"] = expected
+      try:
+        del dobj["idx"]
+        print("Deleting deprecated idx")
+      except KeyError:
+        pass
+
+    for attr in ("dev_idxs", "hotplug_info", "hotplugs", "pci_reservations"):
+      try:
+        del iobj[attr]
+        print("Deleting deprecated %s" % attr)
+      except KeyError:
+        pass
 
 
 def UpgradeRapiUsers():