From 3f61fbeb0e8330d43718ac93cdcd12fe40274753 Mon Sep 17 00:00:00 2001 From: grossmj Date: Mon, 30 May 2016 11:52:08 -0600 Subject: [PATCH] Generate a MAC address using the project + node UUID. Ref #522. --- gns3server/modules/qemu/qemu_vm.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gns3server/modules/qemu/qemu_vm.py b/gns3server/modules/qemu/qemu_vm.py index 2006a285..d7d5bba1 100644 --- a/gns3server/modules/qemu/qemu_vm.py +++ b/gns3server/modules/qemu/qemu_vm.py @@ -28,7 +28,6 @@ import subprocess import shlex import asyncio import socket -import random import gns3server from gns3server.utils import parse_version @@ -494,9 +493,10 @@ class QemuVM(BaseVM): """ if not mac_address: - self._mac_address = "12:34:%02x:%02x:%02x:00" % (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)) + # use the node UUID to generate a random MAC address + self._mac_address = "00:%s:%s:%s:%s:00" % (self.project.id[-4:-2], self.project.id[-2:], self.id[-4:-2], self.id[-2:]) else: - self._mac_address = mac_address[:8] + ":%02x:%02x:00" % (random.randint(0, 255), random.randint(0, 255)) + self._mac_address = mac_address log.info('QEMU VM "{name}" [{id}]: MAC address changed to {mac_addr}'.format(name=self._name, id=self._id,