1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/hp/models/lb/node.rb
Paul Thornthwaite 2e0b7e545a Standardise empty lines throughout codebase
Done with `rubocop --auto-correct --only EmptyLineBetweenDefs,EmptyLines,EmptyLinesAroundBody`
2014-05-26 14:20:02 +01:00

51 lines
1.1 KiB
Ruby

require 'fog/core/model'
module Fog
module HP
class LB
class Node < Fog::Model
identity :id
attribute :address
attribute :port
attribute :condition
attribute :status
def destroy
requires :id, :load_balancer
service.delete_load_balancer_node(load_balancer.id, id)
true
end
def ready?
self.status == 'ONLINE'
end
def save
identity ? update : create
end
private
def load_balancer
collection.load_balancer
end
def create
requires :load_balancer, :address, :port
options = {}
options['condition'] = condition if condition
data = service.create_load_balancer_node(load_balancer.id, address, port, options)
merge_attributes(data.body['nodes'][0])
true
end
def update
requires :id, :load_balancer, :condition
service.update_load_balancer_node(load_balancer.id, id, condition)
true
end
end
end
end
end