Sha256: bac933753ac20bdf2af0343a67eeab9a9050fbf53d4e38f755031699a93a8d7d

Contents?: true

Size: 1.1 KB

Versions: 37

Compression:

Stored size: 1.1 KB

Contents

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

Version data entries

37 entries across 37 versions & 2 rubygems

Version Path
fog-1.22.0 lib/fog/hp/models/lb/node.rb
fog-1.21.0 lib/fog/hp/models/lb/node.rb
fog-maestrodev-1.20.0.20140305101839 lib/fog/hp/models/lb/node.rb
fog-maestrodev-1.20.0.20140305101305 lib/fog/hp/models/lb/node.rb
fog-maestrodev-1.19.0.20140212012611 lib/fog/hp/models/lb/node.rb
fog-1.20.0 lib/fog/hp/models/lb/node.rb
fog-maestrodev-1.19.0.20140110004459 lib/fog/hp/models/lb/node.rb
fog-maestrodev-1.19.0.20140110003812 lib/fog/hp/models/lb/node.rb
fog-maestrodev-1.19.0.20140109202555 lib/fog/hp/models/lb/node.rb
fog-maestrodev-1.19.0.20140107192102 lib/fog/hp/models/lb/node.rb
fog-maestrodev-1.19.0.20140107142106 lib/fog/hp/models/lb/node.rb
fog-maestrodev-1.19.0.20131219203941 lib/fog/hp/models/lb/node.rb
fog-maestrodev-1.18.0.20131219193542 lib/fog/hp/models/lb/node.rb
fog-1.19.0 lib/fog/hp/models/lb/node.rb
fog-maestrodev-1.18.0.20131219033443 lib/fog/hp/models/lb/node.rb
fog-maestrodev-1.18.0.20131219032002 lib/fog/hp/models/lb/node.rb
fog-maestrodev-1.18.0.20131219030716 lib/fog/hp/models/lb/node.rb
fog-maestrodev-1.18.0.20131219022322 lib/fog/hp/models/lb/node.rb
fog-maestrodev-1.18.0.20131218202447 lib/fog/hp/models/lb/node.rb
fog-maestrodev-1.18.0.20131209091424 lib/fog/hp/models/lb/node.rb