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 :get_server
request :create_server request :create_server
request :resize_server request :resize_server
request :remove_balancer_node request :remove_balancer_node
request :add_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 :list_balancers
request :get_balancer_possible_nodes
request :get_balancer_strategies
request :list_configs request :list_configs
request :get_config_details request :get_config_details
request :list_templates request :list_templates
request :list_images request :list_images
request :create_image request :create_image
request :delete_image request :delete_image
request :get_image_details request :get_image_details
request :update_image request :update_image
request :restore_image request :restore_image
request :get_stats request :get_stats
request :list_private_ips request :list_private_ips

View file

@ -8,14 +8,16 @@ module Fog
identity :uniq_id identity :uniq_id
attribute :vip attribute :capabilities
attribute :price
attribute :name attribute :name
attribute :nodes
attribute :region_id
attribute :services
attribute :session_persistence attribute :session_persistence
attribute :ssl_includes
attribute :ssl_termination attribute :ssl_termination
attribute :strategy attribute :strategy
attribute :nodes attribute :vip
attribute :services
def initialize(attributes={}) def initialize(attributes={})
super super
@ -31,8 +33,28 @@ module Fog
service.remove_balancer_node({:uniq_id => identity}.merge!(options)) service.remove_balancer_node({:uniq_id => identity}.merge!(options))
end end
def add_service(options)
requires :identity
service.add_balancer_service({:uniq_id => identity}.merge!(options))
end 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 end
end end
end end

View file

@ -9,11 +9,34 @@ module Fog
model Fog::Compute::StormOnDemand::Balancer model Fog::Compute::StormOnDemand::Balancer
def all def all(options={})
data = service.list_balancers.body['items'] data = service.list_balancers(options).body['items']
load(data) load(data)
end 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
end end

View file

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

View file

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