Re: [PATCH] comparing MAC address is changed to case insensitive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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("<", "&lt;")
>      str = str.replace(">", "&gt;")
>      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

_______________________________________________
et-mgmt-tools mailing list
et-mgmt-tools@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/et-mgmt-tools

[Index of Archives]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux