knife-ec2 0.5.12 → 0.5.14

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- knife-ec2 (0.5.11)
4
+ knife-ec2 (0.5.14)
5
5
  chef (>= 0.10.10)
6
6
  fog (~> 1.3)
7
7
 
@@ -9,8 +9,8 @@ GEM
9
9
  remote: http://rubygems.org/
10
10
  specs:
11
11
  builder (3.0.0)
12
- bunny (0.7.9)
13
- chef (0.10.10)
12
+ bunny (0.8.0)
13
+ chef (10.12.0)
14
14
  bunny (>= 0.6.0)
15
15
  erubis
16
16
  highline (>= 1.6.9)
@@ -19,7 +19,7 @@ GEM
19
19
  mixlib-cli (>= 1.1.0)
20
20
  mixlib-config (>= 1.1.2)
21
21
  mixlib-log (>= 1.3.0)
22
- mixlib-shellout (~> 1.0.0.rc)
22
+ mixlib-shellout
23
23
  moneta
24
24
  net-ssh (~> 2.2.2)
25
25
  net-ssh-multi (~> 1.1.0)
@@ -27,13 +27,13 @@ GEM
27
27
  rest-client (>= 1.0.4, < 1.7.0)
28
28
  treetop (~> 1.4.9)
29
29
  uuidtools
30
- yajl-ruby (>= 1.1.0)
30
+ yajl-ruby (~> 1.1)
31
31
  diff-lcs (1.1.3)
32
32
  erubis (2.7.0)
33
- excon (0.13.4)
34
- fog (1.3.1)
33
+ excon (0.14.3)
34
+ fog (1.4.0)
35
35
  builder
36
- excon (~> 0.13.0)
36
+ excon (~> 0.14.0)
37
37
  formatador (~> 0.2.0)
38
38
  mime-types
39
39
  multi_json (~> 1.0)
@@ -41,19 +41,19 @@ GEM
41
41
  net-ssh (>= 2.1.3)
42
42
  nokogiri (~> 1.5.0)
43
43
  ruby-hmac
44
- formatador (0.2.1)
45
- highline (1.6.12)
44
+ formatador (0.2.3)
45
+ highline (1.6.13)
46
46
  ipaddress (0.8.0)
47
47
  json (1.6.1)
48
- mime-types (1.18)
48
+ mime-types (1.19)
49
49
  mixlib-authentication (1.1.4)
50
50
  mixlib-log
51
51
  mixlib-cli (1.2.2)
52
52
  mixlib-config (1.1.2)
53
- mixlib-log (1.3.0)
53
+ mixlib-log (1.4.1)
54
54
  mixlib-shellout (1.0.0)
55
55
  moneta (0.6.0)
56
- multi_json (1.3.4)
56
+ multi_json (1.3.6)
57
57
  net-scp (1.0.4)
58
58
  net-ssh (>= 1.99.1)
59
59
  net-ssh (2.2.2)
@@ -62,8 +62,8 @@ GEM
62
62
  net-ssh-multi (1.1)
63
63
  net-ssh (>= 2.1.4)
64
64
  net-ssh-gateway (>= 0.99.0)
65
- nokogiri (1.5.2)
66
- ohai (0.6.12)
65
+ nokogiri (1.5.5)
66
+ ohai (6.14.0)
67
67
  ipaddress
68
68
  mixlib-cli
69
69
  mixlib-config
@@ -81,12 +81,15 @@ GEM
81
81
  rspec-expectations (2.7.0)
82
82
  diff-lcs (~> 1.1.2)
83
83
  rspec-mocks (2.7.0)
84
+ rspec_junit_formatter (0.1.1)
85
+ builder
86
+ rspec (~> 2.0)
84
87
  ruby-hmac (0.4.0)
85
- systemu (2.5.0)
88
+ systemu (2.5.2)
86
89
  treetop (1.4.10)
87
90
  polyglot
88
91
  polyglot (>= 0.3.1)
89
- uuidtools (2.1.2)
92
+ uuidtools (2.1.3)
90
93
  yajl-ruby (1.1.0)
91
94
 
92
95
  PLATFORMS
@@ -95,3 +98,7 @@ PLATFORMS
95
98
  DEPENDENCIES
