2013-03-01 14:26:52 -06:00
|
|
|
require 'fog/core/model'
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module HP
|
|
|
|
class LB
|
2013-03-06 11:01:54 -06:00
|
|
|
class Node < Fog::Model
|
2013-03-01 14:26:52 -06:00
|
|
|
|
|
|
|
identity :id
|
|
|
|
attribute :address
|
|
|
|
attribute :port
|
|
|
|
attribute :condition
|
|
|
|
attribute :status
|
2013-05-21 15:09:13 -06:00
|
|
|
attribute :load_balancer_id
|
2013-03-01 14:26:52 -06:00
|
|
|
|
2013-05-21 15:09:13 -06:00
|
|
|
def destroy
|
|
|
|
requires :id
|
|
|
|
requires :load_balancer_id
|
|
|
|
service.delete_load_balancer_node(load_balancer_id, id)
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
def ready?
|
|
|
|
self.status == 'ACTIVE'
|
|
|
|
end
|
|
|
|
|
|
|
|
def save
|
|
|
|
identity ? update : create
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
2013-03-01 14:26:52 -06:00
|
|
|
|
2013-05-21 15:09:13 -06:00
|
|
|
def create
|
|
|
|
requires :load_balancer_id
|
|
|
|
merge_attributes(service.create_load_balancer_node(load_balancer_id, {'nodes' => [attributes]}).body)
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
|
|
|
requires :id
|
|
|
|
requires :load_balancer_id
|
|
|
|
service.update_load_balancer_node(load_balancer_id, id, attributes[:condition])
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
2013-03-01 14:26:52 -06:00
|
|
|
end
|
|
|
|
end
|
2013-05-21 15:09:13 -06:00
|
|
|
end
|