conan 0.4.10 → 0.4.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -67,7 +67,7 @@ module AWS
67
67
  image_id = new_conf[:image_id]
68
68
  end
69
69
  else
70
- image_id = create_ami_from_server(new_conf[:server_to_image], region)
70
+ image_id = create_ami_from_server(new_conf[:server_to_image], region)
71
71
  end
72
72
 
73
73
  autoscale = Fog::AWS::AutoScaling.new(:region => region)
@@ -102,6 +102,54 @@ module AWS
102
102
  end
103
103
  end
104
104
 
105
+ def launch_test_instances
106
+ autoscale_config.each do |type, resources|
107
+ case type
108
+ when "launch-config"
109
+ resources.each do |name, conf|
110
+ start_test_server(name, conf)
111
+ end
112
+ end
113
+ end
114
+ end
115
+
116
+ def start_test_server(name, config = {})
117
+ new_conf = config.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
118
+ region = new_conf[:region] || "us-east-1"
119
+
120
+ compute = Fog::Compute.new(:provider => :aws, :region => region)
121
+
122
+ autoscale = Fog::AWS::AutoScaling.new(:region => region)
123
+ asres = autoscale.describe_auto_scaling_groups({'AutoScalingGroupNames' => new_conf[:autoscale_groups]})
124
+ lcname = ""
125
+ #so aws APIs sometimes return a blank scaling group????? need to check if there is a LC
126
+ asres.body["DescribeAutoScalingGroupsResult"]["AutoScalingGroups"].each do |asgroup|
127
+ lcname = asgroup["LaunchConfigurationName"]
128
+ break if !lcname.nil? && lcname.length > 0
129
+ end
130
+
131
+ lcres = autoscale.describe_launch_configurations({'LaunchConfigurationNames' => [lcname]})
132
+ lc = lcres.body["DescribeLaunchConfigurationsResult"]["LaunchConfigurations"][0]
133
+
134
+ compute = Fog::Compute.new(:provider => :aws, :region => region)
135
+ server_params = {}
136
+ server_params[:groups] = lc["SecurityGroups"]
137
+ server_params[:key_name] = lc["KeyName"]
138
+ server_params[:image_id] = lc["ImageId"]
139
+ server_params[:monitoring] = false
140
+ server_params[:flavor_id] = lc["InstanceType"]
141
+ server_params[:root_device_type] = "ebs"
142
+ server_params[:availability_zone] = default_availability_zone(region)
143
+
144
+
145
+ puts "Creating test instance from image for launch configuration #{lcname}"
146
+ server = compute.servers.create(server_params)
147
+ server.wait_for { ready? }
148
+
149
+ puts "Created server #{server.dns_name} for testing. Please delete manually"
150
+
151
+ end
152
+
105
153
  end
106
154
  end
107
155
 
@@ -162,7 +162,11 @@ module AWS
162
162
 
163
163
  rdssg_name = rds_name_tag(name)
164
164
 
165
- rdssg = rds.security_groups.get(rdssg_name)
165
+ rdssg = begin
166
+ rds.security_groups.get(rdssg_name)
167
+ rescue Excon::Errors::NotFound
168
+ nil
169
+ end
166
170
 
167
171
  if rdssg.nil?
168
172
  puts "Creating RDS Security Group #{rdssg_name}"
@@ -239,7 +243,12 @@ module AWS
239
243
 
240
244
  elb_name = ec2_name_tag(name)
241
245
 
242
- lb = elb.load_balancers.get(elb_name)
246
+ lb = begin
247
+ elb.load_balancers.get(elb_name)
248
+ rescue Excon::Errors::BadRequest, Excon::Errors::NotFound
249
+ nil
250
+ end
251
+
243
252
  if lb.nil?
244
253
  puts "Creating Elastic Load Balancer #{elb_name}"
245
254
 
@@ -365,7 +374,11 @@ module AWS
365
374
  params[:security_group_names] = [rds_name_tag('default')]
366
375
  end
367
376
 
368
- server = rds.servers.get(params[:id])
377
+ server = begin
378
+ rds.servers.get(params[:id])
379
+ rescue Excon::Errors::NotFound
380
+ nil
381
+ end
369
382
 
370
383
  if server.nil?
371
384
  puts "Creating RDS Server #{params[:id]}"