96
99
  knife-ec2!
97
100
  rspec (~> 2.7.0)
101
+ rspec-core
102
+ rspec-expectations
103
+ rspec-mocks
104
+ rspec_junit_formatter
@@ -65,7 +65,7 @@ Generates instance metadata in meant to be used with Opscode's custom AMIs. This
65
65
 
66
66
  <b>PLEASE NOTE</b> - Using Opscode's custom AMIs reflect an older way of launching instances in EC2 for Chef and should be considered DEPRECATED. Leveraging this plugins's <tt>knife ec2 server create</tt> subcommands with a base AMIs directly from your Linux distribution (ie Ubuntu AMIs from Canonical) is much preferred and more flexible. Although this subcommand will remain, the Opscode custom AMIs are currently out of date.
67
67
 
68
- In-depth usage instructions can be found on the {Chef Wiki}[http://wiki.opscode.com/display/chef/Amazon+EC2+AMIs+with+Chef].
68
+ In-depth usage instructions can be found on the {Chef Wiki}[http://wiki.opscode.com/display/chef/EC2+Bootstrap+Fast+Start+Guide].
69
69
 
70
70
  = LICENSE:
71
71
 
@@ -18,5 +18,7 @@ Gem::Specification.new do |s|
18
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
19
  s.add_dependency "fog", "~> 1.3"
20
20
  s.add_dependency "chef", ">= 0.10.10"
21
+ %w(rspec-core rspec-expectations rspec-mocks rspec_junit_formatter).each { |gem| s.add_development_dependency gem }
22
+
21
23
  s.require_paths = ["lib"]
22
24
  end
@@ -67,7 +67,7 @@ class Chef
67
67
 
68
68
  def locate_config_value(key)
69
69
  key = key.to_sym
70
- Chef::Config[:knife][key] || config[key]
70
+ config[key] || Chef::Config[:knife][key]
71
71
  end
72
72
 
73
73
  def msg_pair(label, value, color=:cyan)
@@ -0,0 +1,53 @@
1
+ #
2
+ # Author:: Seth Chisamore (<schisamo@opscode.com>)
3
+ # Copyright:: Copyright (c) 2012 Opscode, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require 'chef/knife/ec2_base'
20
+
21
+ class Chef
22
+ class Knife
23
+ class Ec2FlavorList < Knife
24
+
25
+ include Knife::Ec2Base
26
+
27
+ banner "knife ec2 flavor list (options)"
28
+
29
+ def run
30
+
31
+ validate!
32
+
33
+ flavor_list = [
34
+ ui.color('ID', :bold),
35
+ ui.color('Name', :bold),
36
+ ui.color('Architecture', :bold),
37
+ ui.color('RAM', :bold),
38
+ ui.color('Disk', :bold),
39
+ ui.color('Cores', :bold)
40
+ ]
41
+ connection.flavors.sort_by(&:id).each do |flavor|
42
+ flavor_list << flavor.id.to_s
43
+ flavor_list << flavor.name
44
+ flavor_list << "#{flavor.bits.to_s}-bit"
45
+ flavor_list << "#{flavor.ram.to_s}"
46
+ flavor_list << "#{flavor.disk.to_s} GB"
47
+ flavor_list << flavor.cores.to_s
48
+ end
49
+ puts ui.list(flavor_list, :columns_across, 6)
50
+ end
51
+ end
52
+ end
53
+ end
@@ -36,6 +36,7 @@ class Chef
36
36
  banner "knife ec2 server create (options)"
37
37
 
38
38
  attr_accessor :initial_sleep_delay
39
+ attr_reader :server
39
40
 
40
41
  option :flavor,
41
42
  :short => "-f FLAVOR",
@@ -53,10 +54,15 @@ class Chef
53
54
  option :security_groups,
54
55
  :short => "-G X,Y,Z",
55
56
  :long => "--groups X,Y,Z",
56
- :description => "The security groups for this server",
57
- :default => ["default"],
57
+ :description => "The security groups for this server; not allowed when using VPC",
58
58
  :proc => Proc.new { |groups| groups.split(',') }
59
59
 
60
+ option :security_group_ids,
61
+ :short => "-g X,Y,Z",
62
+ :long => "--security-group-ids X,Y,Z",
63
+ :description => "The security group ids for this server; required when using VPC",
64
+ :proc => Proc.new { |security_group_ids| security_group_ids.split(',') }
65
+
60
66
  option :tags,
61
67
  :short => "-T T=V[,T=V,...]",
62
68
  :long => "--tags Tag=Value[,Tag=Value...]",
@@ -141,17 +147,25 @@ class Chef
141
147
  :proc => lambda { |o| o.split(/[\s,]+/) },
142
148
  :default => []
143
149
 
150
+ option :json_attributes,
151
+ :short => "-j JSON",
152
+ :long => "--json-attributes JSON",
153
+ :description => "A JSON string to be added to the first run of chef-client",
154
+ :proc => lambda { |o| JSON.parse(o) },
155
+ :default => {}
156
+
157
+
144
158
  option :subnet_id,
145
159
  :short => "-s SUBNET-ID",
146
160
  :long => "--subnet SUBNET-ID",
147
161
  :description => "create node in this Virtual Private Cloud Subnet ID (implies VPC mode)",
148
162
  :default => false
149
163
 
150
- option :no_host_key_verify,
151
- :long => "--no-host-key-verify",
152
- :description => "Disable host key verification",
164
+ option :host_key_verify,
165
+ :long => "--[no-]host-key-verify",
166
+ :description => "Verify host key, enabled by default.",
153
167
  :boolean => true,
154
- :default => false
168
+ :default => true
155
169
 
156
170
  option :aws_user_data,
157
171
  :long => "--user-data USER_DATA_FILE",
@@ -197,68 +211,81 @@ class Chef
197
211
 
198
212
  validate!
199
213
 
200
- server = connection.servers.create(create_server_def)
214
+ @server = connection.servers.create(create_server_def)
201
215
 
202
216
  hashed_tags={}
203
217
  tags.map{ |t| key,val=t.split('='); hashed_tags[key]=val} unless tags.nil?
204
218
 
205
219
  # Always set the Name tag
206
220
  unless hashed_tags.keys.include? "Name"
207
- hashed_tags["Name"] = locate_config_value(:chef_node_name) || server.id
221
+ hashed_tags["Name"] = locate_config_value(:chef_node_name) || @server.id
208
222
  end
209
223
 
210
224
  hashed_tags.each_pair do |key,val|
211
- connection.tags.create :key => key, :value => val, :resource_id => server.id
225
+ connection.tags.create :key => key, :value => val, :resource_id => @server.id
212
226
  end
213
227
 
214
- msg_pair("Instance ID", server.id)
215
- msg_pair("Flavor", server.flavor_id)
216
- msg_pair("Image", server.image_id)
228
+ msg_pair("Instance ID", @server.id)
229
+ msg_pair("Flavor", @server.flavor_id)
230
+ msg_pair("Image", @server.image_id)
217
231
  msg_pair("Region", connection.instance_variable_get(:@region))
218
- msg_pair("Availability Zone", server.availability_zone)
219
- msg_pair("Security Groups", server.groups.join(", "))
232
+ msg_pair("Availability Zone", @server.availability_zone)
233
+
234
+ # If we don't specify a security group or security group id, Fog will
235
+ # pick the appropriate default one. In case of a VPC we don't know the
236
+ # default security group id at this point unless we look it up, hence
237
+ # 'default' is printed if no id was specified.
238
+ printed_security_groups = "default"
239
+ printed_security_groups = @server.groups.join(", ") if @server.groups
240
+ msg_pair("Security Groups", printed_security_groups) unless vpc_mode? or (@server.groups.nil? and @server.security_group_ids)
241
+
242
+ printed_security_group_ids = "default"
243
+ printed_security_group_ids = @server.security_group_ids.join(", ") if @server.security_group_ids
244
+ msg_pair("Security Group Ids", printed_security_group_ids) if vpc_mode? or @server.security_group_ids
245
+
220
246
  msg_pair("Tags", hashed_tags)
221
- msg_pair("SSH Key", server.key_name)
247
+ msg_pair("SSH Key", @server.key_name)
222
248
 
223
249
  print "\n#{ui.color("Waiting for server", :magenta)}"
224
250
 
225
251
  # wait for it to be ready to do stuff
226
- server.wait_for { print "."; ready? }
252
+ @server.wait_for { print "."; ready? }
227
253
 
228
254
  puts("\n")
229
255
 
230
256
  if vpc_mode?
231
- msg_pair("Subnet ID", server.subnet_id)
257
+ msg_pair("Subnet ID", @server.subnet_id)
232
258
  else
233
- msg_pair("Public DNS Name", server.dns_name)
234
- msg_pair("Public IP Address", server.public_ip_address)
235
- msg_pair("Private DNS Name", server.private_dns_name)
259
+ msg_pair("Public DNS Name", @server.dns_name)
260
+ msg_pair("Public IP Address", @server.public_ip_address)
261
+ msg_pair("Private DNS Name", @server.private_dns_name)
236
262
  end
237
- msg_pair("Private IP Address", server.private_ip_address)
263
+ msg_pair("Private IP Address", @server.private_ip_address)
238
264
 
239
265
  print "\n#{ui.color("Waiting for sshd", :magenta)}"
240
266
 
241
- fqdn = vpc_mode? ? server.private_ip_address : server.dns_name
267
+ fqdn = vpc_mode? ? @server.private_ip_address : @server.dns_name
242
268
 
243
269
  print(".") until tcp_test_ssh(fqdn) {
244
270
  sleep @initial_sleep_delay ||= (vpc_mode? ? 40 : 10)
245
271
  puts("done")
246
272
  }
247
273
 
248
- bootstrap_for_node(server,fqdn).run
274
+ bootstrap_for_node(@server,fqdn).run
249
275
 
250
276
  puts "\n"
251
- msg_pair("Instance ID", server.id)
252
- msg_pair("Flavor", server.flavor_id)
253
- msg_pair("Image", server.image_id)
277
+ msg_pair("Instance ID", @server.id)
278
+ msg_pair("Flavor", @server.flavor_id)
279
+ msg_pair("Image", @server.image_id)
254
280
  msg_pair("Region", connection.instance_variable_get(:@region))
255
- msg_pair("Availability Zone", server.availability_zone)
256
- msg_pair("Security Groups", server.groups.join(", "))
281
+ msg_pair("Availability Zone", @server.availability_zone)
282
+ msg_pair("Security Groups", printed_security_groups) unless vpc_mode? or (@server.groups.nil? and @server.security_group_ids)
283
+ msg_pair("Security Group Ids", printed_security_group_ids) if vpc_mode? or @server.security_group_ids
257
284
  msg_pair("Tags", hashed_tags)
258
- msg_pair("SSH Key", server.key_name)
259
- msg_pair("Root Device Type", server.root_device_type)
260
- if server.root_device_type == "ebs"
261
- device_map = server.block_device_mapping.first
285
+ msg_pair("SSH Key", @server.key_name)
286
+ msg_pair("Root Device Type", @server.root_device_type)
287
+ if @server.root_device_type == "ebs"
288
+ device_map = @server.block_device_mapping.first
262
289
  msg_pair("Root Volume ID", device_map['volumeId'])
263
290
  msg_pair("Root Device Name", device_map['deviceName'])
264
291
  msg_pair("Root Device Delete on Terminate", device_map['deleteOnTermination'])
@@ -274,15 +301,16 @@ class Chef
274
301
  end
275
302
  end
276
303
  if vpc_mode?
277
- msg_pair("Subnet ID", server.subnet_id)
304
+ msg_pair("Subnet ID", @server.subnet_id)
278
305
  else
279
- msg_pair("Public DNS Name", server.dns_name)
280
- msg_pair("Public IP Address", server.public_ip_address)
281
- msg_pair("Private DNS Name", server.private_dns_name)
306
+ msg_pair("Public DNS Name", @server.dns_name)
307
+ msg_pair("Public IP Address", @server.public_ip_address)
308
+ msg_pair("Private DNS Name", @server.private_dns_name)
282
309
  end
283
- msg_pair("Private IP Address", server.private_ip_address)
310
+ msg_pair("Private IP Address", @server.private_ip_address)
284
311
  msg_pair("Environment", config[:environment] || '_default')
285
312
  msg_pair("Run List", config[:run_list].join(', '))
313
+ msg_pair("JSON Attributes",config[:json_attributes]) unless config[:json_attributes].empty?
286
314
  end
287
315
 
288
316
  def bootstrap_for_node(server,fqdn)
@@ -295,12 +323,13 @@ class Chef
295
323
  bootstrap.config[:chef_node_name] = config[:chef_node_name] || server.id
296
324
  bootstrap.config[:prerelease] = config[:prerelease]
297
325
  bootstrap.config[:bootstrap_version] = locate_config_value(:bootstrap_version)
326
+ bootstrap.config[:first_boot_attributes] = config[:json_attributes]
298
327
  bootstrap.config[:distro] = locate_config_value(:distro)
299
328
  bootstrap.config[:use_sudo] = true unless config[:ssh_user] == 'root'
300
329
  bootstrap.config[:template_file] = locate_config_value(:template_file)
301
330
  bootstrap.config[:environment] = config[:environment]
302
331
  # may be needed for vpc_mode
303
- bootstrap.config[:no_host_key_verify] = config[:no_host_key_verify]
332
+ bootstrap.config[:host_key_verify] = config[:host_key_verify]
304
333
  bootstrap
305
334
  end
306
335
 
@@ -322,6 +351,12 @@ class Chef
322
351
  ui.error("You have not provided a valid image (AMI) value. Please note the short option for this value recently changed from '-i' to '-I'.")
323
352
  exit 1
324
353
  end
354
+
355
+ if vpc_mode? and !!config[:security_groups]
356
+ ui.error("You are using a VPC, security groups specified with '-G' are not allowed, specify one or more security group ids with '-g' instead.")
357
+ exit 1
358
+ end
359
+
325
360
  end
326
361
 
327
362
  def tags
@@ -337,6 +372,7 @@ class Chef
337
372
  server_def = {
338
373
  :image_id => locate_config_value(:image),
339
374
  :groups => config[:security_groups],
375
+ :security_group_ids => config[:security_group_ids],
340
376
  :flavor_id => locate_config_value(:flavor),
341
377
  :key_name => Chef::Config[:knife][:aws_ssh_key_id],
342
378
  :availability_zone => locate_config_value(:availability_zone)
@@ -31,6 +31,8 @@ class Chef
31
31
 
32
32
  banner "knife ec2 server delete SERVER [SERVER] (options)"
33
33
 
34
+ attr_reader :server
35
+
34
36
  option :purge,
35
37
  :short => "-P",
36
38
  :long => "--purge",
@@ -65,27 +67,27 @@ class Chef
65
67
  @name_args.each do |instance_id|
66
68
 
67
69
  begin
68
- server = connection.servers.get(instance_id)
70
+ @server = connection.servers.get(instance_id)
69
71
 
70
- msg_pair("Instance ID", server.id)
71
- msg_pair("Flavor", server.flavor_id)
72
- msg_pair("Image", server.image_id)
72
+ msg_pair("Instance ID", @server.id)
73
+ msg_pair("Flavor", @server.flavor_id)
74
+ msg_pair("Image", @server.image_id)
73
75
  msg_pair("Region", connection.instance_variable_get(:@region))
74
- msg_pair("Availability Zone", server.availability_zone)
75
- msg_pair("Security Groups", server.groups.join(", "))
76
- msg_pair("SSH Key", server.key_name)
77
- msg_pair("Root Device Type", server.root_device_type)
78
- msg_pair("Public DNS Name", server.dns_name)
79
- msg_pair("Public IP Address", server.public_ip_address)
80
- msg_pair("Private DNS Name", server.private_dns_name)
81
- msg_pair("Private IP Address", server.private_ip_address)
76
+ msg_pair("Availability Zone", @server.availability_zone)
77
+ msg_pair("Security Groups", @server.groups.join(", "))
78
+ msg_pair("SSH Key", @server.key_name)
79
+ msg_pair("Root Device Type", @server.root_device_type)
80
+ msg_pair("Public DNS Name", @server.dns_name)
81
+ msg_pair("Public IP Address", @server.public_ip_address)
82
+ msg_pair("Private DNS Name", @server.private_dns_name)
83
+ msg_pair("Private IP Address", @server.private_ip_address)
82
84
 
83
85
  puts "\n"
84
86
  confirm("Do you really want to delete this server")
85
87
 
86
- server.destroy
88
+ @server.destroy
87
89
 
88
- ui.warn("Deleted server #{server.id}")
90
+ ui.warn("Deleted server #{@server.id}")
89
91
 
90
92
  if config[:purge]
91
93
  thing_to_delete = config[:chef_node_name] || instance_id
@@ -1,6 +1,6 @@
1
1
  module Knife
2
2
  module Ec2
3
- VERSION = "0.5.12"
3
+ VERSION = "0.5.14"
4
4
  MAJOR, MINOR, TINY = VERSION.split('.')
5
5
  end
6
6
  end
@@ -47,6 +47,7 @@ describe Chef::Knife::Ec2ServerCreate do
47
47
  :availability_zone => 'us-west-1',
48
48
  :key_name => 'my_ssh_key',
49
49
  :groups => ['group1', 'group2'],
50
+ :security_group_ids => ['sg-00aa11bb'],
50
51
  :dns_name => 'ec2-75.101.253.10.compute-1.amazonaws.com',
51
52
  :public_ip_address => '75.101.253.10',
52
53
  :private_dns_name => 'ip-10-251-75-20.ec2.internal',
@@ -75,6 +76,7 @@ describe Chef::Knife::Ec2ServerCreate do
75
76
  Chef::Knife::Bootstrap.stub!(:new).and_return(@bootstrap)
76
77
  @bootstrap.should_receive(:run)
77
78
  @knife_ec2_create.run
79
+ @knife_ec2_create.server.should_not == nil
78
80
  end
79
81
  end
80
82
  describe "when setting tags" do
@@ -130,6 +132,7 @@ describe Chef::Knife::Ec2ServerCreate do
130
132
  @knife_ec2_create.config[:template_file] = '~/.chef/templates/my-bootstrap.sh.erb'
131
133
  @knife_ec2_create.config[:distro] = 'ubuntu-10.04-magic-sparkles'
132
134
  @knife_ec2_create.config[:run_list] = ['role[base]']
135
+ @knife_ec2_create.config[:json_attributes] = "{'my_attributes':{'foo':'bar'}"
133
136
 
134
137
  @bootstrap = @knife_ec2_create.bootstrap_for_node(@new_ec2_server, @new_ec2_server.dns_name)
135
138
  end
@@ -138,6 +141,10 @@ describe Chef::Knife::Ec2ServerCreate do
138
141
  @bootstrap.name_args.should == ['ec2-75.101.253.10.compute-1.amazonaws.com']
139
142
  end
140
143
 
144
+ it "should set the bootstrap 'first_boot_attributes' correctly" do
145
+ @bootstrap.config[:first_boot_attributes].should == "{'my_attributes':{'foo':'bar'}"
146
+ end
147
+
141
148
  it "configures sets the bootstrap's run_list" do
142
149
  @bootstrap.config[:run_list].should == ['role[base]']
143
150
  end
@@ -187,4 +194,63 @@ describe Chef::Knife::Ec2ServerCreate do
187
194
  end
188
195
  end
189
196
 
197
+ describe "when validating the command-line parameters" do
198
+ before do
199
+ Fog::Compute::AWS.stub(:new).and_return(@ec2_connection)
200
+ @knife_ec2_create.ui.stub!(:error)
201
+ end
202
+
203
+ it "disallows security group names when using a VPC" do
204
+ @knife_ec2_create.config[:subnet_id] = 'subnet-1a2b3c4d'
205
+ @knife_ec2_create.config[:security_group_ids] = 'sg-aabbccdd'
206
+ @knife_ec2_create.config[:security_groups] = 'groupname'
207
+
208
+ lambda { @knife_ec2_create.validate! }.should raise_error SystemExit
209
+ end
210
+ end
211
+
212
+ describe "when creating the server definition" do
213
+ before do
214
+ Fog::Compute::AWS.stub(:new).and_return(@ec2_connection)
215
+ end
216
+
217
+ it "sets the specified security group names" do
218
+ @knife_ec2_create.config[:security_groups] = ['groupname']
219
+ server_def = @knife_ec2_create.create_server_def
220
+
221
+ server_def[:groups].should == ['groupname']
222
+ end
223
+
224
+ it "sets the specified security group ids" do
225
+ @knife_ec2_create.config[:security_group_ids] = ['sg-aabbccdd']
226
+ server_def = @knife_ec2_create.create_server_def
227
+
228
+ server_def[:security_group_ids].should == ['sg-aabbccdd']
229
+ end
230
+
231
+ it "sets the image id from CLI arguments over knife config" do
232
+ @knife_ec2_create.config[:image] = "ami-aaa"
233
+ Chef::Config[:knife][:image] = "ami-zzz"
234
+ server_def = @knife_ec2_create.create_server_def
235
+
236
+ server_def[:image_id].should == "ami-aaa"
237
+ end
238
+
239
+ it "sets the flavor id from CLI arguments over knife config" do
240
+ @knife_ec2_create.config[:flavor] = "massive"
241
+ Chef::Config[:knife][:flavor] = "bitty"
242
+ server_def = @knife_ec2_create.create_server_def
243
+
244
+ server_def[:flavor_id].should == "massive"
245
+ end
246
+
247
+ it "sets the availability zone from CLI arguments over knife config" do
248
+ @knife_ec2_create.config[:availability_zone] = "dis-one"
249
+ Chef::Config[:knife][:availability_zone] = "dat-one"
250
+ server_def = @knife_ec2_create.create_server_def
251
+
252
+ server_def[:availability_zone].should == "dis-one"
253
+ end
254
+ end
255
+
190
256
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-ec2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.12
4
+ version: 0.5.14
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-05-15 00:00:00.000000000Z
13
+ date: 2012-07-26 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: fog
17
- requirement: &70349127587980 !ruby/object:Gem::Requirement
17
+ requirement: !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ~>
@@ -22,10 +22,15 @@ dependencies:
22
22
  version: '1.3'
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *70349127587980
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ~>
29
+ - !ruby/object:Gem::Version
30
+ version: '1.3'
26
31
  - !ruby/object:Gem::Dependency
27
32
  name: chef
28
- requirement: &70349127587440 !ruby/object:Gem::Requirement
33
+ requirement: !ruby/object:Gem::Requirement
29
34
  none: false
30
35
  requirements:
31
36
  - - ! '>='
@@ -33,7 +38,76 @@ dependencies:
33
38
  version: 0.10.10
34
39
  type: :runtime
35
40
  prerelease: false
36
- version_requirements: *70349127587440
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: 0.10.10
47
+ - !ruby/object:Gem::Dependency
48
+ name: rspec-core
49
+ requirement: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ - !ruby/object:Gem::Dependency
64
+ name: rspec-expectations
65
+ requirement: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ type: :development
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ - !ruby/object:Gem::Dependency
80
+ name: rspec-mocks
81
+ requirement: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ! '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ type: :development
88
+ prerelease: false
89
+ version_requirements: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ! '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ - !ruby/object:Gem::Dependency
96
+ name: rspec_junit_formatter
97
+ requirement: !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ! '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ type: :development
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
37
111
  description: EC2 Support for Chef's Knife Command
38
112
  email:
39
113
  - adam@opscode.com
@@ -53,6 +127,7 @@ files:
53
127
  - Rakefile
54
128
  - knife-ec2.gemspec
55
129
  - lib/chef/knife/ec2_base.rb
130
+ - lib/chef/knife/ec2_flavor_list.rb
56
131
  - lib/chef/knife/ec2_instance_data.rb
57
132
  - lib/chef/knife/ec2_server_create.rb
58
133
  - lib/chef/knife/ec2_server_delete.rb
@@ -80,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
80
155
  version: '0'
81
156
  requirements: []
82
157
  rubyforge_project:
83
- rubygems_version: 1.8.17
158
+ rubygems_version: 1.8.23
84
159
  signing_key:
85
160
  specification_version: 3
86
161
  summary: EC2 Support for Chef's Knife Command