rig 0.6.5 → 0.6.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,8 @@
1
1
  # Changelog
2
2
 
3
+ ## v0.6.5:
4
+ * get stickiness code working properly, have to add policy to balancer and associate with listener
5
+
3
6
  ## v0.6.4:
4
7
  * add support for setting stickiness policy with DSL 'sticky' method on balancers
5
8
  * clean up waiting for dns on environment create/save
@@ -9,21 +9,18 @@ module Rig
9
9
  subcommand "list", "list load balancers" do
10
10
  def execute
11
11
  list = Rig::Model::Balancer.all
12
+ rows = []
12
13
  list.each do |lb|
13
- puts lb.id
14
- puts "- listeners"
15
- lb.listeners.each do |l|
16
- puts " - #{l.protocol}:#{l.lb_port} => #{l.instance_protocol}:#{l.instance_port}"
17
- end
18
- puts "- instances"
19
- lb.instances.each do |inst|
20
- puts " - #{inst}"
21
- end
22
- puts "- zones"
23
- lb.availability_zones.each do |z|
24
- puts " - #{z}"
25
- end
14
+ listeners = lb.listeners.map { |l| "#{l.protocol}:#{l.lb_port} => #{l.instance_protocol}:#{l.instance_port}" }.join("\n")
15
+ instances = lb.instances.join("\n")
16
+ zones = lb.availability_zones.join("\n")
17
+ rows << [lb.id,
18
+ listeners,
19
+ instances,
20
+ zones]
26
21
  end
22
+
23
+ print_table(%w{Name Listeners Instances Zones}, rows)
27
24
  end
28
25
  end
29
26
 
@@ -11,9 +11,8 @@ module Rig
11
11
  parameter "TEMPLATE", "the template to use (solo, multi, etc)", :default => "solo"
12
12
 
13
13
  def execute
14
- #connection = Rig::Connection.compute
15
- env = Rig::Model::Environment.create(name, template.to_sym)
16
- #ap env.servers
14
+ Rig::Model::Environment.create(name, template.to_sym)
15
+ Rig::Log.info "environment created"
17
16
  end
18
17
  end
19
18
 
@@ -1,5 +1,4 @@
1
1
  require 'rig'
2
- require 'awesome_print'
3
2
 
4
3
  module Rig
5
4
  module Command
@@ -20,7 +19,7 @@ module Rig
20
19
 
21
20
  def execute
22
21
  # figure out if there are others of this role, if there are add a number to name to distinguish.
23
- n = "#{name}1.#{environment}.env"
22
+ n = "#{name}1.#{environment}.#{Rig.get_config[:dns_subdomain]}"
24
23
  chef = Rig.config[:chef] ? true : false
25
24
 
26
25
  unless flavor
@@ -52,7 +52,7 @@ module Rig
52
52
 
53
53
  def remove_environment(name)
54
54
  zone = zone(Rig.get_config(:dns_zone))
