Sha256: e14bce850f84a326ac1d7332b077c591b5d33a85a4b1f53b6e25a033a3b008b9

Contents?: true

Size: 1.45 KB

Versions: 26

Compression:

Stored size: 1.45 KB

Contents

require 'fog/core/model'

module Fog
  module Rackspace
    class LoadBalancers
      class Node < Fog::Model
        identity :id

        attribute :address
        attribute :status
        attribute :weight
        attribute :port
        attribute :type
        attribute :condition

        def destroy
          requires :identity, :load_balancer
          service.delete_node(load_balancer.identity, identity)
          true
        end

        def save
          if persisted?
            update
          else
            create
          end
          true
        end

        private
        def load_balancer
          collection.load_balancer
        end

        def create
          requires :load_balancer, :address, :condition, :port
          options = {}
          unless weight.nil?
            options[:weight] = weight
          end
          unless type.nil?
            options[:type] = type
          end
          data = service.create_node(load_balancer.id, address, port, condition, options)
          merge_attributes(data.body['nodes'][0])
        end

        def update
          requires :load_balancer, :identity
          options = {
            :condition => condition
          }
          unless weight.nil?
            options[:weight] = weight
          end
          unless type.nil?
            options[:type] = type
          end
          service.update_node(load_balancer.id, identity, options)
        end
      end
    end
  end
end

Version data entries

26 entries across 24 versions & 5 rubygems

Version Path
fog-rackspace-0.1.6 lib/fog/rackspace/models/load_balancers/node.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-rackspace-0.1.5/lib/fog/rackspace/models/load_balancers/node.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-rackspace-0.1.5/lib/fog/rackspace/models/load_balancers/node.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-rackspace-0.1.5/lib/fog/rackspace/models/load_balancers/node.rb
fog-rackspace-0.1.5 lib/fog/rackspace/models/load_balancers/node.rb
fog-rackspace-0.1.4 lib/fog/rackspace/models/load_balancers/node.rb
fog-rackspace-0.1.3 lib/fog/rackspace/models/load_balancers/node.rb
fog-rackspace-0.1.2 lib/fog/rackspace/models/load_balancers/node.rb
fog-rackspace-0.1.1 lib/fog/rackspace/models/load_balancers/node.rb
fog-rackspace-0.1.0 lib/fog/rackspace/models/load_balancers/node.rb
fog-1.37.0 lib/fog/rackspace/models/load_balancers/node.rb
fog-1.36.0 lib/fog/rackspace/models/load_balancers/node.rb
fog-1.35.0 lib/fog/rackspace/models/load_balancers/node.rb
fog-2.0.0.pre.0 lib/fog/rackspace/models/load_balancers/node.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-1.32.0/lib/fog/rackspace/models/load_balancers/node.rb
fog-1.34.0 lib/fog/rackspace/models/load_balancers/node.rb
fog-1.33.0 lib/fog/rackspace/models/load_balancers/node.rb
fog-1.32.0 lib/fog/rackspace/models/load_balancers/node.rb
fog-1.31.0 lib/fog/rackspace/models/load_balancers/node.rb
fog-1.30.0 lib/fog/rackspace/models/load_balancers/node.rb