Sha256: ec183c106d1c1ba065e7ccd5d42288d92a68be7f0190da05e2b24f778c11b4a3

Contents?: true

Size: 1.29 KB

Versions: 16

Compression:

Stored size: 1.29 KB

Contents

require 'mccloud/util/iterator'

module Mccloud
  module Command
    include Mccloud::Util

    def loadbalance(selection, options)
      filter=@environment.config.mccloud.stackfilter

      puts
      on_selected_lbs(selection) do |id,lb|

        member_ids=Array.new
        lb_instance=lb.instance
        #Adding new member first
        lb.members.each do |member|
          vm=@environment.config.vms[member]
          server_instance=vm.instance
          unless server_instance.nil?
            unless lb_instance.nil?
              puts "[#{lb.name}] Registering #{vm.name} - #{server_instance.id} with loadbalancer "
              lb_instance.register_instances(server_instance.id)
              member_ids << server_instance.id
            else
              puts "[#{lb.name} Loadbalancer does not (yet) exist"
            end
          else
            puts "[#{lb.name}] Member #{member} is not yet created. "
          end
        end

        #Removing old members
        lb_instance.instances.each do |instance_id|
          unless member_ids.include?(instance_id)
            lb_instance=lb.instance
            lb_instance.deregister_instances(instance_id)
            puts "[#{lb.name}] De-registering member #{instance_id} with loadbalancer "

          end
        end
      end

    end

  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
mccloud-0.1.1 lib/mccloud/provider/aws/provider/old_loadbalance.rb
mccloud-0.0.28 lib/mccloud/provider/aws/provider/old_loadbalance.rb
mccloud-0.0.27 lib/mccloud/provider/aws/provider/old_loadbalance.rb
mccloud-0.0.26 lib/mccloud/provider/aws/provider/old_loadbalance.rb
mccloud-0.0.25 lib/mccloud/provider/aws/provider/old_loadbalance.rb
mccloud-0.0.24 lib/mccloud/provider/aws/provider/old_loadbalance.rb
mccloud-0.0.23 lib/mccloud/provider/aws/provider/old_loadbalance.rb
mccloud-0.0.22 lib/mccloud/provider/aws/provider/old_loadbalance.rb
mccloud-0.0.21 lib/mccloud/provider/aws/provider/old_loadbalance.rb
mccloud-0.0.20 lib/mccloud/provider/aws/provider/old_loadbalance.rb
mccloud-0.0.19 lib/mccloud/provider/aws/provider/old_loadbalance.rb
mccloud-0.0.18 lib/mccloud/provider/aws/provider/old_loadbalance.rb
mccloud-0.0.17 lib/mccloud/provider/aws/provider/old_loadbalance.rb
mccloud-0.0.16 lib/mccloud/provider/aws/provider/old_loadbalance.rb
mccloud-0.0.15 lib/mccloud/provider/aws/provider/old_loadbalance.rb
mccloud-0.0.14 lib/mccloud/provider/aws/provider/old_loadbalance.rb