Skip to content
Browse files

scaling request to cc

  • Loading branch information...
1 parent 9f741fd commit cf8d61a84fdeed40f90159a4ca897c7c01598cd7 @icpsha committed Apr 17, 2012
View
6 cloud_controller/app/models/app.rb
@@ -43,6 +43,12 @@ def self.process_scale_down_message(decoded_json)
end
end
+ def self.process_scale_up_message(decoded_json)
+ app_id = decoded_json[:droplet]
+ if app = App.find_by_id(app_id)
+ AppManager.new(app).scale_up_message_received(decoded_json)
+ end
+ end
def self.find_by_collaborator_and_id(user, app_id)
App.joins(:app_collaborations).where(:app_collaborations => {:user_id => user.id}, :apps => {:id => app_id}).first
end
View
6 cloud_controller/app/models/app_manager.rb
@@ -186,6 +186,12 @@ def once_app_is_staged
end
end
end
+
+ def scale_up_message_received(payload)
+ CloudController.logger.error("[CloudDirector] Received Scale Up request for app #{app.id} - #{app.name}")
+ indices = payload[:number_of_instances]
+ change_running_instances(indices)
+ end
def scale_down_message_received(payload)
CloudController.logger.error("[CloudDirector] Received Scale Down request for app #{app.id} - #{app.name}")
indices = payload[:number_of_instances]
View
11 cloud_controller/app/subscriptions/cloud_director_channel.rb
@@ -21,4 +21,15 @@
CloudController.logger.error(e)
end
end
+ NATS.subscribe('clouddirector.scaleup') do |msg|
+ begin
+ payload = Yajl::Parser.parse(msg, :symbolize_keys => true)
+ CloudController::UTILITY_FIBER_POOL.spawn do
+ App.process_scale_up_message(payload)
+ end
+ rescue => e
+ CloudController.logger.error("Exception processing cloud director request: '#{msg}'")
+ CloudController.logger.error(e)
+ end
+ end
end
View
BIN cloud_director/lib/cf.clouddirector-0.0.1-PTYP.jar
Binary file not shown.

0 comments on commit cf8d61a

Please sign in to comment.
Something went wrong with that request. Please try again.