From: Michal Fojtik <[email protected]>
Signed-off-by: Michal fojtik <[email protected]> --- server/lib/deltacloud/models/image.rb | 3 ++- server/lib/deltacloud/models/instance.rb | 6 ++++-- server/lib/deltacloud/models/realm.rb | 3 ++- server/lib/deltacloud/models/storage_volume.rb | 13 +++++++++---- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/server/lib/deltacloud/models/image.rb b/server/lib/deltacloud/models/image.rb index 11e5a22..19a309c 100644 --- a/server/lib/deltacloud/models/image.rb +++ b/server/lib/deltacloud/models/image.rb @@ -30,9 +30,10 @@ class Image < BaseModel :id => self.id, :name => name, :description => description, - :owner_id => owner_id, + :owner => owner_id, :architecture => architecture, :state => state, + :creation_time => creation_time, :hardware_profiles => hardware_profiles.map { |p| { :id => p.id, :href => context.hardware_profile_url(p.id), :rel => :hardware_profile } } diff --git a/server/lib/deltacloud/models/instance.rb b/server/lib/deltacloud/models/instance.rb index 87bbb1b..fcfe092 100644 --- a/server/lib/deltacloud/models/instance.rb +++ b/server/lib/deltacloud/models/instance.rb @@ -43,6 +43,7 @@ class Instance < BaseModel :id => self.id, :name => name, :state => state, + :owner => owner_id, :image => { :href => context.image_url(image_id), :id => image_id, :rel => :image }, :realm => { :href => context.realm_url(realm_id), :id => realm_id, :rel => :realm }, :actions => actions.compact.map { |a| @@ -52,7 +53,7 @@ class Instance < BaseModel :method => context.instance_action_method(a) } }, - :hardware_profile => { + :instance_profile => { :id => instance_profile.id, :href => context.hardware_profile_url(instance_profile.id), :rel => :hardware_profile, @@ -61,7 +62,8 @@ class Instance < BaseModel :public_addresses => public_addresses.map { |addr| addr.to_hash(context) }, :private_addresses => private_addresses.map { |addr| addr.to_hash(context) } } - r.merge!(:launch_time => launch_time) if !launch_time.nil? + r.merge!(:launch_time => launch_time) + r.merge!(:create_image => create_image) if create_image r.merge!(:firewalls => firewalls.map { |f| { :id => f.id, :href => context.firewall_url(f.id), :rel => :firewall }}) if firewalls if storage_volumes r.merge!(:storage_volumes => storage_volumes.map { |f| { :id => f.id, :href => context.storage_volume_url(f.id), :rel => :storage_volume }}) diff --git a/server/lib/deltacloud/models/realm.rb b/server/lib/deltacloud/models/realm.rb index 75bebed..dab6d01 100644 --- a/server/lib/deltacloud/models/realm.rb +++ b/server/lib/deltacloud/models/realm.rb @@ -25,7 +25,8 @@ class Realm < BaseModel { :id => self.id, :name => name, - :state => state + :state => state, + :limit => limit } end diff --git a/server/lib/deltacloud/models/storage_volume.rb b/server/lib/deltacloud/models/storage_volume.rb index 345df11..477f394 100644 --- a/server/lib/deltacloud/models/storage_volume.rb +++ b/server/lib/deltacloud/models/storage_volume.rb @@ -32,17 +32,22 @@ class StorageVolume < BaseModel r = { :id => self.id, :name => name, + :description => description, :state => state, :created => created, :realm => { :id => realm_id, :href => context.realm_url(realm_id), :rel => :realm }, :device => device, :kind => kind, + :capacity => capacity, } - r[:actions] = actions.map { |a| + r[:actions] = (actions || []).map { |a| { :href => context.send("#{a}_storage_volume", self.id), :rel => a } - } if actions - r[:instance] = { :id => instance_id, :href => context.instance_url(instance_id), :rel => :instance } if instance_id - r.delete_if { |k, v| v.nil? } + } + if instance_id + r[:instance] = { :id => instance_id, :href => context.instance_url(instance_id), :rel => :instance } + else + r[:instance] = {} + end r end -- 1.8.0.2
