Commit 7a99e061 by Heechul Kim

stretch support added.

parent 45fa329a
Showing with 29 additions and 0 deletions
# python script to generate xen or kvm MAC address.
#
import sys
import random
#
def randomMAC(hypervisor='kvm'):
l_first_three = []
if hypervisor == 'xen':
l_first_three = [0x00, 0x16, 0x3e]
elif hypervisor == 'kvm':
l_first_three = [0x52, 0x54, 0x00]
else: # unknown hypervisor
raise Exception("Unknown hypervisor. should be 'kvm' or 'xen'")
mac = l_first_three + [
random.randint(0x00, 0x7f),
random.randint(0x00, 0xff),
random.randint(0x00, 0xff) ]
print(':'.join(map(lambda x: "%02x" % x, mac)))
if __name__ == "__main__":
if len(sys.argv) == 2:
randomMAC(sys.argv[1])
else:
randomMAC()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment