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

[stormondemand|compute] Add all LoadBalancer related APIs

This commit is contained in:
Eric Wong 2013-05-21 20:19:58 +08:00
parent 9b6d00f14c
commit a9a9ad49cd
15 changed files with 212 additions and 9 deletions

View file

@ -35,18 +35,32 @@ module Fog
request :get_server
request :create_server
request :resize_server
request :remove_balancer_node
request :add_balancer_node
request :add_balancer_service
request :remove_balancer_service
request :check_balancer_available
request :create_balancer
request :delete_balancer
request :update_balancer
request :get_balancer_details
request :list_balancers
request :get_balancer_possible_nodes
request :get_balancer_strategies
request :list_configs
request :get_config_details
request :list_templates
request :list_images
request :create_image
request :delete_image
request :get_image_details
request :update_image
request :restore_image
request :get_stats
request :list_private_ips

View file

@ -8,14 +8,16 @@ module Fog
identity :uniq_id
attribute :vip
attribute :price
attribute :capabilities
attribute :name
attribute :nodes
attribute :region_id
attribute :services
attribute :session_persistence
attribute :ssl_includes
attribute :ssl_termination
attribute :strategy
attribute :nodes
attribute :services
attribute :vip
def initialize(attributes={})
super
@ -31,6 +33,26 @@ module Fog
service.remove_balancer_node({:uniq_id => identity}.merge!(options))
end
def add_service(options)
requires :identity
service.add_balancer_service({:uniq_id => identity}.merge!(options))
end
def remove_service(options)
requires :identity
service.remove_balancer_service({:uniq_id => identity}.merge!(options))
end
def destroy
requires :identity
service.delete_balancer({:uniq_id => identity})
end
def update(options)
requires :identity
service.update_balancer({:uniq_id => identity}.merge!(options))
end
end
end

View file

@ -9,11 +9,34 @@ module Fog
model Fog::Compute::StormOnDemand::Balancer
def all
data = service.list_balancers.body['items']
def all(options={})
data = service.list_balancers(options).body['items']
load(data)
end
def available(name)
avail = service.check_balancer_available(:name => name).body
avail[:available].to_i == 1 ? true : false
end
def create(options)
balancer = service.create_balancer(options).body
new(balancer)
end
def get(uniq_id)
balancer = service.get_balancer_details(:uniq_id => uniq_id).body
new(balancer)
end
def possible_nodes(options={})
service.get_balancer_possible_nodes(options).body[:items]
end
def strategies
service.get_balancer_strategies.body[:strategies]
end
end
end

View file

@ -5,7 +5,7 @@ module Fog
def add_balancer_node(options = {})
request(
:path => "/network/loadbalancer/addnode",
:path => "/Network/LoadBalancer/addNode",
:body => Fog::JSON.encode({:params => options})
)
end

View file

@ -0,0 +1,16 @@
module Fog
module Compute
class StormOnDemand
class Real
def add_balancer_service(options={})
request(
:path => '/Network/LoadBalancer/addService',
:body => Fog::JSON.encode(:params => options)
)
end
end
end
end
end

View file

@ -0,0 +1,16 @@
module Fog
module Compute
class StormOnDemand
class Real
def check_balancer_available(options={})
request(
:path => '/Network/LoadBalancer/available',
:body => Fog::JSON.encode(:params => options)
)
end
end
end
end
end

View file

@ -0,0 +1,16 @@
module Fog
module Compute
class StormOnDemand
class Real
def create_balancer(options={})
request(
:path => '/Network/LoadBalancer/create',
:body => Fog::JSON.encode(:params => options)
)
end
end
end
end
end

View file

@ -0,0 +1,16 @@
module Fog
module Compute
class StormOnDemand
class Real
def delete_balancer(options={})
request(
:path => '/Network/LoadBalancer/delete',
:body => Fog::JSON.encode(:params => options)
)
end
end
end
end
end

View file

@ -0,0 +1,16 @@
module Fog
module Compute
class StormOnDemand
class Real
def get_balancer_details(options={})
request(
:path => '/Network/LoadBalancer/details',
:body => Fog::JSON.encode(:params => options)
)
end
end
end
end
end

View file

@ -0,0 +1,16 @@
module Fog
module Compute
class StormOnDemand
class Real
def get_balancer_possible_nodes(options={})
request(
:path => '/Network/LoadBalancer/possibleNodes',
:body => Fog::JSON.encode(:params => options)
)
end
end
end
end
end

View file

@ -0,0 +1,16 @@
module Fog
module Compute
class StormOnDemand
class Real
def get_balancer_strategies(options={})
request(
:path => '/Network/LoadBalancer/strategies',
:body => Fog::JSON.encode(:params => options)
)
end
end
end
end
end

View file

@ -5,7 +5,7 @@ module Fog
def list_balancers(options = {})
request(
:path => "/network/loadbalancer/list",
:path => "/Network/LoadBalancer/list",
:body => Fog::JSON.encode(options)
)
end

View file

@ -5,7 +5,7 @@ module Fog
def remove_balancer_node(options = {})
request(
:path => "/network/loadbalancer/removenode",
:path => "/Network/LoadBalancer/removeNode",
:body => Fog::JSON.encode({:params => options})
)
end

View file

@ -0,0 +1,16 @@
module Fog
module Compute
class StormOnDemand
class Real
def remove_balancer_service(options={})
request(
:path => '/Network/LoadBalancer/removeService',
:body => Fog::JSON.encode(:params => options)
)
end
end
end
end
end

View file

@ -0,0 +1,16 @@
module Fog
module Compute
class StormOnDemand
class Real
def update_balancer(options={})
request(
:path => '/Network/LoadBalancer/update',
:body => Fog::JSON.encode(:params => options)
)
end
end
end
end
end