deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject [2/2] git commit: Core: Fixed missing JSON attributes
Date Mon, 28 Jan 2013 17:48:03 GMT
Updated Branches:
  refs/heads/master 00244c1de -> a62a0d3d6


Core: Fixed missing JSON attributes


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

Branch: refs/heads/master
Commit: a62a0d3d6ec0d0411f3f516ef2297e154bd66ea6
Parents: 3dd359b
Author: Michal Fojtik <mfojtik@redhat.com>
Authored: Thu Jan 17 13:54:00 2013 +0100
Committer: Michal fojtik <mfojtik@redhat.com>
Committed: Mon Jan 28 18:47:40 2013 +0100

----------------------------------------------------------------------
 server/lib/deltacloud/models/instance.rb           |   11 +++++++++--
 .../collections/instances_collection_test.rb       |    4 +++-
 2 files changed, 12 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a62a0d3d/server/lib/deltacloud/models/instance.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/models/instance.rb b/server/lib/deltacloud/models/instance.rb
index af47204..6fe56c4 100644
--- a/server/lib/deltacloud/models/instance.rb
+++ b/server/lib/deltacloud/models/instance.rb
@@ -54,7 +54,7 @@ class Instance < BaseModel
           :method => context.instance_action_method(a)
         }
       },
-      :instance_profile => {
+      :hardware_profile => {
         :id => instance_profile.id,
         :href => context.hardware_profile_url(instance_profile.id),
         :rel => :hardware_profile,
@@ -63,13 +63,20 @@ 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 context.driver.respond_to? :run_on_instance
+      r[:actions] << { :href => "#{context.run_instance_url(self.id)};id=#{self.id}",
:rel => 'run', :method => 'post'}
+    end
+    if can_create_image?
+      r[:actions] << { :href => "#{context.create_image_url};instance_id=#{self.id}",
:rel => 'create_image', :method => 'post'}
+    end
+    r.merge!(:create_time => launch_time) if launch_time
     r.merge!(:create_image => create_image) if create_image
     r.merge!(:firewalls => firewalls.map { |f| { :id => f, :href => context.firewall_url(f),
:rel => :firewall }}) if firewalls
     if storage_volumes
       r.merge!(:storage_volumes => storage_volumes.map { |v| { :id => v.keys.first,
:href => context.storage_volume_url(v.keys.first), :rel => :storage_volume }})
     end
     if context.driver.class.has_feature?(:instances, :authentication_key)
+      r.merge!(:authentication_type => 'key' )
       r.merge!(:authentication => { :keyname => keyname }) if keyname
     end
     if context.driver.class.has_feature?(:instances, :authentication_password)

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a62a0d3d/server/tests/deltacloud/collections/instances_collection_test.rb
----------------------------------------------------------------------
diff --git a/server/tests/deltacloud/collections/instances_collection_test.rb b/server/tests/deltacloud/collections/instances_collection_test.rb
index 8db75e6..cb1be02 100644
--- a/server/tests/deltacloud/collections/instances_collection_test.rb
+++ b/server/tests/deltacloud/collections/instances_collection_test.rb
@@ -69,8 +69,10 @@ describe Deltacloud::Collections::Instances do
     json['instance'].wont_be_empty
     Instance.attributes.each do |attr|
       attr = attr.to_s.gsub(/_id$/,'') if attr.to_s =~ /_id$/
-      next if ['authn_error', 'firewalls', 'keyname', 'username', 'password'].include?(attr.to_s)
+      next if ['launch_time', 'authn_error', 'firewalls', 'keyname', 'username', 'password',
'instance_profile'].include?(attr.to_s)
       json['instance'].keys.must_include attr.to_s
+      json['instance'].keys.must_include 'create_image'
+      json['instance'].keys.must_include 'hardware_profile'
     end
   end
 end


Mime
View raw message