9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/mccloud/provider/aws/lb/associate.rb', line 9
def balance(members,options)
unless raw.nil?
current_members=raw.instances
cleanup_members=current_members
members.each do |member_id|
env.logger.info "Attempting to associate #{@name} with vm name #{member_id}"
vm=env.config.vms[member_id]
if vm.nil?
env.ui.error "vm #{member_id} is not defined"
else
if vm.id.nil?
env.ui.error "vm #{member_id} is not yet instantiated"
else
env.logger.info "The loadbalancer currently has members #{current_members.join(",")} associated" unless raw.instances.nil?
if current_members.include?(vm.id)
cleanup_members=cleanup_members - [ vm.id ]
env.ui.info "[#{@name}] Skipping associate #{vm.name} - #{vm.id} as it already is a member"
else
env.ui.info "[#{@name}] Associating #{vm.name} - #{vm.id}"
raw.register_instances(vm.id)
end
end
end
end
require 'pp'
cleanup_members.each do |member_id|
env.ui.info "Cleanup of old member #{member_id}"
raw.deregister_instances(member_id)
end
else
env.ui.error "[#{@name}] Loadbalancer does not (yet) exist"
end
end
|