You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltacloud.apache.org by ma...@apache.org on 2013/06/28 11:06:37 UTC

[8/9] git commit: Modified 'stop_instance' method to check if instance root type is ebs or instance_store. If ebs -- stop instance otherwise destroy instance

Modified 'stop_instance' method to check if instance root type is ebs or instance_store. If ebs -- stop instance otherwise destroy instance


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

Branch: refs/heads/master
Commit: 1a26f6ac73cd6db3c1a5842190f8b9734422a71e
Parents: b75f0a4
Author: David Ellinger <de...@ltionline.com>
Authored: Tue Jun 4 15:48:47 2013 -0400
Committer: marios <ma...@redhat.com>
Committed: Fri Jun 28 12:05:50 2013 +0300

----------------------------------------------------------------------
 server/lib/deltacloud/drivers/ec2/ec2_driver.rb | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/1a26f6ac/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/ec2/ec2_driver.rb b/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
index 71539b3..81e5832 100644
--- a/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
+++ b/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
@@ -333,11 +333,18 @@ module Deltacloud
         def stop_instance(credentials, instance_id)
           ec2 = new_client(credentials)
           #TODO: If image root is ebs (or persistent) then stop instance otherwise need to run "destroy_instance"
-          if ec2.stop_instances([instance_id])
-            instance(credentials, :id => instance_id)
+          #ec2_instance = ec2.instances[:instance_id]
+          #if ec2_instance.root_device_type == "ebs"
+          ec2_inst = ec2.describe_instances([instance_id]).first
+          if ec2_inst[:root_device_type] == "ebs"
+            if ec2.stop_instances([instance_id])
+              instance(credentials, :id => instance_id)
+            else
+              raise Deltacloud::BackendError.new(500, "Instance", "Instance stop failed", "")
+            end
           else
-            raise Deltacloud::BackendError.new(500, "Instance", "Instance stop failed", "")
-          end
+            destroy_instance(credentials,instance_id)
+          end  
         end