deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "marios@redhat.com" <mandr...@redhat.com>
Subject Re: how does create_xxx_url work?
Date Mon, 20 May 2013 07:02:35 GMT
On 20/05/13 07:45, Koper, Dies wrote:
> Hi Michal, all
> 
> I've started on the implementation of system import/export, advertising
> the operations on the collections and resources.
> The export operation seems to work: I can expose the url in a system, it
> shows up when I retrieve the system, and when I do a POST on that url,
> my driver's export_system method is invoked.
> 
> https://github.com/dkoper/deltacloud-core/commit/e93def6de7b1a088d230b32
> 842a349059f12e88c
> 

had a quick look - some comments inline:

> I'm having problems with the import operation.
> I'm following the add operation as example.
> 

be careful with your namings+copy/paste - like
https://github.com/dkoper/deltacloud-core/commit/e93def6de7b1a088d230b32842a349059f12e88c#L6L-1
you are defining 'import' for class CIMI::Service::SystemTemplateExport

> The add operation seems to be processed in two locations:
> Base.rb:
>     def self.list(ctx)
> ...
>       params[:add_url] = create_url(ctx)
>       if model_class == CIMI::Model::System
>         params[:system] = id
>       end
>       model_class.list(id, entries,
> params).select_by(ctx.params['$select']).filter_by(ctx.params['$filter']
> )
> 
> with create_url:
>     def self.create_url(ctx)
>       cimi_create = "create_#{model_name}_url"
>       dcloud_create = ctx.deltacloud_create_method_for(model_name)
>       if(ctx.respond_to?(cimi_create) &&
>          ctx.driver.respond_to?(dcloud_create)) || provides?(model_name)
>         ctx.send(cimi_create)
>       end
>     end
> 
> Collections.rb:
> ...
>       params[:entries] = entries
>       params[:count] = params[:entries].size
>       if params[:add_url]
>         params[:operations] ||= []
>         params[:operations] << { :rel => "add", :href =>
> params.delete(:add_url) }
>       end
>       collection_class.new(params)
> ...
> 
> 
> So I have added similar code for import (see url above), but
> ctx.respond_to?(cimi_import) in my self.import_url returns nil for me.
> Should I be doing this differently? Or do I need to add other code
> elsewhere for this operation to work?

I can't see where 'cimi_import' is being defined in that commit.

More generally, are you sure you want/need to define new Service classes
for the import/export? Can't these just be added to the System and
SystemTemplate Service classes? There may well be a legitimate reason
but it's Monday morning here so please help me out ;) (edit: see below -
I think it does make sense, actually)

This is the reason you're getting the error below from the
require_relative on the Service class. The code in
lib/cimi/service/base.rb (which is where you're getting explosions) is
trying to determine the corresponding Model class - for
CIMI::Service::SystemTemplateImport for example as it says:

uninitialized constant CIMI::Model::SystemTemplateImport


because the code is doing something like:


 33       def model_class$
 34         CIMI::Model.const_get(name.split('::').last)$
 35       end$

So, either you define a CIMI::Model::SystemTemplateImport, but I'm not
sure yet if we need that. This is the same question as above, i.e.  "are
you sure you want/need to define new Service classes for the
import/export?". I can see how that would make sense though, in the same
way we have a 'MachineCreate' Model and 'MachineCreate' Service. So you
need to determine the attributes of the SystemImport model (like
'source' ?) and continue in that way (yes, I think I just convinced
myself that creating stand-alone SystemImport model makes sense... :) )


hope it helps, marios

> 
> ...
> I just noticed that I didn't require_relative the import and export
> classes in service.rb. When I add that, I get an error:
> 
> 18 cloud providers loaded.
> d:/sources/OSS/cloud/deltacloud-core/server/lib/cimi/service/base.rb:34:
> in `const_get': uninitialized constant CIMI::Model::SystemTemplateImport
> (NameError)
>         from
> d:/sources/OSS/cloud/deltacloud-core/server/lib/cimi/service/base.rb:34:
> in `model_class'
>         from
> d:/sources/OSS/cloud/deltacloud-core/server/lib/cimi/service/base.rb:47:
> in `inherited'
>         from
> d:/sources/OSS/cloud/deltacloud-core/server/lib/cimi/service/system_temp
> late_import.rb:16:in `<top (required)>'
> 
> What am I missing?
> 
> Thanks,
> Dies Koper
> 
> 
> 


Mime
View raw message