mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
50 lines
1 KiB
Ruby
50 lines
1 KiB
Ruby
require 'fog/core/model'
|
|
|
|
module Fog
|
|
module Brightbox
|
|
class Compute
|
|
|
|
class LoadBalancer < Fog::Model
|
|
|
|
identity :id
|
|
|
|
attribute :url
|
|
attribute :name
|
|
attribute :status
|
|
attribute :resource_type
|
|
|
|
attribute :nodes
|
|
attribute :policy
|
|
attribute :healthcheck
|
|
attribute :listeners
|
|
attribute :account
|
|
|
|
def ready?
|
|
status == 'active'
|
|
end
|
|
|
|
def save
|
|
requires :nodes, :listeners, :healthcheck
|
|
options = {
|
|
:nodes => nodes,
|
|
:listeners => listeners,
|
|
:healthcheck => healthcheck,
|
|
:policy => policy,
|
|
:name => name
|
|
}.delete_if {|k,v| v.nil? || v == "" }
|
|
data = connection.create_load_balancer(options)
|
|
merge_attributes(data)
|
|
true
|
|
end
|
|
|
|
def destroy
|
|
requires :identity
|
|
connection.destroy_load_balancer(identity)
|
|
true
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
end
|
|
end
|