aboutsummaryrefslogtreecommitdiffstats
path: root/tools/python/xen/util/mac.py
blob: 47dffd80d555709880902ce18cf630d369fad720 (plain)
1
2
3
4
5
6
7
8
9
10
11
from string import join, split

def macToString(mac):
    return ':'.join(map(lambda x: "%02x" % x, mac))

def macFromString(str):
    mac = [ int(x, 16) for x in str.split(':') ]
    if len(mac) != 6:
        raise ValueError("invalid mac: %s" % str)
    return mac