Merge pull request #44058 from mkoderer/issues/44056

Use correct mac prefix for kvm/qemu
This commit is contained in:
Mike Place 2017-10-17 14:45:56 -06:00 committed by GitHub
commit d15de697f8
2 changed files with 9 additions and 3 deletions

View file

@ -656,7 +656,7 @@ def _nic_profile(profile_name, hypervisor, **kwargs):
if key not in attributes or not attributes[key]:
attributes[key] = value
def _assign_mac(attributes):
def _assign_mac(attributes, hypervisor):
dmac = kwargs.get('dmac', None)
if dmac is not None:
log.debug('DMAC address is {0}'.format(dmac))
@ -666,11 +666,15 @@ def _nic_profile(profile_name, hypervisor, **kwargs):
msg = 'Malformed MAC address: {0}'.format(dmac)
raise CommandExecutionError(msg)
else:
attributes['mac'] = salt.utils.network.gen_mac()
if hypervisor in ['qemu', 'kvm']:
attributes['mac'] = salt.utils.network.gen_mac(
prefix='52:54:00')
else:
attributes['mac'] = salt.utils.network.gen_mac()
for interface in interfaces:
_normalize_net_types(interface)
_assign_mac(interface)
_assign_mac(interface, hypervisor)
if hypervisor in overlays:
_apply_default_overlay(interface)

View file

@ -428,6 +428,8 @@ class VirtTestCase(TestCase, LoaderModuleMockMixin):
controllers = root.findall('.//devices/controller')
# There should be no controller
self.assertTrue(len(controllers) == 0)
# kvm mac address shoud start with 52:54:00
self.assertTrue("mac address='52:54:00" in xml_data)
def test_mixed_dict_and_list_as_profile_objects(self):