On Fri, May 21, 2010 at 03:46:17PM +0100, mtaylor@redhat.com wrote:
From: martyntaylor mtaylor@redhat.com
src/app/models/instance_observer.rb | 2 +- src/app/models/task_observer.rb | 2 +- src/app/util/taskomatic.rb | 16 +++++++++++----- src/config/environment.rb | 4 +++- 4 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/src/app/models/instance_observer.rb b/src/app/models/instance_observer.rb index 283991d..fa5b3d2 100644 --- a/src/app/models/instance_observer.rb +++ b/src/app/models/instance_observer.rb @@ -1,6 +1,6 @@ class InstanceObserver < ActiveRecord::Observer
- def after_save(an_instance)
- def before_save(an_instance) if an_instance.changed? change = an_instance.changes['state'] if change
diff --git a/src/app/models/task_observer.rb b/src/app/models/task_observer.rb index d1834c4..98252b0 100644 --- a/src/app/models/task_observer.rb +++ b/src/app/models/task_observer.rb @@ -2,7 +2,7 @@ class TaskObserver < ActiveRecord::Observer
END_STATES = [ Task::STATE_CANCELED, Task::STATE_FAILED, Task::STATE_FINISHED ]
- def after_save(a_task)
- def before_save(a_task) if a_task.changed? change = a_task.changes['state'] if change
diff --git a/src/app/util/taskomatic.rb b/src/app/util/taskomatic.rb index e66bb62..22328dc 100644 --- a/src/app/util/taskomatic.rb +++ b/src/app/util/taskomatic.rb @@ -45,8 +45,6 @@ class Taskomatic
def instance_create
- @task.time_started = Time.now
- begin client = @task.instance.cloud_account.connect realm = @task.instance.realm.external_key rescue nil
@@ -55,9 +53,13 @@ class Taskomatic unless @task.instance.image.provider_image? @task.instance.image = @task.instance.image.provider_images[0] end
unless @task.instance.hardware_profile.provider_hardware_profile? @task.instance.hardware_profile = @task.instance.hardware_profile.provider_hardware_profiles[0] end
@task.state = Task::STATE_PENDING
@task.save! dcloud_instance = client.create_instance(@task.instance.image.external_key, :flavor => @task.instance.hardware_profile.external_key, :realm => realm,
@@ -65,6 +67,11 @@ class Taskomatic if dcloud_instance.class == Net::HTTPInternalServerError @task.instance.state = Instance::STATE_CREATE_FAILED raise "Error creating dcloud instance, returned internal server error."
@task.state = TASK::STATE_FAILED
@task.failure_code = Task::FAILURE_PROVIDER_CONTACT_FAILED
else
@task.state = Task::STATE_RUNNING
@task.save! end @logger.info "Task instance create completed with key #{dcloud_instance.id} and state #{dcloud_instance.state}"
@@ -77,7 +84,7 @@ class Taskomatic else @task.state = Task::STATE_FINISHED end
- @task.time_ended = Time.now
- @task.save! end
@@ -153,5 +160,4 @@ class Taskomatic end end end -end
+end \ No newline at end of file diff --git a/src/config/environment.rb b/src/config/environment.rb index 141642b..1721126 100644 --- a/src/config/environment.rb +++ b/src/config/environment.rb @@ -40,13 +40,14 @@ Rails::Initializer.run do |config| # config.gem "bj" # config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net" # config.gem "aws-s3", :lib => "aws/s3"
- config.gem "gettext", :lib => "gettext_rails"
config.gem "gettext", :lib => "gettext_rails" config.gem "gettext", :lib => "gettext_activerecord" config.gem "authlogic" config.gem "deltacloud-client", :lib => "deltacloud" config.gem "haml" config.gem "will_paginate"
config.active_record.observers = :instance_observer, :task_observer # Only load the plugins named here, in the order given. By default, all plugins # in vendor/plugins are loaded in alphabetical order. # :all can be used as a placeholder for all plugins not explicitly named
@@ -75,4 +76,5 @@ Rails::Initializer.run do |config| # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}')] # config.i18n.default_locale = :de
end
1.6.6.1
deltacloud-devel mailing list deltacloud-devel@lists.fedorahosted.org https://fedorahosted.org/mailman/listinfo/deltacloud-devel
ACK on series 1-7, with replacement 7/7 as sent, once it's all rebased to apply to 'next' :)
Thanks! Steve