On 05/21/2013 01:19 PM, Koper, Dies wrote:
Hi Marios, Michal,

I've updated my code with Marios' feedback.

https://github.com/dkoper/deltacloud-core/commit/38b09c16609219b21bb83db
7f4384fe016593d7e

I'm much closer now, export is working as expected (advertised properly,
parameters are passed into the driver method correctly).
I'm still having two issues with import:

A POST to /cimi/systems/import returns "Sinatra doesn't know this
ditty.".

Yeah, this is one of the Sinatra-Rabbit design thing. If you have collection of resources and you define an operation, that operation must always be performed on 'resource', so in other words it must have the ':id' in the route.

One workaround for this is to use the 'pure' Sinatra routes:

post '/cimi/systems/import' do
  # place the import code here...
end

This should work. Other option is to hack Rabbit to allow this kind of operations...

  -- Michal

A POST to /cimi/systems/UZXC0GRT-ZG8ZJCJ07/import (which is incorrect as
import is on systems, not a particular system) is accepted and leads to
my driver's import_system method being invoked.

Also, the advertised url is incorrect:

<operation rel="http://schemas.dmtf.org/cimi/1/action/import";
href="http://localhost:3001/cimi/systems/:id/import"; />

Note the ':id' in the href.

I assume the two are related.
I tried to create the import Sinatra route similar to the show action.
What am I missing?

https://github.com/dkoper/deltacloud-core/commit/38b09c16609219b21bb83db
7f4384fe016593d7e#L1R108

Cheers,
Dies Koper


-----Original Message-----
From: mar...@redhat.com [mailto:mandr...@redhat.com]
Sent: Monday, 20 May 2013 5:05 PM
To: dev@deltacloud.apache.org
Cc: Koper, Dies
Subject: Re: how does create_xxx_url work?

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/e93def6de7b1a088d23
0b32
842a349059f12e88c

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

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['$filt
er']
)

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 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

OH, and to answer $TITLE, see
server/lib/deltacloud/helpers/rabbit_helper.rb I *think* (i.e. I don't
think we have similar code defined for CIMI, it just re-uses this
deltacloud helper)









--

Michal Fojtik <mfoj...@redhat.com>
Deltacloud API, CloudForms

Reply via email to