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 1/6] Fix deltacloud HTML UI attach volume form
Date Mon, 02 Jan 2012 12:03:10 GMT
Hi,

ACK.

Just one question/idea, not related to this patch.

Wouldn't be cleaner to rather than creating a 'special' operation to add 'update' operation
that will change the 'instance_id' in storage_volume resource?

I mean something like:

PUT /api/storage_volumes/vol1

Where the params will look like:

{ 'instance_id' => 'inst1' }

For me it sounds more 'natural' that we want to 'PUT' (literally) an instance
to this storage_volume. Or _even_ 'more' natural will be that we will 'PUT' the
storage_volume to instance. In that case the 'instances' collection will define:

collection :instances do
  operation :volumes, :method => :put, :member => true do
  end
end

Then client will do:

PUT /api/instances/inst1/volumes { 'storage_volume_id' => 'vol1' }

Then we somehow need to list the volumes in 'instance'. Just my 50c ;-)

 -- Michal

On Dec 23, 2011, at 5:31 PM, marios@redhat.com wrote:

> From: marios <marios@redhat.com>
> 
> 
> Signed-off-by: marios <marios@redhat.com>
> ---
> server/lib/deltacloud/server.rb             |   10 ++++++++++
> server/views/storage_volumes/show.html.haml |    2 +-
> 2 files changed, 11 insertions(+), 1 deletions(-)
> 
> diff --git a/server/lib/deltacloud/server.rb b/server/lib/deltacloud/server.rb
> index 88250a6..2fa81c7 100644
> --- a/server/lib/deltacloud/server.rb
> +++ b/server/lib/deltacloud/server.rb
> @@ -664,6 +664,16 @@ collection :storage_volumes do
>     end
>   end
> 
> +  operation :attach_instance, :method=>:get, :member=>true  do
> +    description "A form to attach a storage volume to an instance"
> +    control do
> +      @instances = driver.instances(credentials)
> +      respond_to do |format|
> +        format.html{ haml :"storage_volumes/attach"}
> +      end
> +    end
> +  end
> +
>   operation :attach, :method => :post, :member => true do
>     description "Attach storage volume to instance"
>     with_capability :attach_storage_volume
> diff --git a/server/views/storage_volumes/show.html.haml b/server/views/storage_volumes/show.html.haml
> index 585990e..aabdd85 100644
> --- a/server/views/storage_volumes/show.html.haml
> +++ b/server/views/storage_volumes/show.html.haml
> @@ -32,6 +32,6 @@
>           =link_to_action "Snapshot", api_url_for("storage_snapshots/new?volume_id=#{@storage_volume.id}"),
:get
>           - unless @storage_volume.instance_id
>             =link_to_action "Delete", destroy_storage_volume_url(@storage_volume.id),
:delete
> -            =link_to_action "Attach", api_url_for("storage_volumes/attach?id=#{@storage_volume.id}"),
:get
> +            =link_to_action "Attach", api_url_for("storage_volumes/#{@storage_volume.id}/attach_instance"),
:get

I think, you can also use:

attach_instance

>           - if @storage_volume.instance_id
>             =link_to_action "Detach", detach_storage_volume_url(@storage_volume.id),
:post
> -- 
> 1.7.6.4
> 

------------------------------------------------------
Michal Fojtik, mfojtik@redhat.com
Deltacloud API: http://deltacloud.org


Mime
View raw message