bbc-cosmos-tools 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b7190ff2e94981faebca714317e92216e4158b69
4
- data.tar.gz: 22c74bf8e9a3e2e7ff70360a5f05bf2999c2246f
3
+ metadata.gz: 04c758bfc6ade823bed478bba49e00c3fba442f6
4
+ data.tar.gz: 7fe305ecdec23db678c74374bd7560c965d0dd73
5
5
  SHA512:
6
- metadata.gz: 66373735b82214ca4e9b3a4c79ddaa8838dc9dfe8691f37cf135f62cfffe0945d1fb0f983b72b8aacd324624b86cdbbcbad726cae624c5416db898a98494360b
7
- data.tar.gz: b2164e242b15e93c2dd73c78889b1d9fd49a20c1704534622e7773ae5237ef7f7715933c516dd187d69844098118b857da9361e6fa9c93c7db0085d052913ce1
6
+ metadata.gz: 87151ff75ea23d7c8b8b09efb02f0e347e568d519222d4f3bb3563ce131024ae35dabf3b81f931e84ac258c382aa7ea36a40eaa7b993fd3d48e729a3c90d5177
7
+ data.tar.gz: 0b76ea8dee40322a0f382576824b9116c8279b0f23e14190b332f2e026606f64708edd72ce2487484a5bb5fc95e1921b8a2ca221ac419cab91d492ffcee0ec29
@@ -60,7 +60,7 @@ module BBC
60
60
  method_option :group, :type => :string, :default => nil, :desc => "The group name to override the component id"
61
61
  desc "stack create [COMPONENT, MAIN_STACK = false]", "Generates and create the cloudformation template for the specific component"
62
62
  def create(component, main_stack = false)
63
-
63
+ begin
64
64
  say "#{banner(component)}\n"
65
65
 
66
66
  data = cloudformation(component, options, false)
@@ -72,14 +72,17 @@ module BBC
72
72
  'parameters' => Tools::Cloudformation::Generator.parameters(data),
73
73
  }
74
74
 
75
- @api = BBC::Cosmos::Tools::Config::API.new(config.app['api'], options[:key_path])
76
- response = @api.post sprintf(config.app['stack_create_endpoint'], options[:env], component), JSON.pretty_generate(post_data)
75
+ response = api.post sprintf(config.app['stack_create_endpoint'], options[:env], component), JSON.pretty_generate(post_data)
77
76
 
78
77
  if response.success?
79
78
  say "Stack creation for component '#{component}' successfully started", :green
80
79
  else
81
80
  api_error response
82
81
  end
82
+ rescue Exception => e
83
+ puts e.backtrace
84
+ error e.message
85
+ end
83
86
 
84
87
  end
85
88
 
@@ -92,14 +95,14 @@ module BBC
92
95
 
93
96
  stack_name = "#{options[:env]}-#{component}-#{options[:stack]}"
94
97
  data = cloudformation(component, options, false)
98
+ data['Parameters']['ImageId'] = latest_ami_for(component, options[:env])
95
99
 
96
100
  post_data = {
97
101
  'template' => data,
98
102
  'parameters' => Tools::Cloudformation::Generator.parameters(data)
99
103
  }
100
104
 
101
- @api = BBC::Cosmos::Tools::Config::API.new(config.app['api'], options[:key_path])
102
- response = @api.post sprintf(config.app['stack_update_endpoint'], options[:env], component, stack_name), JSON.pretty_generate(post_data)
105
+ response = api.post sprintf(config.app['stack_update_endpoint'], options[:env], component, stack_name), JSON.pretty_generate(post_data)
103
106
 
104
107
  if response.success?
105
108
  say "Stack update for component '#{component}' successfully started", :green
@@ -119,8 +122,7 @@ module BBC
119
122
 
120
123
  stack_name = "#{options[:env]}-#{component}-#{options[:stack]}"
121
124
 
122
- @api = BBC::Cosmos::Tools::Config::API.new(config.app['api'], options[:key_path])
123
- response = @api.post sprintf(config.app['stack_delete'], options[:env], component, stack_name), JSON.pretty_generate({})
125
+ response = api.post sprintf(config.app['stack_delete'], options[:env], component, stack_name), JSON.pretty_generate({})
124
126
 
125
127
  if response.success?
126
128
  say "Stack delete for component '#{component}' successfully started", :green
@@ -163,6 +165,12 @@ module BBC
163
165
 
164
166
  private
165
167
 
168
+ def latest_ami_for(component, env = 'int')
169
+ response = api.get sprintf(config.app['deployments'], component, env)
170
+ api_error response unless response.success?
171
+ JSON.parse(response.body).first['image']['ami_id']
172
+ end
173
+
166
174
  def cloudformation(component, options, to_json = true)
167
175
  config_data = config
168
176
 
@@ -1,7 +1,7 @@
1
1
  module BBC
2
2
  module Cosmos
3
3
  module Tools
4
- VERSION = "0.1.3"
4
+ VERSION = "0.1.4"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bbc-cosmos-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Jack
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-06 00:00:00.000000000 Z
11
+ date: 2014-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler