~ubuntu-branches/ubuntu/utopic/xen/utopic

« back to all changes in this revision

Viewing changes to tools/python/xen/util/mac.py

  • Committer: Bazaar Package Importer
  • Author(s): Bastian Blank
  • Date: 2010-05-06 15:47:38 UTC
  • mto: (1.3.1) (15.1.1 sid) (4.1.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20100506154738-agoz0rlafrh1fnq7
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
from string import join, split
 
3
 
 
4
def macToString(mac):
 
5
    return ':'.join(map(lambda x: "%02x" % x, mac))
 
6
 
 
7
def macFromString(str):
 
8
    mac = [ int(x, 16) for x in str.split(':') ]
 
9
    if len(mac) != 6:
 
10
        raise ValueError("invalid mac: %s" % str)
 
11
    return mac