1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/hp/requests/lb/delete_load_balancer_node.rb

48 lines
1.3 KiB
Ruby
Raw Normal View History

2013-03-01 18:46:56 -05:00
module Fog
module HP
2013-03-05 11:25:30 -05:00
class LB
# Delete an existing load balancer node
#
# ==== Parameters
# * 'load_balancer_id'<~String> - UUId of load balancer for the node
# * 'node_id'<~String> - UUId of node to delete
#
2013-03-05 11:25:30 -05:00
class Real
2013-03-06 12:35:09 -05:00
def delete_load_balancer_node(load_balancer_id, node_id)
request(
:expects => 202,
2013-03-05 11:25:30 -05:00
:method => 'DELETE',
:path => "loadbalancers/#{load_balancer_id}/nodes/#{node_id}"
2013-03-05 11:25:30 -05:00
)
2013-03-01 18:46:56 -05:00
end
2013-03-05 11:25:30 -05:00
end
class Mock
2013-03-06 12:35:09 -05:00
def delete_load_balancer_node(load_balancer_id, node_id)
2013-03-06 18:35:05 -05:00
response = Excon::Response.new
if get_load_balancer(load_balancer_id)
if get_load_balancer_node(load_balancer_id, node_id)
2013-03-06 18:35:05 -05:00
response.status = 202
nodes = delete_node(load_balancer_id, node_id)
self.data[:lbs][load_balancer_id]['nodes'] = nodes
response
2013-03-06 18:35:05 -05:00
else
raise Fog::HP::LB::NotFound
end
else
raise Fog::HP::LB::NotFound
end
2013-03-01 18:46:56 -05:00
end
2013-03-06 18:35:05 -05:00
def delete_node(load_balancer_id, node_id)
nodes = list_load_balancer_nodes(load_balancer_id).body['nodes']
nodes.reject {|n| n['id'] == node_id}
2013-03-06 18:35:05 -05:00
end
2013-03-01 18:46:56 -05:00
end
end
end
end