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:36 UTC
[7/9] git commit: EC2 driver - modify instance actions depending on
transient root (ebs/root_store)
EC2 driver - modify instance actions depending on transient root (ebs/root_store)
related to https://github.com/deltacloud/deltacloud-core/pull/44
Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/6307f267
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/6307f267
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/6307f267
Branch: refs/heads/master
Commit: 6307f267e7dbc0dca2a2f972a341ce02eb8fb0f9
Parents: a426922
Author: marios <ma...@redhat.com>
Authored: Fri Jun 7 11:25:49 2013 +0300
Committer: marios <ma...@redhat.com>
Committed: Fri Jun 28 12:05:50 2013 +0300
----------------------------------------------------------------------
server/lib/deltacloud/drivers/base_driver.rb | 2 +-
server/lib/deltacloud/drivers/ec2/ec2_driver.rb | 29 ++++++++++++++++++--
2 files changed, 28 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/6307f267/server/lib/deltacloud/drivers/base_driver.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/base_driver.rb b/server/lib/deltacloud/drivers/base_driver.rb
index 8e1c6df..439f099 100644
--- a/server/lib/deltacloud/drivers/base_driver.rb
+++ b/server/lib/deltacloud/drivers/base_driver.rb
@@ -135,7 +135,7 @@ module Deltacloud
self.class.instance_state_machine
end
- def instance_actions_for(state)
+ def instance_actions_for(state, instance = nil)
actions = []
states = instance_state_machine.states()
current_state = states.find{|e| e.name == state.underscore.to_sym }
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/6307f267/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 da627c5..fdc282b 100644
--- a/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
+++ b/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
@@ -137,6 +137,31 @@ module Deltacloud
end
+ def instance_actions_for(state, instance = nil)
+ if instance
+ ebs = (instance[:root_device_type] == "ebs") ? true : false
+ end
+ actions = []
+ states = instance_state_machine.states()
+ current_state = states.find{|e| e.name == state.underscore.to_sym }
+ if ( current_state )
+ actions = current_state.transitions.collect{|e|e.action}
+ actions.reject!{|e| e.nil?}
+ end
+ if ebs
+ actions
+ else
+ # hax :( :stop becomes :destroy, :start is not possible
+ actions.inject([]) do |res, cur|
+ res << cur unless [:stop, :start].include? cur
+ if cur == :stop
+ res << :destroy
+ end
+ res
+ end
+ end
+ end
+
# We do not allow users to set the endpoint through environment
# variables. That that would work is an implementation detail.
ENV.delete("EC2_URL")
@@ -342,7 +367,7 @@ module Deltacloud
end
else
destroy_instance(credentials,instance_id)
- end
+ end
end
def destroy_instance(credentials, instance_id)
@@ -1075,7 +1100,7 @@ module Deltacloud
:state => convert_state(instance[:aws_state]),
:image_id => instance[:aws_image_id],
:owner_id => instance[:aws_owner],
- :actions => instance_actions_for(convert_state(instance[:aws_state])),
+ :actions => instance_actions_for(convert_state(instance[:aws_state]), instance),
:keyname => instance[:ssh_key_name],
:launch_time => instance[:aws_launch_time],
:instance_profile => InstanceProfile.new(instance[:aws_instance_type], inst_profile_opts),