deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject [2/4] git commit: Core: Fix .to_hash method in some models to include more informations
Date Thu, 13 Dec 2012 11:46:14 GMT
Core: Fix .to_hash method in some models to include more informations


Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/c31220fb
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/c31220fb
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/c31220fb

Branch: refs/heads/master
Commit: c31220fb097f8276cb921e9209985ad69bb05eab
Parents: 4141ee0
Author: Michal Fojtik <mfojtik@redhat.com>
Authored: Wed Dec 12 10:28:34 2012 +0100
Committer: Michal fojtik <mfojtik@redhat.com>
Committed: Thu Dec 13 12:45:53 2012 +0100

----------------------------------------------------------------------
 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(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/c31220fb/server/lib/deltacloud/models/image.rb
----------------------------------------------------------------------
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
}
       }

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/c31220fb/server/lib/deltacloud/models/instance.rb
----------------------------------------------------------------------
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 }})

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/c31220fb/server/lib/deltacloud/models/realm.rb
----------------------------------------------------------------------
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
 

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/c31220fb/server/lib/deltacloud/models/storage_volume.rb
----------------------------------------------------------------------
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
 


Mime
View raw message