[et-mgmt-tools] [PATCH] comparing MAC address is changed to case insensitive

Richard W.M. Jones rjones at redhat.com
Mon Apr 21 09:40:24 UTC 2008


On Mon, Apr 21, 2008 at 05:02:30PM +0900, Hiroyuki Kaguchi wrote:
> diff -r 6462dfd3e606 -r 6ec83c2a5c36 virtinst/util.py
> --- a/virtinst/util.py	Tue Apr 08 15:35:49 2008 -0400
> +++ b/virtinst/util.py	Mon Apr 21 15:44:24 2008 +0900
> @@ -222,3 +222,22 @@
>      str = str.replace("<", "<")
>      str = str.replace(">", ">")
>      return str
> +
> +def compareMAC(p, q):
> +    """Compare two MAC addresses"""
> +    pa = p.split(":")
> +    qa = q.split(":")
> +
> +    if len(pa) != len(qa):
> +        if p > q:
> +            return 1
> +        else:
> +            return -1
> +
> +    for i in xrange(len(pa)):
> +        n = int(pa[i], 0x10) - int(qa[i], 0x10)
> +        if n > 0:
> +            return 1
> +        elif n < 0:
> +            return -1
> +    return 0

Looks good to me, although I don't have commit access so someone else
should also review this.

Rich.

-- 
Richard Jones, Emerging Technologies, Red Hat  http://et.redhat.com/~rjones
virt-p2v converts physical machines to virtual machines.  Boot with a
live CD or over the network (PXE) and turn machines into Xen guests.
http://et.redhat.com/~rjones/virt-p2v




More information about the et-mgmt-tools mailing list