2010-12-03 09:54:50 -05:00
|
|
|
require 'fog/core/model'
|
|
|
|
|
|
|
|
module Fog
|
2011-06-16 19:28:54 -04:00
|
|
|
module Compute
|
|
|
|
class Brightbox
|
2010-12-03 09:54:50 -05:00
|
|
|
|
|
|
|
class LoadBalancer < Fog::Model
|
|
|
|
|
|
|
|
identity :id
|
|
|
|
attribute :url
|
2011-08-22 12:41:18 -04:00
|
|
|
attribute :resource_type
|
|
|
|
|
2010-12-03 09:54:50 -05:00
|
|
|
attribute :name
|
|
|
|
attribute :status
|
|
|
|
|
|
|
|
attribute :policy
|
2011-08-22 12:41:18 -04:00
|
|
|
attribute :nodes
|
2010-12-03 09:54:50 -05:00
|
|
|
attribute :healthcheck
|
|
|
|
attribute :listeners
|
2011-08-22 12:41:18 -04:00
|
|
|
|
|
|
|
# Times
|
2011-08-26 11:00:24 -04:00
|
|
|
attribute :created_at, :type => :time
|
|
|
|
attribute :deleted_at, :type => :time
|
2011-08-22 12:41:18 -04:00
|
|
|
|
|
|
|
# Links - to be replaced
|
2010-12-03 09:54:50 -05:00
|
|
|
attribute :account
|
2011-08-22 12:41:18 -04:00
|
|
|
attribute :server
|
|
|
|
attribute :cloud_ip
|
2010-12-03 09:54:50 -05:00
|
|
|
|
|
|
|
def ready?
|
|
|
|
status == 'active'
|
|
|
|
end
|
|
|
|
|
|
|
|
def save
|
2012-12-22 21:45:05 -05:00
|
|
|
raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted?
|
2010-12-03 09:54:50 -05:00
|
|
|
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
|