From bc89efc373fac7c689da9a8fc0c247cc41ddff36 Mon Sep 17 00:00:00 2001 From: Guido Trotter <ultrotter@google.com> Date: Mon, 20 Oct 2008 13:44:19 +0000 Subject: [PATCH] LUCreateInstance: reuse mac address on import When importing an instance with the same name as the exported one if the mac address is "auto" we try to reuse the previous mac address. One can still force generation of a new one with mac="generate". Forward-port-of: r1887, Reviewed-by: iustinp Reviewed-by: imsnah --- lib/cmdlib.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/cmdlib.py b/lib/cmdlib.py index c7370c760..5d5914500 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -3491,6 +3491,14 @@ class LUCreateInstance(LogicalUnit): 'disk0_dump')) self.src_image = diskimage + if self.op.mac == constants.VALUE_AUTO: + old_name = export_info.get(constants.INISECT_INS, 'name') + if self.op.instance_name == old_name: + # FIXME: adjust every nic, when we'll be able to create instances + # with more than one + if int(export_info.get(constants.INISECT_INS, 'nic_count')) >= 1: + self.op.mac = export_info.get(constants.INISECT_INS, 'nic_0_mac') + # ip ping checks (we use the same ip that was resolved in ExpandNames) if self.op.start and not self.op.ip_check: -- GitLab