[Libvirt-cim] [PATCH 1 of 2] [TEST] Adding AllocationUnits field to MemRASD and updating the call to MemRASD in the libraries where it is accessed

Dan Smith danms at us.ibm.com
Thu Jul 31 16:07:23 UTC 2008


DK> +    def __init__(self, megabytes, mallocunits, name):
DK>          self.ResourceType = RASD_TYPE_MEM
         
DK>          if megabytes != None:
DK>              self.VirtualQuantity = megabytes
DK> +
DK> +        if mallocunits != None:
DK> +            self.AllocationUnits = mallocunits

These should be parameters with default values.  The way you have it
now, the caller must specify something for each, and if they don't,
you create an invalid RASD.  For example:

  class_masd(None, None, "foo")

succeeds, but passes none of the required information in the RASD.  A
definition like this would be better:

  def __init__(self, name, megabytes=128, mallocunits="MegaBytes")

So that someone can call it in any of the following ways:

  masd_class("foo")
  masd_class("foo", 256)
  masd_class("foo", 131076, "KiloBytes")

Doing it this way will avoid the need to change every use of this
function in places that don't need to know about whatever new
parameter you add next time.

-- 
Dan Smith
IBM Linux Technology Center
Open Hypervisor Team
email: danms at us.ibm.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 188 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvirt-cim/attachments/20080731/1655378f/attachment.sig>


More information about the Libvirt-cim mailing list