deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michal Fojtik <mfoj...@redhat.com>
Subject Re: [PATCH] DTACLOUD-402 Add operations for pseudo collections
Date Fri, 11 Jan 2013 10:44:55 GMT
On 01/10, jvlcek@redhat.com wrote:

ACK.

One minor coding suggestion inline.

  -- Michal

> From: Joe VLcek <jvlcek@redhat.com>
> 
> ---
>  server/lib/cimi/helpers/database_helper.rb | 8 ++++++++
>  server/lib/cimi/models/collection.rb       | 4 +++-
>  2 files changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/server/lib/cimi/helpers/database_helper.rb b/server/lib/cimi/helpers/database_helper.rb
> index b581c7b..22d20ac 100644
> --- a/server/lib/cimi/helpers/database_helper.rb
> +++ b/server/lib/cimi/helpers/database_helper.rb
> @@ -6,10 +6,18 @@ module Deltacloud
>      module Database
>        include Deltacloud::Helpers::Drivers
>  
> +      DATABASE_COLLECTIONS = [ "machine_template", "address_template",
> +        "volume_configuration", "volume_template" ]
> +
>        def test_environment?
>          Deltacloud.test_environment?
>        end
>  
> +     def provides?(entity)
> +       return true if DATABASE_COLLECTIONS.include? entity
> +       return false

The 'return' is not necessary here:

def provides?(entity)
  DATABASE_COLLECTIONS.include? entity
end

> +     end
> +
>        def load_attributes_for(model)
>          return {} if test_environment?
>          entity = get_entity(model)
> diff --git a/server/lib/cimi/models/collection.rb b/server/lib/cimi/models/collection.rb
> index 1836449..0f2a89e 100644
> --- a/server/lib/cimi/models/collection.rb
> +++ b/server/lib/cimi/models/collection.rb
> @@ -122,7 +122,9 @@ module CIMI::Model
>          cimi_entity = collection_class.entry_name.to_s.singularize
>          cimi_create = "create_#{cimi_entity}_url"
>          dcloud_create = context.deltacloud_create_method_for(cimi_entity)
> -        if context.respond_to?(cimi_create) && context.driver.respond_to?(dcloud_create)
> +        if(context.respond_to?(cimi_create) &&
> +           context.driver.respond_to?(dcloud_create)) ||
> +             provides?(cimi_entity)
>            url = context.send(cimi_create)
>            ops << { :rel => "add", :href => url }
>          end
> -- 
> 1.7.11.7
> 

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

Mime
View raw message