55
- list = zone.records.all.select {|e| e.attributes[:name] =~ /\.#{name}\.env/ }
55
+ list = zone.records.all.select {|e| e.attributes[:name] =~ /\.#{name}\.#{Rig.get_config[:dns_subdomain]}/ }
56
56
  list.each do |e|
57
57
  Rig::Log.info "record: #{e.attributes[:name]}"
58
58
  destroy(e.attributes[:name])
@@ -65,7 +65,7 @@ module Rig
65
65
  @template.servers.each do |s|
66
66
  Rig::Log.debug "server[#{s.count}]= #{s.inspect}"
67
67
  1.upto(s.count) do |i|
68
- n = "#{s.name}#{i}.#@name.env"
68
+ n = "#{s.name}#{i}.#@name.#{Rig.get_config[:dns_subdomain]}"
69
69
  Rig::Log.debug " name= #{n}"
70
70
  userdata = s.userdata || Rig.get_config(:userdata)
71
71
  o = {
@@ -111,8 +111,8 @@ module Rig
111
111
  @balancers << balancer
112
112
 
113
113
  if b.primary
114
- Rig::Log.info ".. primary: #{name}.env.#@zone #{balancer.attributes[:dns_name]}"
115
- Rig::Model::Dns.create("#{name}.env.#@zone", balancer.attributes[:dns_name], :ttl => 30)
114
+ Rig::Log.info ".. primary: #{name}.#{Rig.get_config[:dns_subdomain]}.#@zone #{balancer.attributes[:dns_name]}"
115
+ Rig::Model::Dns.create("#{name}.#{Rig.get_config[:dns_subdomain]}.#@zone", balancer.attributes[:dns_name], :ttl => 30)
116
116
  end
117
117
  end
118
118
  end
@@ -123,17 +123,9 @@ module Rig
123
123
  if set[b.name]
124
124
  if b.sticky
125
125
  Rig::Log.info "#@name-#{b.name}: setting stickiness policy"
126
- policy_name = 'RigLBStickinessPolicy'
127
126
  type = b.sticky_type
128
- expires_or_cookie = b.sticky_arg
129
- case type.to_sym
130
- when :app, :application
131
- ap Rig::Connection.balancer.create_app_cookie_stickiness_policy("#@name-#{b.name}", policy_name, expires_or_cookie)
132
- when :lb, :load_balancer
133
- ap Rig::Connection.balancer.create_lb_cookie_stickiness_policy("#@name-#{b.name}", policy_name, expires_or_cookie)
134
- else
135
- raise "unknown sticky type #{type}"
136
- end
127
+ expires = b.sticky_arg
128
+ Rig::Model::Balancer.sticky(b.name, type, expires, 443, "AWSConsolePolicy-1")
137
129
  end
138
130
  end
139
131
  end
@@ -176,11 +168,11 @@ module Rig
176
168
  roles = @servers.collect { |s| s.tags['Role'] }.compact
177
169
  roles.each do |r|
178
170
  Rig::Log.info "removing role balancer dns (#{r})"
179
- Rig::Model::Dns.destroy("#{r}.#{name}.env.#{Rig.get_config(:dns_zone)}")
171
+ Rig::Model::Dns.destroy("#{r}.#{name}.#{Rig.get_config[:dns_subdomain]}.#{Rig.get_config(:dns_zone)}")
180
172
  end
181
173
 
182
174
  Rig::Log.info "removing primary dns"
183
- Rig::Model::Dns.destroy("#{name}.env.#{Rig.get_config(:dns_zone)}")
175
+ Rig::Model::Dns.destroy("#{name}.#{Rig.get_config[:dns_subdomain]}.#{Rig.get_config(:dns_zone)}")
184
176
 
185
177
  Rig::Log.info "destroying servers"
186
178
  Rig::Model::Instance.destroy(@servers)
@@ -39,6 +39,8 @@ module Rig
39
39
  end
40
40
 
41
41
  def create(opts, tags={})
42
+ #Rig::Log.debug "instance create #{opts.inspect}"
43
+ #Rig::Log.debug "instance create #{tags.inspect}"
42
44
  fog = Rig::Connection.compute
43
45
  server = fog.servers.create(opts)
44
46
  fog.create_tags(server.id, tags) if tags.count > 0
@@ -1,5 +1,4 @@
1
1
  require 'erubis'
2
- require 'awesome_print'
3
2
 
4
3
  module Rig
5
4
  module Model
@@ -6,9 +6,12 @@ module Rig
6
6
  @hooks.select { |e| e[:event] == event }.each do |plugin|
7
7
  klass = plugin[:class]
8
8
  block = plugin[:block]
9
-
10
- Rig::Log.debug "calling #{klass} :: #{event}"
11
- block.call(args.dup)
9
+ begin
10
+ Rig::Log.debug "calling #{klass} :: #{event}"
11
+ block.call(args.dup)
12
+ rescue => e
13
+ Rig::Log.error "failed to run event #{event} for #{klass}"
14
+ end
12
15
  end
13
16
  end
14
17
 
@@ -5,13 +5,13 @@ module Rig
5
5
  @templates ||= { }
6
6
  template_name = name.to_sym
7
7
  template_file = "#{dir}/#{name}.rb"
8
-
9
8
  raise "could not load template #{template_name} (#{template_file})" unless File.file?(template_file)
10
- raise "template already loaded #{template_name}" if @templates[template_name]
11
-
12
- t = Rig::Template::DSL.new(template_name)
13
- t.instance_eval(File.read(template_file), "Template(#{template_file})")
14
- @templates[template_name] = t
9
+ #raise "template already loaded #{template_name}" if @templates[template_name]
10
+ @templates[template_name] ||= begin
11
+ t = Rig::Template::DSL.new(template_name)
12
+ t.instance_eval(File.read(template_file), "Template(#{template_file})")
13
+ @templates[template_name] = t
14
+ end
15
15
  end
16
16
 
17
17
  def load_yaml_file(path)
@@ -3,7 +3,7 @@ unless defined?(Rig::Version)
3
3
  module Version
4
4
  MAJOR = 0
5
5
  MINOR = 6
6
- TINY = 5
6
+ TINY = 6
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rig
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.5
4
+ version: 0.6.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-04 00:00:00.000000000 Z
12
+ date: 2012-09-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: clamp