1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-14 12:29:02 +00:00

Generate a MAC address using the project + node UUID. Ref #522.

This commit is contained in:
grossmj 2016-05-30 11:52:08 -06:00
parent e65648398b
commit 3f61fbeb0e

View File

@ -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,