[PATCH] BZ 805224 limit action to be executable only every 2 minutes
Jan Provaznik
jprovazn at redhat.com
Mon Sep 10 12:48:35 UTC 2012
On 09/10/2012 02:43 PM, Jan Provaznik wrote:
> On 08/29/2012 11:19 AM, Tomáš Hrčka wrote:
>> ---
>> src/app/models/instance.rb | 7 ++++++-
>> src/config/locales/en.yml | 1 +
>> 2 files changed, 7 insertions(+), 1 deletion(-)
>>
>> diff --git a/src/app/models/instance.rb b/src/app/models/instance.rb
>> index fad0d03..0ec11bf 100644
>> --- a/src/app/models/instance.rb
>> +++ b/src/app/models/instance.rb
>> @@ -464,7 +464,12 @@ class Instance < ActiveRecord::Base
>> end
>>
>> def reboot(user)
>> - do_operation(user, 'reboot')
>> + if tasks.where("action = :action AND time_submitted > :time_ago",
>> + {:action => "reboot", :time_ago => 2.minutes.ago}).present?
>> + raise I18n.t("instances.errors.reboot_already_scheduled")
>> + else
>> + do_operation(user, 'reboot')
>> + end
>> end
>>
>> def forced_stop(user)
>> diff --git a/src/config/locales/en.yml b/src/config/locales/en.yml
>> index a089d31..e301b9c 100644
>> --- a/src/config/locales/en.yml
>> +++ b/src/config/locales/en.yml
>> @@ -530,6 +530,7 @@ en:
>> provider_account_quota_too_low: "%{match_provider_account}
>> quota limit too low to launch Deployable"
>> stop_invalid_action: "Stop is an invalid action."
>> reboot_invalid_action: "Reboot is an invalid action."
>> + reboot_already_scheduled: "reboot is already scheduled."
>> must_be_enabled: "%{account_name}: Provider must be enabled"
>> provider_not_available: "%{account_name}: Provider is not
>> available"
>> cannot_destroy: "Destroy cannot be performed on this instance."
>>
>
> ACK
This actually revealed another bug in instances controller:
when selecting multiple instances and clicking "reboot selected
instances", I get an exception that an error can't be converted to string.
You might fix it before push, since it's slightly related.
diff --git a/src/app/controllers/instances_controller.rb
b/src/app/controllers/instances_controller.rb
index 31d70a4..a39a919 100644
--- a/src/app/controllers/instances_controller.rb
+++ b/src/app/controllers/instances_controller.rb
@@ -193,7 +193,7 @@ class InstancesController < ApplicationController
instance.reboot(current_user)
notices << "#{instance.name}:
#{t('instances.flash.notice.reboot', :name => instance.name)}"
rescue Exception => err
- errors << "#{instance.name}: " + err
+ errors << "#{instance.name}: " + err.message
logger.error err.message
logger.error err.backtrace.join("\n ")
end
Jan
More information about the aeolus-devel
mailing list