Fix backup import in case NIC is inside a network
authorDimitris Aragiorgis <dimara@grnet.gr>
Thu, 13 Feb 2014 14:47:00 +0000 (16:47 +0200)
committerMichele Tartara <mtartara@google.com>
Thu, 20 Feb 2014 14:45:37 +0000 (15:45 +0100)
Network UUID is written in .ini file during backup export
but is not used by _ReadExportParams(). This patch fixes it.

Please note that in case a network is given, link and mode should
not be included in NIC options.

This fixes issue 716.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Signed-off-by: Michele Tartara <mtartara@google.com>
Reviewed-by: Michele Tartara <mtartara@google.com>

lib/cmdlib/instance.py

index 007f989..6064088 100644 (file)
@@ -757,9 +757,19 @@ class LUInstanceCreate(LogicalUnit):
       for idx in range(constants.MAX_NICS):
         if einfo.has_option(constants.INISECT_INS, "nic%d_mac" % idx):
           ndict = {}
-          for name in list(constants.NICS_PARAMETERS) + ["ip", "mac"]:
+          for name in [constants.INIC_IP, constants.INIC_MAC]:
             v = einfo.get(constants.INISECT_INS, "nic%d_%s" % (idx, name))
             ndict[name] = v
+          network = einfo.get(constants.INISECT_INS,
+                              "nic%d_%s" % (idx, constants.INIC_NETWORK))
+          # in case network is given link and mode are inherited
+          # from nodegroup's netparams and thus should not be passed here
+          if network:
+            ndict[constants.INIC_NETWORK] = network
+          else:
+            for name in list(constants.NICS_PARAMETERS):
+              v = einfo.get(constants.INISECT_INS, "nic%d_%s" % (idx, name))
+              ndict[name] = v
           nics.append(ndict)
         else:
           break