(old_mac)
return new_mac
Generates a random MAC address.
        Keeps the same vender (first 6 chars) of the old MAC address (old_mac).
        Returns string in format old_mac[0:9] + :XX:XX:XX where X is random hex
Generates a random MAC address.
        Keeps the same vender (first 6 chars) of the old MAC address (old_mac).
        Returns string in format old_mac[0:9] + :XX:XX:XX where X is random hex
Generates a random MAC address . Keeps the same vender ( first 6 chars ) of the old MAC address ( old_mac ) . Returns string in format old_mac [ 0 : 9 ] + : XX : XX : XX where X is random hex
def generate_random_mac(old_mac):
    """
        Generates a random MAC address.
        Keeps the same vender (first 6 chars) of the old MAC address (old_mac).
        Returns string in format old_mac[0:9] + :XX:XX:XX where X is random hex
    """
    random.seed()
    new_mac = old_mac[:8].lower().replace('-', ':')
    for i in xrange(0, 6):
        if i % 2 == 0: new_mac += ':'
        new_mac += '0123456789abcdef'[random.randint(0,15)]
    
    # Prevent generating the same MAC address via recursion.
    if new_mac == old_mac:
        new_mac = generate_random_mac(old_mac)
    return new_mac
def generate_random_mac ( old_mac ) : random . seed ( ) new_mac = old_mac [ : 8 ] . lower ( ) . replace ( '-' , ':' ) for i in xrange ( 0 , 6 ) : if i % 2 == 0 : new_mac += ':' new_mac += '0123456789abcdef' [ random . randint ( 0 , 15 ) ] # Prevent generating the same MAC address via recursion. if new_mac == old_mac : new_mac = generate_random_mac ( old_mac ) return new_mac