You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltacloud.apache.org by ma...@redhat.com on 2011/11/25 13:07:49 UTC
[PATCH 1/2] Adds CIMI::VolumeImage to server.rb (index/show)
From: marios <ma...@redhat.com>
Signed-off-by: marios <ma...@redhat.com>
---
server/lib/cimi/server.rb | 28 ++++++++++++++++++++++++++++
1 files changed, 28 insertions(+), 0 deletions(-)
diff --git a/server/lib/cimi/server.rb b/server/lib/cimi/server.rb
index 2bd3a39..fdd7f17 100644
--- a/server/lib/cimi/server.rb
+++ b/server/lib/cimi/server.rb
@@ -255,4 +255,32 @@ global_collection :volumes do
end
end
+global_collection :volume_images do
+ description 'This entity represents an image that could be place on a pre-loaded volume.'
+
+ operation :index do
+ description "List all volumes images"
+ control do
+ volume_images = VolumeImage.all(self)
+ respond_to do |format|
+ format.xml { volume_images.to_xml_cimi_collection(self) }
+ format.json { volume_images.to_json_cimi_collection(self) }
+ end
+ end
+ end
+
+ operation :show do
+ description "Show a specific volume image"
+ param :id, :string, :required
+ control do
+ volume_image = VolumeImage.find(params[:id], self)
+ respond_to do |format|
+ format.xml { volume_image.to_xml }
+ format.json { volume_image.to_json }
+ end
+ end
+ end
+
+end
+
end
--
1.7.6.4
[PATCH 2/2] Adds find and convert methods to CIMI::VolumeImage
Posted by ma...@redhat.com.
From: marios <ma...@redhat.com>
Signed-off-by: marios <ma...@redhat.com>
---
server/lib/cimi/model/volume_image.rb | 25 +++++++++++++++++++++++++
1 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/server/lib/cimi/model/volume_image.rb b/server/lib/cimi/model/volume_image.rb
index ee35d16..0ebfb01 100644
--- a/server/lib/cimi/model/volume_image.rb
+++ b/server/lib/cimi/model/volume_image.rb
@@ -20,4 +20,29 @@ class CIMI::Model::VolumeImage < CIMI::Model::Base
array :operations do
scalar :rel, :href
end
+
+ def self.find(id, _self)
+ storage_snapshots = []
+ opts = ( id==:all ) ? {} : { :id=>id }
+ storage_snapshots = self.driver.storage_snapshots(_self.credentials, opts)
+ storage_snapshots.collect!{ |snapshot| from_storage_snapshot(snapshot, _self) }
+ return storage_snapshots.first unless storage_snapshots.length > 1
+ return storage_snapshots
+ end
+
+ def self.all(_self); find(:all, _self); end
+
+ private
+
+ def self.from_storage_snapshot(snapshot, _self)
+ self.new( {
+ :name => snapshot.id,
+ :description => snapshot.id,
+ :created => snapshot.created,
+ :uri => _self.volume_image_url(snapshot.id),
+ :image_location => {:href=>_self.volume_url(snapshot.storage_volume_id)},
+ :bootable => "false"
+ } )
+ end
+
end
--
1.7.6.4
Re: [PATCH 1/2] Adds CIMI::VolumeImage to server.rb (index/show)
Posted by "marios@redhat.com" <ma...@redhat.com>.
(were my patches really that bad? ;) )
try sending mail to: dev-unsubscribe@deltacloud.apache.org
(dev-help@deltacloud.apache.org will give you list of all commands)
marios
On 25/11/11 14:30, Ladislav Martincik wrote:
> Can someone help me sing off this mailing list? Could not find the way.
>
> Thank you,
>
> -- Ladislav
>
>
> On Friday, November 25, 2011 at 1:07 PM, marios@redhat.com wrote:
>
>> From: marios <marios@redhat.com (mailto:marios@redhat.com)>
>>
>>
>> Signed-off-by: marios <marios@redhat.com (mailto:marios@redhat.com)>
>> ---
>> server/lib/cimi/server.rb | 28 ++++++++++++++++++++++++++++
>> 1 files changed, 28 insertions(+), 0 deletions(-)
>>
>> diff --git a/server/lib/cimi/server.rb b/server/lib/cimi/server.rb
>> index 2bd3a39..fdd7f17 100644
>> --- a/server/lib/cimi/server.rb
>> +++ b/server/lib/cimi/server.rb
>> @@ -255,4 +255,32 @@ global_collection :volumes do
>> end
>> end
>>
>> +global_collection :volume_images do
>> + description 'This entity represents an image that could be place on a pre-loaded volume.'
>> +
>> + operation :index do
>> + description "List all volumes images"
>> + control do
>> + volume_images = VolumeImage.all(self)
>> + respond_to do |format|
>> + format.xml { volume_images.to_xml_cimi_collection(self) }
>> + format.json { volume_images.to_json_cimi_collection(self) }
>> + end
>> + end
>> + end
>> +
>> + operation :show do
>> + description "Show a specific volume image"
>> + param :id, :string, :required
>> + control do
>> + volume_image = VolumeImage.find(params[:id], self)
>> + respond_to do |format|
>> + format.xml { volume_image.to_xml }
>> + format.json { volume_image.to_json }
>> + end
>> + end
>> + end
>> +
>> +end
>> +
>> end
>> --
>> 1.7.6.4
>>
>>
>
>
>
Re: [PATCH 1/2] Adds CIMI::VolumeImage to server.rb
(index/show)
Posted by Ladislav Martincik <la...@gmail.com>.
Can someone help me sing off this mailing list? Could not find the way.
Thank you,
-- Ladislav
On Friday, November 25, 2011 at 1:07 PM, marios@redhat.com wrote:
> From: marios <marios@redhat.com (mailto:marios@redhat.com)>
>
>
> Signed-off-by: marios <marios@redhat.com (mailto:marios@redhat.com)>
> ---
> server/lib/cimi/server.rb | 28 ++++++++++++++++++++++++++++
> 1 files changed, 28 insertions(+), 0 deletions(-)
>
> diff --git a/server/lib/cimi/server.rb b/server/lib/cimi/server.rb
> index 2bd3a39..fdd7f17 100644
> --- a/server/lib/cimi/server.rb
> +++ b/server/lib/cimi/server.rb
> @@ -255,4 +255,32 @@ global_collection :volumes do
> end
> end
>
> +global_collection :volume_images do
> + description 'This entity represents an image that could be place on a pre-loaded volume.'
> +
> + operation :index do
> + description "List all volumes images"
> + control do
> + volume_images = VolumeImage.all(self)
> + respond_to do |format|
> + format.xml { volume_images.to_xml_cimi_collection(self) }
> + format.json { volume_images.to_json_cimi_collection(self) }
> + end
> + end
> + end
> +
> + operation :show do
> + description "Show a specific volume image"
> + param :id, :string, :required
> + control do
> + volume_image = VolumeImage.find(params[:id], self)
> + respond_to do |format|
> + format.xml { volume_image.to_xml }
> + format.json { volume_image.to_json }
> + end
> + end
> + end
> +
> +end
> +
> end
> --
> 1.7.6.4
>
>
Re: [PATCH 1/2] Adds CIMI::VolumeImage to server.rb (index/show)
Posted by "marios@redhat.com" <ma...@redhat.com>.
Please ignore these 2 patches, obsoleted by newer series "CIMI::Volume
creation" sent 25th November that includes and builds on thses
On 25/11/11 14:07, marios@redhat.com wrote:
> From: marios <ma...@redhat.com>
>
>
> Signed-off-by: marios <ma...@redhat.com>
> ---
> server/lib/cimi/server.rb | 28 ++++++++++++++++++++++++++++
> 1 files changed, 28 insertions(+), 0 deletions(-)
>
> diff --git a/server/lib/cimi/server.rb b/server/lib/cimi/server.rb
> index 2bd3a39..fdd7f17 100644
> --- a/server/lib/cimi/server.rb
> +++ b/server/lib/cimi/server.rb
> @@ -255,4 +255,32 @@ global_collection :volumes do
> end
> end
>
> +global_collection :volume_images do
> + description 'This entity represents an image that could be place on a pre-loaded volume.'
> +
> + operation :index do
> + description "List all volumes images"
> + control do
> + volume_images = VolumeImage.all(self)
> + respond_to do |format|
> + format.xml { volume_images.to_xml_cimi_collection(self) }
> + format.json { volume_images.to_json_cimi_collection(self) }
> + end
> + end
> + end
> +
> + operation :show do
> + description "Show a specific volume image"
> + param :id, :string, :required
> + control do
> + volume_image = VolumeImage.find(params[:id], self)
> + respond_to do |format|
> + format.xml { volume_image.to_xml }
> + format.json { volume_image.to_json }
> + end
> + end
> + end
> +
> +end
> +
> end