@@ -401,7 +414,11 @@ module AWS
401
414
 
402
415
  cluster_name = ec2_name_tag(name)
403
416
 
404
- cl = elasticache.clusters.get(cluster_name)
417
+ cl = begin
418
+ elasticache.clusters.get(cluster_name)
419
+ rescue Excon::Errors::NotFound
420
+ nil
421
+ end
405
422
 
406
423
  unless cl
407
424
  puts "Creating ElastiCache cluster #{cluster_name}"
@@ -52,7 +52,7 @@ module AWS
52
52
  case region
53
53
  when "us-east-1"
54
54
  #not using availability zone us-east-1a as it often fails
55
- ["us-east-1b", "us-east-1c"]
55
+ ["us-east-1b", "us-east-1d"]
56
56
  when "us-west-1"
57
57
  ["us-west-1a", "us-west-1b", "us-west-1c"]
58
58
  when "eu-west-1"
@@ -41,5 +41,10 @@ namespace :aws do
41
41
  AWS::Autoscale.new(stage, autoscale_config, application).update_autoscale
42
42
  end
43
43
 
44
+ desc "create a test instance from an autoscale image after a deployment"
45
+ task :test_autoscale do
46
+ autoscale_config = JSON.parse(File.read("config/autoscale.json"))[stage] || {}
47
+ AWS::Autoscale.new(stage, autoscale_config, application).launch_test_instances
48
+ end
44
49
  end
45
50
 
@@ -31,13 +31,10 @@ module Conan
31
31
 
32
32
 
33
33
  def git_log(from, to)
34
- begin
35
- run_locally("git log #{real_revision(from)}..#{real_revision(to)}")
36
- rescue RuntimeError
37
- #runtime error probably means there is no initial tag and no deploys have been done
38
- return run_locally("git log #{real_revision(to)}")
39
- end
40
-
34
+ run_locally "git log #{real_revision(from)}..#{real_revision(to)}"
35
+ rescue RuntimeError
36
+ # there is probably no initial tag or no deploys have been done
37
+ return run_locally("git log #{real_revision(to)}")
41
38
  end
42
39
 
43
40
  def real_revision(tag)
@@ -6,6 +6,7 @@ namespace :git do
6
6
 
7
7
  before "git:tag_attempted_deploy", "git:deploy_commits" unless deploy_via == :copy
8
8
  task :deploy_commits do
9
+ run_locally "git fetch origin --tags"
9
10
  logs = git_log("#{stage}.#{application}.last-successful-deploy", branch)
10
11
  puts "the following new commits for #{application} on #{stage} revision #{real_revision(branch)} will be deployed"
11
12
  puts logs
@@ -44,7 +44,8 @@
44
44
  },
45
45
  "s3": {
46
46
  "bucket-name": {
47
- "region": "us-east-1"
47
+ "region": "us-east-1",
48
+ "location_constraint": "us-east-1"
48
49
  }
49
50
  }
50
51
  },
@@ -1,3 +1,3 @@
1
1
  module Conan
2
- VERSION = "0.4.10"
2
+ VERSION = "0.4.11"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: conan
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.10
4
+ version: 0.4.11
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,16 +10,16 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-10-16 00:00:00.000000000 Z
13
+ date: 2013-05-21 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: json
16
+ name: capistrano
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
21
21
  - !ruby/object:Gem::Version
22
- version: 1.6.1
22
+ version: '0'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -27,23 +27,7 @@ dependencies:
27
27
  requirements:
28
28
  - - ! '>='
29
29
  - !ruby/object:Gem::Version
30
- version: 1.6.1
31
- - !ruby/object:Gem::Dependency
32
- name: capistrano
33
- requirement: !ruby/object:Gem::Requirement
34
- none: false
35
- requirements:
36
- - - ~>
37
- - !ruby/object:Gem::Version
38
- version: 2.12.0
39
- type: :runtime
40
- prerelease: false
41
- version_requirements: !ruby/object:Gem::Requirement
42
- none: false
43
- requirements:
44
- - - ~>
45
- - !ruby/object:Gem::Version
46
- version: 2.12.0
30
+ version: '0'
47
31
  - !ruby/object:Gem::Dependency
48
32
  name: fog
49
33
  requirement: !ruby/object:Gem::Requirement