[Libvirt-cim] [PATCH] [TEST] Add compare functions to CIM_Instance class

Richard Maciel rmaciel at linux.vnet.ibm.com
Fri Jan 30 21:39:02 UTC 2009


+1

Kaitlin Rupert wrote:
> # HG changeset patch
> # User Kaitlin Rupert <karupert at us.ibm.com>
> # Date 1233349527 28800
> # Node ID 0612bccec10e0221328decb12d435d0c611e732b
> # Parent  d86fcc1592a36d5a1c246009dbcb472e35cf87ba
> [TEST] Add compare functions to CIM_Instance class.
> 
> These functions allow you to compare a CIM_Instance class object in the
> following ways:
> 
>   rasd_inst == None
>   rasd_inst != None
> 
> The following aren't supported:  <, >, <=, >=.
> 
> Also, return a mof version of the CIM_Instance class when printing.   This
> allows the caller to print the return values from EnumInstances() (etc) without
> encountering an error.
> 
> Signed-off-by: Kaitlin Rupert <karupert at us.ibm.com>
> 
> diff -r d86fcc1592a3 -r 0612bccec10e suites/libvirt-cim/lib/XenKvmLib/enumclass.py
> --- a/suites/libvirt-cim/lib/XenKvmLib/enumclass.py	Fri Jan 30 13:02:15 2009 -0800
> +++ b/suites/libvirt-cim/lib/XenKvmLib/enumclass.py	Fri Jan 30 13:05:27 2009 -0800
> @@ -34,12 +34,47 @@
>      def __init__(self, inst):
>          self.inst = inst
> 
> +    def __eq__(self, other):
> +        if self is other:
> +            return True
> +        else:
> +            return False
> +
> +    def __ne__(self, other):
> +        if self is other:
> +            return False
> +        else:
> +            return True
> +
> +    def __coerce__(self, other):
> +        logger.error("__coerce__ function not implemented")
> +        return NotImplemented
> +
> +    def __cmp__(self, other):
> +        logger.error("__cmp__ function not implemented")
> +        return NotImplemented
> +
> +    def __gt__(self, other):
> +        logger.error("__gt__ function not implemented")
> +        return NotImplemented
> +
> +    def __lt__(self, other):
> +        logger.error("__gt__ function not implemented")
> +        return NotImplemented
> +
> +    def __ge__(self, other):
> +        logger.error("__gt__ function not implemented")
> +        return NotImplemented
> +
> +    def __le__(self, other):
> +        logger.error("__gt__ function not implemented")
> +        return NotImplemented
> 
>      def __getattr__(self, attr):
>          return self.inst[attr]
> 
>      def __str__(self):
> -        print self.inst.items()
> +        return self.inst.tomof()
> 
>  class CIM_CimtestClass(CIM_Instance):
>      def __init__(self, host, ref):
> 
> _______________________________________________
> Libvirt-cim mailing list
> Libvirt-cim at redhat.com
> https://www.redhat.com/mailman/listinfo/libvirt-cim


-- 
Richard Maciel, MSc
IBM Linux Technology Center
rmaciel at linux.vnet.ibm.com




More information about the Libvirt-cim mailing list