[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 08:21:26 UTC 2012
---
src/db/migrate/20120904073451_add_checked_at_to_instance.rb | 9 +++++++++
src/dbomatic/dbomatic | 3 ++-
2 files changed, 11 insertions(+), 1 deletion(-)
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..b60f4e2
--- /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
+ end
+
+ def self.down
+ remove_column :instances, :checked_at
+ end
+end
diff --git a/src/dbomatic/dbomatic b/src/dbomatic/dbomatic
index 76fadf6..d375f40 100755
--- a/src/dbomatic/dbomatic
+++ b/src/dbomatic/dbomatic
@@ -189,7 +189,7 @@ 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)
@@ -201,6 +201,7 @@ def check_one_account(account)
end
if api_instance
+ instance.update_attribute(:checked_at,Time.now)
DBomaticLogger.instance.info("updating instance state for #{instance.name}: #{instance.external_key}")
instance.state = Taskomatic.dcloud_to_instance_state(api_instance.state)
--
1.7.11.4
More information about the aeolus-devel
mailing list