changes to replace MacAddress usage and remove ipaddress module altogether
This commit is contained in:
parent
4db7f845a5
commit
de493c810a
11 changed files with 43 additions and 83 deletions
|
@ -11,10 +11,13 @@ import json
|
|||
import logging
|
||||
import logging.config
|
||||
import os
|
||||
import random
|
||||
import shlex
|
||||
import sys
|
||||
from subprocess import PIPE, STDOUT, Popen
|
||||
|
||||
import netaddr
|
||||
|
||||
from core.errors import CoreCommandError
|
||||
|
||||
DEVNULL = open(os.devnull, "wb")
|
||||
|
@ -408,3 +411,17 @@ def threadpool(funcs, workers=10):
|
|||
except Exception as e:
|
||||
exceptions.append(e)
|
||||
return results, exceptions
|
||||
|
||||
|
||||
def random_mac():
|
||||
"""
|
||||
Create a random mac address using Xen OID 00:16:3E.
|
||||
|
||||
:return: random mac address
|
||||
:rtype: str
|
||||
"""
|
||||
value = random.randint(0, 0xFFFFFF)
|
||||
value |= 0x00163E << 24
|
||||
mac = netaddr.EUI(value)
|
||||
mac.dialect = netaddr.mac_unix
|
||||
return str(mac)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue