diff mbox

[5/5] KVM test: kvm_vm: Allow NIC MACs to be defined on config file

Message ID 1292864254-6782-5-git-send-email-lmr@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Lucas Meneghel Rodrigues Dec. 20, 2010, 4:57 p.m. UTC
None
diff mbox

Patch

diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py
index 416b827..b1aefb6 100755
--- a/client/tests/kvm/kvm_vm.py
+++ b/client/tests/kvm/kvm_vm.py
@@ -598,14 +598,22 @@  class VM:
                 self.uuid = f.read().strip()
                 f.close()
 
+
+
             # Generate or copy MAC addresses for all NICs
             num_nics = len(kvm_utils.get_sub_dict_names(params, "nics"))
             for vlan in range(num_nics):
-                mac = mac_source and mac_source.get_mac_address(vlan)
-                if mac:
+                nic_name = kvm_utils.get_sub_dict_names(params, "nics")[vlan]
+                nic_params = kvm_utils.get_sub_dict(params, nic_name)
+                if nic_params.get("nic_mac", None):
+                    mac = nic_params.get("nic_mac")
                     kvm_utils.set_mac_address(self.instance, vlan, mac)
                 else:
-                    kvm_utils.generate_mac_address(self.instance, vlan)
+                    mac = mac_source and mac_source.get_mac_address(vlan)
+                    if mac:
+                        kvm_utils.set_mac_address(self.instance, vlan, mac)
+                    else:
+                        kvm_utils.generate_mac_address(self.instance, vlan)
 
             # Assign a PCI assignable device
             self.pci_assignable = None