[PATCH] added new attribute checked_at to instance and changed dbomatic to iterate instances using this attribute
Tomáš Hrčka
thrcka at redhat.com
Tue Sep 4 13:40:56 UTC 2012
---
src/db/migrate/20120904073451_add_checked_at_to_instance.rb | 9 +++++++++
src/dbomatic/dbomatic | 6 ++++--
2 files changed, 13 insertions(+), 2 deletions(-)
create mode 100644 src/db/migrate/20120904073451_add_checked_at_to_instance.rb
diff --git a/src/db/migrate/20120904073451_add_checked_at_to_instance.rb b/src/db/migrate/20120904073451_add_checked_at_to_instance.rb
new file mode 100644
index 0000000..29b218a
--- /dev/null
+++ b/src/db/migrate/20120904073451_add_checked_at_to_instance.rb
@@ -0,0 +1,9 @@
+class AddCheckedAtToInstance < ActiveRecord::Migration
+ def self.up
+ add_column :instances, :checked_at, :datetime, :null => false, :default => Time.now
+ end
+
+ def self.down
+ remove_column :instances, :checked_at
+ end
+end
diff --git a/src/dbomatic/dbomatic b/src/dbomatic/dbomatic
index 76fadf6..a8633a0 100755
--- a/src/dbomatic/dbomatic
+++ b/src/dbomatic/dbomatic
@@ -33,7 +33,7 @@ dbomatic_pid_dir = "/var/run/aeolus-conductor"
# $dbomatic_timeout is also our polling interval between cloud status checks
$dbomatic_timeout = 60
$realms_timeout = 300
-$deltacloud_timeout = 30
+$deltacloud_timeout = 50
optparse = OptionParser.new do |opts|
opts.banner = <<BANNER
@@ -189,10 +189,12 @@ end
def check_one_account(account)
connection = account.connect
- account.instances.each do |instance|
+ account.instances.order("checked_at ASC").each do |instance|
# optimization; right now we ignore instances that are in the STOPPED, NEW, or CREATE_FAILED states.
# when we get to stateful instances, this will need to change
unless [Instance::STATE_NEW, Instance::STATE_STOPPED, Instance::STATE_CREATE_FAILED].include?(instance.state)
+ instance.update_attribute(:checked_at,Time.now)
+
begin
api_instance = connection.instance(instance.external_key)
rescue Exception => e
--
1.7.11.4
More information about the aeolus-devel
mailing list