You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltacloud.apache.org by mf...@apache.org on 2012/10/02 14:31:28 UTC

git commit: EC2: Using EC2 frontend with RHEV-M - problem with actions (DTACLOUD-327)

Updated Branches:
  refs/heads/master 761904939 -> 8086f4149


EC2: Using EC2 frontend with RHEV-M - problem with actions (DTACLOUD-327)


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

Branch: refs/heads/master
Commit: 8086f41492b4e1163c6f90668a6d878700be7ec5
Parents: 7619049
Author: Oved Ourfali <oo...@redhat.com>
Authored: Tue Oct 2 14:24:00 2012 +0200
Committer: Michal fojtik <mf...@redhat.com>
Committed: Tue Oct 2 14:30:53 2012 +0200

----------------------------------------------------------------------
 server/lib/ec2/query_parser.rb |   19 +++++++++++++++++--
 1 files changed, 17 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/8086f414/server/lib/ec2/query_parser.rb
----------------------------------------------------------------------
diff --git a/server/lib/ec2/query_parser.rb b/server/lib/ec2/query_parser.rb
index 2098d24..fc2d5be 100644
--- a/server/lib/ec2/query_parser.rb
+++ b/server/lib/ec2/query_parser.rb
@@ -56,14 +56,29 @@ module Deltacloud::EC2
     def perform!(credentials, driver)
       @result = case deltacloud_method
         when :create_instance then driver.send(deltacloud_method, credentials, deltacloud_method_params.delete(:image_id), deltacloud_method_params)
-        when :stop_instance then driver.send(deltacloud_method, credentials, deltacloud_method_params.delete(:id))
-        when :start_instance then driver.send(deltacloud_method, credentials, deltacloud_method_params.delete(:id))
+        when :stop_instance then instance_action(driver, deltacloud_method, credentials, deltacloud_method_params.delete(:id))
+        when :start_instance then instance_action(driver, deltacloud_method, credentials, deltacloud_method_params.delete(:id))
         when :destroy_instance then driver.send(deltacloud_method, credentials, deltacloud_method_params.delete(:id))
         when :reboot_instance then driver.send(deltacloud_method, credentials, deltacloud_method_params.delete(:id))
         else driver.send(deltacloud_method, credentials, deltacloud_method_params)
       end
     end
 
+    # Some drivers, like RHEV-M does not return the instance object
+    # but just notify client that the action was executed successfully.
+    #
+    # If we not received an Instance object, then we need to do additional
+    # query.
+    #
+    def instance_action(driver, action, credentials, id)
+      instance = driver.send(action, credentials, id)
+      if instance.kind_of? Instance
+        instance
+      else
+        driver.instance(credentials, :id => id)
+      end
+    end
+
     def to_xml(context)
       ResultParser.parse(action, @result, context)
     end