On Nov 21, 2012, at 10:35 AM, [email protected] wrote: ACK.
> From: marios <[email protected]> > > related to DTACLOUD-375 > > https://issues.apache.org/jira/browse/DTACLOUD-375 > > Signed-off-by: marios <[email protected]> > --- > server/lib/cimi/collections/volumes.rb | 2 +- > server/lib/cimi/helpers/cimi_helper.rb | 8 ++++++++ > server/lib/cimi/models/volume.rb | 4 ++-- > server/lib/cimi/models/volume_configuration.rb | 5 +++-- > 4 files changed, 14 insertions(+), 5 deletions(-) > > diff --git a/server/lib/cimi/collections/volumes.rb > b/server/lib/cimi/collections/volumes.rb > index 319390e..59fd69d 100644 > --- a/server/lib/cimi/collections/volumes.rb > +++ b/server/lib/cimi/collections/volumes.rb > @@ -46,7 +46,7 @@ module CIMI::Collections > end > end > > - operation :create do > + operation :create, :with_capability => :create_storage_volume do > description "Create a new Volume." > control do > content_type = (request.content_type.end_with?("json") ? :json : > :xml) > diff --git a/server/lib/cimi/helpers/cimi_helper.rb > b/server/lib/cimi/helpers/cimi_helper.rb > index c4d081e..99af08a 100644 > --- a/server/lib/cimi/helpers/cimi_helper.rb > +++ b/server/lib/cimi/helpers/cimi_helper.rb > @@ -42,6 +42,14 @@ module CIMI > end > end > > + def from_kibibyte(value, unit="GB") > + case unit > + when "GB" then ((value.to_i)/1024/1024).to_i > + when "MB" then ((value.to_i)/1024).to_i > + else nil > + end > + end > + > end > end > > diff --git a/server/lib/cimi/models/volume.rb > b/server/lib/cimi/models/volume.rb > index eca5cc1..c89835c 100644 > --- a/server/lib/cimi/models/volume.rb > +++ b/server/lib/cimi/models/volume.rb > @@ -84,7 +84,7 @@ class CIMI::Model::Volume < CIMI::Model::Base > > def self.create_volume(params, context) > volume_config = > CIMI::Model::VolumeConfiguration.find(params[:volume_config_id], context) > - opts = {:capacity=>volume_config.capacity[:quantity], > :snapshot_id=>params[:volume_image_id] } > + opts = {:capacity=>context.from_kibibyte(volume_config.capacity, "GB"), > :snapshot_id=>params[:volume_image_id] } > storage_volume = > context.driver.create_storage_volume(context.credentials, opts) > from_storage_volume(storage_volume, context) > end > @@ -94,7 +94,7 @@ class CIMI::Model::Volume < CIMI::Model::Base > :description => volume.id, > :created => Time.parse(volume.created).xmlschema, > :id => context.volume_url(volume.id), > - :capacity => context.to_kibibyte(volume.capacity, 'MB'), > + :capacity => context.to_kibibyte(volume.capacity, 'GB'), > :bootable => "false", #fixme ... will vary... ec2 doesn't > expose this > :snapshots => [], #fixme... > :type => 'http://schemas.dmtf.org/cimi/1/mapped', > diff --git a/server/lib/cimi/models/volume_configuration.rb > b/server/lib/cimi/models/volume_configuration.rb > index 7b7860d..383aac3 100644 > --- a/server/lib/cimi/models/volume_configuration.rb > +++ b/server/lib/cimi/models/volume_configuration.rb > @@ -45,12 +45,13 @@ class CIMI::Model::VolumeConfiguration < CIMI::Model::Base > private > > def self.create(size, context) > + size_kib = context.to_kibibyte(size, "GB") > self.new( { > :id => context.volume_configuration_url(size), > :name => "volume-#{size}", > - :description => "Volume configuration with #{size} > kilobytes", > + :description => "Volume configuration with #{size_kib} > kibibytes", > :created => Time.now.xmlschema, > - :capacity => context.to_kibibyte(size, "MB"), > + :capacity => size_kib, > :supports_snapshots => "true" > # FIXME :guest_interface => "NFS" > } ) > -- > 1.7.11.7 > Michal Fojtik http://deltacloud.org [email protected]
