Method: CloudLB::Balancer#create_node
- Defined in:
- lib/cloudlb/balancer.rb
#create_node(options = {}) ⇒ Object
Creates a brand new backend node and associates it with the current load balancer. Returns the new Node object.
Options include:
* :address - The IP address of the backend node *required*
* :port - The TCP port that the backend node listens on. *required*
* :condition - Can be "ENABLED" (default), "DISABLED", or "DRAINING"
* :weight - A weighting for the WEIGHTED_ balancing algorithms. Defaults to 1.
76 77 78 79 80 81 82 83 84 85 |
# File 'lib/cloudlb/balancer.rb', line 76 def create_node(={}) (raise CloudLB::Exception::MissingArgument, "Must provide a node IP address") if [:address].to_s.empty? (raise CloudLB::Exception::MissingArgument, "Must provide a node TCP port") if [:port].to_s.empty? [:condition] ||= "ENABLED" body = {:nodes => []}.to_json response = @connection.lbreq("POST", @lbmgmthost, "#{@lbmgmtpath}/loadbalancers/#{CloudLB.escape(@id.to_s)}/nodes",@lbmgmtport,@lbmgmtscheme,{},body) CloudLB::Exception.raise_exception(response) unless response.code.to_s.match(/^20.$/) body = JSON.parse(response.body)['nodes'][0] return get_node(body["id"]) end |