[PATCH] BZ 805224 limit action to be executable only every 2 minutes
Jan Provaznik
jprovazn at redhat.com
Mon Sep 10 12:43:01 UTC 2012
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
More information about the aeolus-devel
mailing list