deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Lutterkort (JIRA)" <>
Subject [jira] [Commented] (DTACLOUD-525) Unable to perform operations on CIMI::Model
Date Thu, 04 Apr 2013 22:14:15 GMT


David Lutterkort commented on DTACLOUD-525:

Most of the Service.find methods actually return CIMI::Service objects (have a look at CIMI::Service::Machine)
since that's where the business logic (like performing actions) lives.

Usually, the find method gets some intermediate object from the driver, and converts them
into a Service object that wraps the underlying model. The system stuff is a little unusual
in that respect ... I don't care too much where the conversion to a service object happens
(System#find or the driver) though doing it in System#find seems more in line with the others.

> Unable to perform operations on CIMI::Model
> -------------------------------------------
>                 Key: DTACLOUD-525
>                 URL:
>             Project: DeltaCloud
>          Issue Type: Bug
>            Reporter: Michal Fojtik
>            Assignee: David Lutterkort
>            Priority: Blocker
> Today Dies found an interesting issue in CIMI::Model vs CIMI::Service:
> mock_driver_cimi_methods.rb:
>     def systems(credentials, opts={})
>       check_credentials(credentials)
>       if opts[:id].nil?
>         systems = @client.load_all_cimi(:system).map{|sys| CIMI::Model::System.from_json(sys)}
>       else
>         begin
>           systems = [CIMI::Model::System.from_json(@client.load_cimi(:system, opts[:id]))]
>         rescue Errno::ENOENT
>           return []
>         end
>       end
>{|sys| convert_urls(sys, opts[:env])}.flatten
>     end
> As you can see, this method will return CIMI::Model::System, which is fine if you want
to serialize it directly to JSON/XML. However, this is how we define 'stop' operation in Rabbit:
>       action :stop, :with_capability => :stop_system do
>         description "Stop specific system."
>         param :id,          :string,    :required
>         control do
>           system = System.find(params[:id], self)
>           action = Action.parse(self)
>           system.perform(action, self) do |operation|
>             no_content_with_status(202) if operation.success?
>             # Handle errors using operation.failure?
>           end
>         end
>       end
> In this case, "system.perform" will fail with:
> undefined method `perform' for #<CIMI::Model::System:0x00000003d154b8>
> The .perform() method is defined for CIMI::Service::System. Any clues how to fix this?

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see:

View raw message