deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Lutterkort <lut...@redhat.com>
Subject Re: CIMI::Models split to CIMI::Services (rev 2) WIP
Date Tue, 05 Mar 2013 01:35:51 GMT
On Fri, 2013-03-01 at 17:25 -0800, David Lutterkort wrote:
> On Fri, 2013-03-01 at 14:40 +0100, Michal Fojtik wrote:
> > - ResourceMetada are now broken and need to be fixed.
> >   (an informative warning included ;-)
> 
> I added one more patch to your series and rerecorded as
> http://tracker.deltacloud.org/set/364 

I noticed a bunch of minor issues, and one bigger one today: if you look
at VolumeCreate#create now:

        def create(context)
            if volume_template.href?
              template = volume_template.find(context)
            else
              template = CIMI::Service::VolumeTemplate.from_xml(volume_template.to_xml)
            end
        
            volume_image = template.volume_image.href? ?
              template.volume_image.find(context) : template.volume_image
        
            volume_config = template.volume_config.href? ?
              template.volume_config.find(context) : template.volume_config
        
            ...
        end

things blow up horribly because volume_template.find(context) winds up
calling CIMI::Model::VolumeTemplate::find - which doesn't exist anymore.

To address that, I want to add some magic to CIMI::Service::Base; I just
haven't made up my mind what that magic should be exactly. Option (1)
would be to wrap each model object in a service object as it is returned
from Service::Base#[] .. but that seems like overkill. Option (2) is to
only do something special for Ref's, but still return CIMI::Model
objects from accessors. Ideally, that something could also help us get
rid of the boilerplate above, so that you could just write

        template = volume_template.unref(context)

and have it (a) look up the volume_template if href is set and (b) set
attributes that were directly defined. That would have the advantage
that we'd do the right thing where requests reference an existing entity
and then override some of its attributes.

Clearly, allowing to write volume_template.unref would require
monkeypatching the CIMI::Model::VolumeTemplateRef class - and I am still
hoping to come up with something that would avoid that.

I'll look more into this business tomorrow.

David



Mime
View raw message