1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[bluebox|blb] add_machine

This commit is contained in:
Josh Yotty 2013-02-28 18:24:11 -08:00
parent 1536a29b73
commit 17f6dc89f4
3 changed files with 47 additions and 0 deletions

View file

@ -30,6 +30,14 @@ module Fog
request :get_lb_backend
request :get_lb_backends
request :add_machine_to_application
request :add_machine_to_backend
request :remove_machine_from_backend
request :update_machine
class Mock
end

View file

@ -13,6 +13,11 @@ module Fog
attribute :description
attribute :created, :aliases => 'created_at'
def add_machine(lb_machine_id, options)
requires :id
service.add_machine_to_application(id, lb_machine_id, options)
end
def lb_services
Fog::Bluebox::BLB::LbServices.new({
:service => service,

View file

@ -0,0 +1,34 @@
module Fog
module Bluebox
class BLB
class Real
# Add machine to default lb_backend for each lb_service
# in the application.
#
# === Parameters
# * lb_application_id<~String> - ID of application
# * lb_machine_id<~String> - ID of machine
# * options<~Hash>:
# * port<~Integer> - port machine listens on; defaults to service listening port
# * maxconn<~Integer> - maximum number of connections server can be sent
# * backup<~Boolean> - only send traffic to machine if all others are down
#
def add_machine_to_application(lb_application_id, lb_machine_id, options = {})
# convert to CGI array args
body = Hash[options.map {|k,v| ["lb_options[#{k}]", v] }]
body['lb_machine'] = lb_machine_id
request(
:expects => 200,
:method => 'POST',
:path => "/api/lb_applications/add_machine/#{lb_application_id}.json",
:body => body.map {|k,v| "#{CGI.escape(k)}=#{CGI.escape(v.to_s)}"}.join('&')
)
end
end
class Mock
end
end
end
end