class Fog::HP::LB::LoadBalancer

Public Instance Methods

destroy() click to toggle source
# File lib/fog/hp/models/lb/load_balancer.rb, line 21
def destroy
  requires :id
  service.delete_load_balancer(id)
  true
end
nodes() click to toggle source
# File lib/fog/hp/models/lb/load_balancer.rb, line 35
def nodes
  @nodes ||= begin
    Fog::HP::LB::Nodes.new({
      :service  => service,
      :load_balancer   => self
    })
  end
end
nodes=(new_nodes=[]) click to toggle source
# File lib/fog/hp/models/lb/load_balancer.rb, line 44
def nodes=(new_nodes=[])
  nodes.load(new_nodes)
end
ready?() click to toggle source
# File lib/fog/hp/models/lb/load_balancer.rb, line 27
def ready?
  self.status == 'ACTIVE'
end
save() click to toggle source
# File lib/fog/hp/models/lb/load_balancer.rb, line 31
def save
  identity ? update : create
end

Private Instance Methods

create() click to toggle source
# File lib/fog/hp/models/lb/load_balancer.rb, line 50
def create
  requires :name, :nodes

  options = {}
  options['virtualIps'] = virtual_ips if virtual_ips
  options['port']       = port if port
  options['protocol']   = protocol if protocol
  options['algorithm']  = algorithm if algorithm
  merge_attributes(service.create_load_balancer(name, nodes_to_hash, options).body)
  true
end
nodes_to_hash() click to toggle source
# File lib/fog/hp/models/lb/load_balancer.rb, line 72
def nodes_to_hash
  if nodes
    nodes.map do |node|
      { 'address' => node.address, 'port' => node.port, 'condition' => node.condition }
    end
  end
end
update() click to toggle source
# File lib/fog/hp/models/lb/load_balancer.rb, line 62
def update
  requires :id

  options = {}
  options['name']       = name if name
  options['algorithm']  = algorithm if algorithm
  service.update_load_balancer(id, options).body
  true
end