rig 0.6.4 → 0.6.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +5 -0
- data/lib/rig/command/balancer.rb +20 -1
- data/lib/rig/model/balancer.rb +32 -13
- data/lib/rig/model/environment.rb +10 -5
- data/lib/rig/version.rb +1 -1
- metadata +1 -1
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## v0.6.4:
|
4
|
+
* add support for setting stickiness policy with DSL 'sticky' method on balancers
|
5
|
+
* clean up waiting for dns on environment create/save
|
6
|
+
* clean up mongo plugin
|
7
|
+
|
3
8
|
## v0.6.3:
|
4
9
|
* minor bug fixes
|
5
10
|
* clean up 'server tags' command, need to look at the rest
|
data/lib/rig/command/balancer.rb
CHANGED
@@ -89,13 +89,32 @@ module Rig
|
|
89
89
|
subcommand "view", "view load balancer information" do
|
90
90
|
include Options::ShowAll
|
91
91
|
|
92
|
-
parameter "NAME", "name of
|
92
|
+
parameter "NAME", "name of the balancer"
|
93
93
|
|
94
94
|
def execute
|
95
95
|
item = Rig::Model::Balancer.find(name)
|
96
96
|
puts item.attributes.to_yaml
|
97
97
|
end
|
98
98
|
end
|
99
|
+
|
100
|
+
subcommand "sticky", "set sticky policy" do
|
101
|
+
|
102
|
+
parameter "NAME", "name of the balancer"
|
103
|
+
|
104
|
+
option %w{-d --delete}, :flag, "delete policy"
|
105
|
+
option %w{-p --policy}, "POLICY", "policy name", :default => "AWSConsolePolicy-1"
|
106
|
+
option %w{-l --listener}, "LISTENER", "the listener port", :default => "443"
|
107
|
+
option %w{-t --type}, "TYPE", "the sticky policy type (lb or app)", :default => "lb"
|
108
|
+
option %w{-e --expires}, "EXPIRES", "the expiration period for lb type or cookie for app type", :default => "300"
|
109
|
+
|
110
|
+
def execute
|
111
|
+
if delete?
|
112
|
+
Rig::Model::Balancer.unsticky(name, type, expires, listener, policy)
|
113
|
+
else
|
114
|
+
Rig::Model::Balancer.sticky(name, type, expires, listener, policy)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
99
118
|
end
|
100
119
|
end
|
101
120
|
end
|
data/lib/rig/model/balancer.rb
CHANGED
@@ -79,6 +79,38 @@ module Rig
|
|
79
79
|
match.first.destroy
|
80
80
|
end
|
81
81
|
|
82
|
+
def sticky(balancer_name, type, expires_or_cookie, listener="443", policy_name='RigLbCookiePolicy')
|
83
|
+
elb = find(balancer_name)
|
84
|
+
raise "balancer #{balancer_name} not found" unless elb
|
85
|
+
|
86
|
+
case type.to_sym
|
87
|
+
when :app, :application
|
88
|
+
Rig::Connection.balancer.create_app_cookie_stickiness_policy(balancer_name, policy_name, expires_or_cookie)
|
89
|
+
Rig::Connection.balancer.set_load_balancer_policies_of_listener(balancer_name, listener.to_i, [policy_name])
|
90
|
+
when :lb, :load_balancer
|
91
|
+
Rig::Connection.balancer.create_lb_cookie_stickiness_policy(balancer_name, policy_name, expires_or_cookie.to_i)
|
92
|
+
Rig::Connection.balancer.set_load_balancer_policies_of_listener(balancer_name, listener.to_i, [policy_name])
|
93
|
+
else
|
94
|
+
raise "unknown sticky type #{type}"
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def unsticky(balancer_name, type, expires_or_cookie, listener="443", policy_name='RigLbCookiePolicy')
|
99
|
+
elb = find(balancer_name)
|
100
|
+
raise "balancer #{balancer_name} not found" unless elb
|
101
|
+
|
102
|
+
case type.to_sym
|
103
|
+
when :app, :application
|
104
|
+
Rig::Connection.balancer.set_load_balancer_policies_of_listener(balancer_name, listener.to_i, [])
|
105
|
+
Rig::Connection.balancer.delete_load_balancer_policy(balancer_name, policy_name)
|
106
|
+
when :lb, :load_balancer
|
107
|
+
Rig::Connection.balancer.set_load_balancer_policies_of_listener(balancer_name, listener.to_i, [])
|
108
|
+
Rig::Connection.balancer.delete_load_balancer_policy(balancer_name, policy_name)
|
109
|
+
else
|
110
|
+
raise "unknown sticky type #{type}"
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
82
114
|
private
|
83
115
|
|
84
116
|
def new_listener_description(listener)
|
@@ -99,19 +131,6 @@ module Rig
|
|
99
131
|
'PolicyNames' => policy_names
|
100
132
|
}
|
101
133
|
end
|
102
|
-
|
103
|
-
def sticky(type, balancer_name, expires_or_cookie, policy_name='LBCookieStickinessPolicy')
|
104
|
-
elb = find(balancer_name)
|
105
|
-
raise "balancer #{balancer_name} not found" unless elb
|
106
|
-
case type.to_sym
|
107
|
-
when :app, :application
|
108
|
-
Rig::Connection.balancer.create_app_cookie_stickiness_policy(balancer_name, policy_name, expires_or_cookie)
|
109
|
-
when :lb, :load_balancer
|
110
|
-
Rig::Connection.balancer.create_lb_cookie_stickiness_policy(balancer_name, policy_name, expires_or_cookie)
|
111
|
-
else
|
112
|
-
raise "unknown sticky type #{type}"
|
113
|
-
end
|
114
|
-
end
|
115
134
|
end
|
116
135
|
end
|
117
136
|
end
|
@@ -114,17 +114,23 @@ module Rig
|
|
114
114
|
Rig::Log.info ".. primary: #{name}.env.#@zone #{balancer.attributes[:dns_name]}"
|
115
115
|
Rig::Model::Dns.create("#{name}.env.#@zone", balancer.attributes[:dns_name], :ttl => 30)
|
116
116
|
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
wait_for_dns
|
117
121
|
|
122
|
+
@template.balancers.each do |b|
|
123
|
+
if set[b.name]
|
118
124
|
if b.sticky
|
119
|
-
Rig::Log.info "
|
125
|
+
Rig::Log.info "#@name-#{b.name}: setting stickiness policy"
|
120
126
|
policy_name = 'RigLBStickinessPolicy'
|
121
127
|
type = b.sticky_type
|
122
128
|
expires_or_cookie = b.sticky_arg
|
123
129
|
case type.to_sym
|
124
130
|
when :app, :application
|
125
|
-
Rig::Connection.balancer.create_app_cookie_stickiness_policy("#@name-#{b.name}", policy_name, expires_or_cookie)
|
131
|
+
ap Rig::Connection.balancer.create_app_cookie_stickiness_policy("#@name-#{b.name}", policy_name, expires_or_cookie)
|
126
132
|
when :lb, :load_balancer
|
127
|
-
Rig::Connection.balancer.create_lb_cookie_stickiness_policy("#@name-#{b.name}", policy_name, expires_or_cookie)
|
133
|
+
ap Rig::Connection.balancer.create_lb_cookie_stickiness_policy("#@name-#{b.name}", policy_name, expires_or_cookie)
|
128
134
|
else
|
129
135
|
raise "unknown sticky type #{type}"
|
130
136
|
end
|
@@ -132,8 +138,6 @@ module Rig
|
|
132
138
|
end
|
133
139
|
end
|
134
140
|
|
135
|
-
wait_for_dns
|
136
|
-
|
137
141
|
Rig::Log.info "associating servers' DNS"
|
138
142
|
@dnsdelayed.each do |h|
|
139
143
|
server = @server_hash[h[:server]]
|
@@ -204,6 +208,7 @@ module Rig
|
|
204
208
|
private
|
205
209
|
|
206
210
|
def wait_for_dns
|
211
|
+
Rig::Log.info "waiting for servers..."
|
207
212
|
while servers_without_dns > 0
|
208
213
|
sleep 2
|
209
214
|
reload
|
data/lib/rig/version.rb
CHANGED