On 12/14/2011 03:17 PM, Tomas Hrcka wrote:
---
src/app/models/instance.rb | 11 ++++++++---
src/config/locales/en.yml | 1 +
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/src/app/models/instance.rb b/src/app/models/instance.rb
index d146cce..dacebbd 100644
--- a/src/app/models/instance.rb
+++ b/src/app/models/instance.rb
@@ -483,15 +483,20 @@ class Instance< ActiveRecord::Base
]
def destroy_on_provider
- if (provider_account.label != "ec2" or provider_account.label !=
"mock") and state != STATE_CREATE_FAILED
+ if (provider_account.provider.provider_type.deltacloud_driver != "ec2" or
+ provider_account.provider.provider_type.deltacloud_driver != "mock")
and state != STATE_CREATE_FAILED
+ retries = 0
begin
+ retries += 1
@task = self.queue_action(self.owner, 'destroy')
unless @task
- raise ActionError.new("destroy cannot be performed on this
instance.")
+ raise ActionError.new(t"instance.errors.cannot_destroy")
end
Taskomatic.destroy_instance(@task)
rescue Exception => e
- retry if self.tasks.last.action != 'destroy'
+ if self.tasks.last.action != 'destroy' or retries< 500
+ retry
+ end
end
end
end
diff --git a/src/config/locales/en.yml b/src/config/locales/en.yml
index 05feeaf..99bfba0 100644
--- a/src/config/locales/en.yml
+++ b/src/config/locales/en.yml
@@ -355,6 +355,7 @@ en:
stop_invalid: "stop is an invalid action."
stop_not_be_performed: "stop cannot be performed on this instance."
must_be_enabled: "%{account_name}: provider must be enabled"
+ cannot_destroy: "destroy cannot be performed on this instance."
headers:
vm_name: VM NAME
status: STATUS
Self ACK and pushed.