Make generation of VM MAC addresses idempotent. 12/3712/2
authorTodd Malsbary <todd.malsbary@intel.com>
Mon, 21 Sep 2020 18:20:00 +0000 (11:20 -0700)
committerKuralamudhan Ramakrishnan <kuralamudhan.ramakrishnan@intel.com>
Sat, 7 Nov 2020 00:37:01 +0000 (00:37 +0000)
This ensures that the network XML, VM XML, and Ironic node definitions
remain in sync when the vm-setup playbooks is run multiple times.

Issue-ID: ICN-453
Signed-off-by: Todd Malsbary <todd.malsbary@intel.com>
Change-Id: I2f48a91b6a031bffb9a204fa8d93de326bc94b54

deploy/metal3-vm/vm-setup/library/generate_macs.py

index f304c6f..d4f09fb 100644 (file)
@@ -15,6 +15,7 @@
 # generate_baremetal_macs method ripped from
 # openstack/tripleo-incubator/scripts/configure-vm
 
+import marshal
 import math
 import random
 
@@ -50,6 +51,10 @@ def generate_baremetal_macs(nodes, networks):
         raise ValueError("The MAX num of MACS supported is %i  "
                          "(you specified %i)." % (MAX_NUM_MACS, count))
 
+    # See the random number generator with the input so that MAC
+    # generation is idempotent.
+    random.seed(marshal.dumps(nodes + networks))
+
     base_nums = [0x00,
                  random.randint(0x00, 0xff),
                  random.randint(0x00, 0xff),