knife-ec2 0.19.15 → 0.19.16
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.
- checksums.yaml +4 -4
- data/lib/knife-ec2/version.rb +1 -1
- metadata +3 -19
- data/spec/spec_helper.rb +0 -19
- data/spec/unit/ec2_ami_list_spec.rb +0 -357
- data/spec/unit/ec2_flavor_list_spec.rb +0 -84
- data/spec/unit/ec2_server_create_spec.rb +0 -2729
- data/spec/unit/ec2_server_delete_spec.rb +0 -140
- data/spec/unit/ec2_server_list_spec.rb +0 -131
- data/spec/unit/s3_source_deps_spec.rb +0 -24
- data/spec/unit/s3_source_spec.rb +0 -75
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: eca2c2f560a3a801db6f64bad73bbf766e5884164a1bc56d23afebf29911417e
|
|
4
|
+
data.tar.gz: 34897bd6689958ff49c4627ec08ae819364ba0a578b8deef0c92cb7219606a05
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 71989dcdb4ac810b423ce75684563a685dd04fed81cca49630fe01cd36bc2cc697df3b81ac262f97263fbdfb909c97a95bcdc66be25b6729373476e2e6e3df4f
|
|
7
|
+
data.tar.gz: 10c20723124e241d81ed631cda7f7e9eb324acc428cb8c4bb3252c317a993ce6195d29ade245e1ff25145a817eb4d84ac3927dfffe2573305d76eb170c4e7955
|
data/lib/knife-ec2/version.rb
CHANGED
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.19.
|
|
4
|
+
version: 0.19.16
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Adam Jacob
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2018-12-
|
|
12
|
+
date: 2018-12-11 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: fog-aws
|
|
@@ -62,14 +62,6 @@ files:
|
|
|
62
62
|
- lib/chef/knife/ec2_server_list.rb
|
|
63
63
|
- lib/chef/knife/s3_source.rb
|
|
64
64
|
- lib/knife-ec2/version.rb
|
|
65
|
-
- spec/spec_helper.rb
|
|
66
|
-
- spec/unit/ec2_ami_list_spec.rb
|
|
67
|
-
- spec/unit/ec2_flavor_list_spec.rb
|
|
68
|
-
- spec/unit/ec2_server_create_spec.rb
|
|
69
|
-
- spec/unit/ec2_server_delete_spec.rb
|
|
70
|
-
- spec/unit/ec2_server_list_spec.rb
|
|
71
|
-
- spec/unit/s3_source_deps_spec.rb
|
|
72
|
-
- spec/unit/s3_source_spec.rb
|
|
73
65
|
homepage: https://github.com/chef/knife-ec2
|
|
74
66
|
licenses:
|
|
75
67
|
- Apache-2.0
|
|
@@ -94,12 +86,4 @@ rubygems_version: 2.7.6
|
|
|
94
86
|
signing_key:
|
|
95
87
|
specification_version: 4
|
|
96
88
|
summary: Amazon EC2 Support for Chef's Knife Command
|
|
97
|
-
test_files:
|
|
98
|
-
- spec/spec_helper.rb
|
|
99
|
-
- spec/unit/ec2_ami_list_spec.rb
|
|
100
|
-
- spec/unit/ec2_flavor_list_spec.rb
|
|
101
|
-
- spec/unit/ec2_server_create_spec.rb
|
|
102
|
-
- spec/unit/ec2_server_delete_spec.rb
|
|
103
|
-
- spec/unit/ec2_server_list_spec.rb
|
|
104
|
-
- spec/unit/s3_source_deps_spec.rb
|
|
105
|
-
- spec/unit/s3_source_spec.rb
|
|
89
|
+
test_files: []
|
data/spec/spec_helper.rb
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
$:.unshift File.expand_path("../../lib", __FILE__)
|
|
2
|
-
require "chef"
|
|
3
|
-
require "chef/knife/winrm_base"
|
|
4
|
-
require "chef/knife/ec2_server_create"
|
|
5
|
-
require "chef/knife/ec2_server_delete"
|
|
6
|
-
require "chef/knife/ec2_server_list"
|
|
7
|
-
require "chef/knife/ec2_ami_list"
|
|
8
|
-
require "chef/knife/ec2_flavor_list"
|
|
9
|
-
|
|
10
|
-
# Clear config between each example
|
|
11
|
-
# to avoid dependencies between examples
|
|
12
|
-
RSpec.configure do |c|
|
|
13
|
-
c.raise_errors_for_deprecations!
|
|
14
|
-
c.filter_run_excluding exclude: true
|
|
15
|
-
c.before(:each) do
|
|
16
|
-
Chef::Config.reset
|
|
17
|
-
Chef::Config[:knife] = {}
|
|
18
|
-
end
|
|
19
|
-
end
|
|
@@ -1,357 +0,0 @@
|
|
|
1
|
-
# License:: Apache License, Version 2.0
|
|
2
|
-
#
|
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
# you may not use this file except in compliance with the License.
|
|
5
|
-
# You may obtain a copy of the License at
|
|
6
|
-
#
|
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
#
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
14
|
-
#
|
|
15
|
-
|
|
16
|
-
require File.expand_path("../../spec_helper", __FILE__)
|
|
17
|
-
require "fog/aws"
|
|
18
|
-
|
|
19
|
-
describe Chef::Knife::Ec2AmiList do
|
|
20
|
-
|
|
21
|
-
describe "#run" do
|
|
22
|
-
let(:knife_ec2_ami_list) { Chef::Knife::Ec2AmiList.new }
|
|
23
|
-
let(:ec2_connection) { double(Fog::Compute::AWS) }
|
|
24
|
-
before (:each) do
|
|
25
|
-
allow(knife_ec2_ami_list).to receive(:connection).and_return(ec2_connection)
|
|
26
|
-
@describe_images_format = double("describe_image_output", body: {
|
|
27
|
-
"imagesSet" => [{
|
|
28
|
-
"architecture" => "x86_64",
|
|
29
|
-
"blockDeviceMapping" => [{ "deviceName" => "/dev/sda1",
|
|
30
|
-
"snapshotId" => "snap-f7e645f4",
|
|
31
|
-
"volumeSize" => 30,
|
|
32
|
-
"deleteOnTermination" => "true",
|
|
33
|
-
"volumeType" => "standard",
|
|
34
|
-
"encrypted" => "false" }],
|
|
35
|
-
"description" => "window winrm",
|
|
36
|
-
"hypervisor" => "xen",
|
|
37
|
-
"imageId" => "ami-4ace6d23",
|
|
38
|
-
"imageLocation" => "microsoft/Windows_Server-2008-R2-SP1-English-64Bit-WebMatrix_Hosting-2012.06.12",
|
|
39
|
-
"imageOwnerAlias" => "microsoft",
|
|
40
|
-
"name" => "Windows_Server-2008-R2-SP1-English-64Bit-Windows_Media_Services_4.1-2012.06.12",
|
|
41
|
-
"imageOwnerId" => "461346954234",
|
|
42
|
-
"imageState" => "available",
|
|
43
|
-
"imageType" => "machine",
|
|
44
|
-
"isPublic" => true,
|
|
45
|
-
"platform" => "windows",
|
|
46
|
-
"productCodes" => [],
|
|
47
|
-
"rootDeviceName" => "/dev/sda1",
|
|
48
|
-
"rootDeviceType" => "ebs",
|
|
49
|
-
"stateReason" => {},
|
|
50
|
-
"tagSet" => {},
|
|
51
|
-
"virtualizationType" => "hvm",
|
|
52
|
-
}, {
|
|
53
|
-
"architecture" => "i386",
|
|
54
|
-
"blockDeviceMapping" => [{ "deviceName" => "/dev/sda1",
|
|
55
|
-
"snapshotId" => "snap-f7e645f4",
|
|
56
|
-
"volumeSize" => 10,
|
|
57
|
-
"deleteOnTermination" => "true",
|
|
58
|
-
"volumeType" => "standard",
|
|
59
|
-
"encrypted" => "false" }],
|
|
60
|
-
"description" => "DC for Quan",
|
|
61
|
-
"hypervisor" => "xen",
|
|
62
|
-
"imageId" => "ami-4ace6d21",
|
|
63
|
-
"imageOwnerAlias" => "aws-marketplace",
|
|
64
|
-
"name" => "ubuntu i386",
|
|
65
|
-
"imageOwnerId" => "461346954235",
|
|
66
|
-
"imageState" => "available",
|
|
67
|
-
"imageType" => "machine",
|
|
68
|
-
"isPublic" => true,
|
|
69
|
-
"productCodes" => [],
|
|
70
|
-
"rootDeviceName" => "/dev/sda1",
|
|
71
|
-
"rootDeviceType" => "ebs",
|
|
72
|
-
"stateReason" => {},
|
|
73
|
-
"tagSet" => {},
|
|
74
|
-
"virtualizationType" => "hvm",
|
|
75
|
-
}, {
|
|
76
|
-
"architecture" => "x86_64",
|
|
77
|
-
"blockDeviceMapping" => [{ "deviceName" => "/dev/sda1",
|
|
78
|
-
"snapshotId" => "snap-f7e645f4",
|
|
79
|
-
"volumeSize" => 8,
|
|
80
|
-
"deleteOnTermination" => "true",
|
|
81
|
-
"volumeType" => "standard",
|
|
82
|
-
"encrypted" => "false" }],
|
|
83
|
-
"description" => "ubuntu 14.04",
|
|
84
|
-
"hypervisor" => "xen",
|
|
85
|
-
"imageId" => "ami-4ace6d29",
|
|
86
|
-
"imageOwnerAlias" => "aws-marketplace",
|
|
87
|
-
"name" => "fedora i64",
|
|
88
|
-
"imageOwnerId" => "461346954234",
|
|
89
|
-
"imageState" => "available",
|
|
90
|
-
"imageType" => "machine",
|
|
91
|
-
"isPublic" => true,
|
|
92
|
-
"productCodes" => [],
|
|
93
|
-
"rootDeviceName" => "/dev/sda1",
|
|
94
|
-
"rootDeviceType" => "ebs",
|
|
95
|
-
"stateReason" => {},
|
|
96
|
-
"tagSet" => {},
|
|
97
|
-
"virtualizationType" => "hvm",
|
|
98
|
-
}],
|
|
99
|
-
"requestId" => "ba38c315-f1b4-4822-b336-6309bed6d50c",
|
|
100
|
-
}
|
|
101
|
-
)
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
it "invokes validate!" do
|
|
105
|
-
allow(ec2_connection).to receive(:describe_images).and_return(@describe_images_format)
|
|
106
|
-
allow(knife_ec2_ami_list.ui).to receive(:warn)
|
|
107
|
-
expect(knife_ec2_ami_list).to receive(:validate!)
|
|
108
|
-
knife_ec2_ami_list.run
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
context "when region is not specified" do
|
|
112
|
-
it "shows warning that default region will be will be used" do
|
|
113
|
-
knife_ec2_ami_list.config.delete(:region)
|
|
114
|
-
Chef::Config[:knife].delete(:region)
|
|
115
|
-
ec2_servers = double()
|
|
116
|
-
allow(ec2_connection).to receive(:describe_images).and_return(@describe_images_format)
|
|
117
|
-
allow(knife_ec2_ami_list).to receive(:validate!)
|
|
118
|
-
expect(knife_ec2_ami_list.ui).to receive(:warn).with("No region was specified in knife.rb/config.rb or as an argument. The default region, us-east-1, will be used:")
|
|
119
|
-
knife_ec2_ami_list.run
|
|
120
|
-
end
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
context "when --owner is passed" do
|
|
124
|
-
before do
|
|
125
|
-
allow(knife_ec2_ami_list.ui).to receive(:warn)
|
|
126
|
-
allow(knife_ec2_ami_list).to receive(:custom_warnings!)
|
|
127
|
-
knife_ec2_ami_list.config[:use_iam_profile] = true
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
context "When value for owner is nil" do
|
|
131
|
-
it "shows the available AMIs List" do
|
|
132
|
-
knife_ec2_ami_list.config[:owner] = nil
|
|
133
|
-
allow(ec2_connection).to receive(:describe_images).and_return(@describe_images_format)
|
|
134
|
-
expect(knife_ec2_ami_list).to receive(:validate!)
|
|
135
|
-
images = ec2_connection.describe_images.body["imagesSet"]
|
|
136
|
-
output_column = ["AMI ID", "Platform", "Architecture", "Size", "Name", "Description"]
|
|
137
|
-
output_column_count = output_column.length
|
|
138
|
-
images.each do |image|
|
|
139
|
-
output_column << image["imageId"].to_s
|
|
140
|
-
output_column << (image["platform"] ? image["platform"] : image["name"].split(/\W+/).first)
|
|
141
|
-
output_column << image["architecture"].to_s
|
|
142
|
-
output_column << image["blockDeviceMapping"].first["volumeSize"].to_s
|
|
143
|
-
output_column << image["name"].split(/\W+/).first
|
|
144
|
-
output_column << image["description"]
|
|
145
|
-
end
|
|
146
|
-
expect(knife_ec2_ami_list.ui).to receive(:list).with(output_column, :uneven_columns_across, output_column_count)
|
|
147
|
-
knife_ec2_ami_list.run
|
|
148
|
-
end
|
|
149
|
-
end
|
|
150
|
-
|
|
151
|
-
context "When value for owner is self" do
|
|
152
|
-
it "does not raise any error" do
|
|
153
|
-
knife_ec2_ami_list.config[:owner] = "self"
|
|
154
|
-
allow(ec2_connection).to receive(:describe_images).and_return(@describe_images_format)
|
|
155
|
-
expect { knife_ec2_ami_list.validate! }.not_to raise_error
|
|
156
|
-
end
|
|
157
|
-
end
|
|
158
|
-
|
|
159
|
-
context "When value for owner is microsoft" do
|
|
160
|
-
it "does not raise any error" do
|
|
161
|
-
knife_ec2_ami_list.config[:owner] = "microsoft"
|
|
162
|
-
allow(ec2_connection).to receive(:describe_images).and_return(@describe_images_format)
|
|
163
|
-
expect { knife_ec2_ami_list.validate! }.not_to raise_error
|
|
164
|
-
end
|
|
165
|
-
end
|
|
166
|
-
|
|
167
|
-
context "When value for owner is aws-marketplace" do
|
|
168
|
-
it "does not raise any error" do
|
|
169
|
-
knife_ec2_ami_list.config[:owner] = "aws-marketplace"
|
|
170
|
-
allow(ec2_connection).to receive(:describe_images).and_return(@describe_images_format)
|
|
171
|
-
expect { knife_ec2_ami_list.validate! }.not_to raise_error
|
|
172
|
-
end
|
|
173
|
-
end
|
|
174
|
-
|
|
175
|
-
context "When owner is invalid" do
|
|
176
|
-
it "raises error" do
|
|
177
|
-
knife_ec2_ami_list.config[:owner] = "xyz"
|
|
178
|
-
knife_ec2_ami_list.config[:use_iam_profile] = true
|
|
179
|
-
expect { knife_ec2_ami_list.validate! }.to raise_error "Invalid owner: #{knife_ec2_ami_list.config[:owner]}. Allowed owners are self, aws-marketplace or microsoft."
|
|
180
|
-
end
|
|
181
|
-
end
|
|
182
|
-
end
|
|
183
|
-
|
|
184
|
-
context "when --platform is passed" do
|
|
185
|
-
before do
|
|
186
|
-
allow(knife_ec2_ami_list.ui).to receive(:warn)
|
|
187
|
-
allow(knife_ec2_ami_list).to receive(:custom_warnings!)
|
|
188
|
-
end
|
|
189
|
-
|
|
190
|
-
context "When platform is nil" do
|
|
191
|
-
it "shows all the AMIs List" do
|
|
192
|
-
knife_ec2_ami_list.config[:platform] = nil
|
|
193
|
-
allow(ec2_connection).to receive(:describe_images).and_return(@describe_images_format)
|
|
194
|
-
images = ec2_connection.describe_images.body["imagesSet"]
|
|
195
|
-
expect(knife_ec2_ami_list).to receive(:validate!)
|
|
196
|
-
output_column = ["AMI ID", "Platform", "Architecture", "Size", "Name", "Description"]
|
|
197
|
-
output_column_count = output_column.length
|
|
198
|
-
images.each do |image|
|
|
199
|
-
output_column << image["imageId"].to_s
|
|
200
|
-
output_column << (image["platform"] ? image["platform"] : image["name"].split(/\W+/).first)
|
|
201
|
-
output_column << image["architecture"].to_s
|
|
202
|
-
output_column << image["blockDeviceMapping"].first["volumeSize"].to_s
|
|
203
|
-
output_column << image["name"].split(/\W+/).first
|
|
204
|
-
output_column << image["description"]
|
|
205
|
-
end
|
|
206
|
-
expect(knife_ec2_ami_list.ui).to receive(:list).with(output_column, :uneven_columns_across, output_column_count)
|
|
207
|
-
knife_ec2_ami_list.run
|
|
208
|
-
end
|
|
209
|
-
end
|
|
210
|
-
|
|
211
|
-
context "When platform is windows" do
|
|
212
|
-
it "shows only windows AMIs List" do
|
|
213
|
-
knife_ec2_ami_list.config[:platform] = "windows"
|
|
214
|
-
allow(ec2_connection).to receive(:describe_images).and_return(@describe_images_format)
|
|
215
|
-
window_image = ec2_connection.describe_images.body["imagesSet"].first
|
|
216
|
-
expect(knife_ec2_ami_list).to receive(:validate!)
|
|
217
|
-
output_column = ["AMI ID", "Platform", "Architecture", "Size", "Name", "Description"]
|
|
218
|
-
output_column_count = output_column.length
|
|
219
|
-
output_column << window_image["imageId"]
|
|
220
|
-
output_column << window_image["platform"]
|
|
221
|
-
output_column << window_image["architecture"]
|
|
222
|
-
output_column << window_image["blockDeviceMapping"].first["volumeSize"].to_s
|
|
223
|
-
output_column << window_image["name"].split(/\W+/).first
|
|
224
|
-
output_column << window_image["description"]
|
|
225
|
-
expect(knife_ec2_ami_list.ui).to receive(:list).with(output_column, :uneven_columns_across, output_column_count)
|
|
226
|
-
knife_ec2_ami_list.run
|
|
227
|
-
end
|
|
228
|
-
end
|
|
229
|
-
|
|
230
|
-
context "When platform is ubuntu" do
|
|
231
|
-
it "shows only ubuntu AMIs List" do
|
|
232
|
-
knife_ec2_ami_list.config[:platform] = "ubuntu"
|
|
233
|
-
allow(ec2_connection).to receive(:describe_images).and_return(@describe_images_format)
|
|
234
|
-
ubuntu_image = ec2_connection.describe_images.body["imagesSet"][1]
|
|
235
|
-
expect(knife_ec2_ami_list).to receive(:validate!)
|
|
236
|
-
output_column = ["AMI ID", "Platform", "Architecture", "Size", "Name", "Description"]
|
|
237
|
-
output_column_count = output_column.length
|
|
238
|
-
output_column << ubuntu_image["imageId"]
|
|
239
|
-
output_column << ubuntu_image["name"].split(/\W+/).first
|
|
240
|
-
output_column << ubuntu_image["architecture"]
|
|
241
|
-
output_column << ubuntu_image["blockDeviceMapping"].first["volumeSize"].to_s
|
|
242
|
-
output_column << ubuntu_image["name"].split(/\W+/).first
|
|
243
|
-
output_column << ubuntu_image["description"]
|
|
244
|
-
expect(knife_ec2_ami_list.ui).to receive(:list).with(output_column, :uneven_columns_across, output_column_count)
|
|
245
|
-
knife_ec2_ami_list.run
|
|
246
|
-
end
|
|
247
|
-
end
|
|
248
|
-
|
|
249
|
-
context "When platform is fedora" do
|
|
250
|
-
it "shows only fedora AMIs List" do
|
|
251
|
-
knife_ec2_ami_list.config[:platform] = "fedora"
|
|
252
|
-
allow(ec2_connection).to receive(:describe_images).and_return(@describe_images_format)
|
|
253
|
-
expect(knife_ec2_ami_list).to receive(:validate!)
|
|
254
|
-
fedora_image = ec2_connection.describe_images.body["imagesSet"].last
|
|
255
|
-
output_column = ["AMI ID", "Platform", "Architecture", "Size", "Name", "Description"]
|
|
256
|
-
output_column_count = output_column.length
|
|
257
|
-
output_column << fedora_image["imageId"]
|
|
258
|
-
output_column << fedora_image["name"].split(/\W+/).first
|
|
259
|
-
output_column << fedora_image["architecture"]
|
|
260
|
-
output_column << fedora_image["blockDeviceMapping"].first["volumeSize"].to_s
|
|
261
|
-
output_column << fedora_image["name"].split(/\W+/).first
|
|
262
|
-
output_column << fedora_image["description"]
|
|
263
|
-
expect(knife_ec2_ami_list.ui).to receive(:list).with(output_column, :uneven_columns_across, output_column_count)
|
|
264
|
-
knife_ec2_ami_list.run
|
|
265
|
-
end
|
|
266
|
-
end
|
|
267
|
-
|
|
268
|
-
context "When platform is invalid" do
|
|
269
|
-
it "raises error" do
|
|
270
|
-
knife_ec2_ami_list.config[:platform] = "xyz"
|
|
271
|
-
knife_ec2_ami_list.config[:use_iam_profile] = true
|
|
272
|
-
knife_ec2_ami_list.config[:owner] = true
|
|
273
|
-
expect { knife_ec2_ami_list.validate! }.to raise_error "Invalid platform: #{knife_ec2_ami_list.config[:platform]}. Allowed platforms are: windows, ubuntu, debian, centos, fedora, rhel, nginx, turnkey, jumpbox, coreos, cisco, amazon, nessus."
|
|
274
|
-
end
|
|
275
|
-
end
|
|
276
|
-
end
|
|
277
|
-
|
|
278
|
-
context "when --search is passed" do
|
|
279
|
-
before do
|
|
280
|
-
allow(knife_ec2_ami_list.ui).to receive(:warn)
|
|
281
|
-
allow(knife_ec2_ami_list).to receive(:custom_warnings!)
|
|
282
|
-
end
|
|
283
|
-
|
|
284
|
-
context "When search key word is present in description" do
|
|
285
|
-
it "shows only AMIs List that have 14.04 in description" do
|
|
286
|
-
knife_ec2_ami_list.config[:search] = "14.04"
|
|
287
|
-
allow(ec2_connection).to receive(:describe_images).and_return(@describe_images_format)
|
|
288
|
-
image = ec2_connection.describe_images.body["imagesSet"][2]
|
|
289
|
-
expect(knife_ec2_ami_list).to receive(:validate!)
|
|
290
|
-
output_column = ["AMI ID", "Platform", "Architecture", "Size", "Name", "Description"]
|
|
291
|
-
output_column_count = output_column.length
|
|
292
|
-
output_column << image["imageId"]
|
|
293
|
-
output_column << image["name"].split(/\W+/).first
|
|
294
|
-
output_column << image["architecture"]
|
|
295
|
-
output_column << image["blockDeviceMapping"].first["volumeSize"].to_s
|
|
296
|
-
output_column << image["name"].split(/\W+/).first
|
|
297
|
-
output_column << image["description"]
|
|
298
|
-
expect(knife_ec2_ami_list.ui).to receive(:list).with(output_column, :uneven_columns_across, output_column_count)
|
|
299
|
-
knife_ec2_ami_list.run
|
|
300
|
-
end
|
|
301
|
-
end
|
|
302
|
-
|
|
303
|
-
context "When user pass platform and search keyword" do
|
|
304
|
-
it "shows only AMIs List that have 14.04 in description and platform is ubuntu" do
|
|
305
|
-
knife_ec2_ami_list.config[:platform] = "ubuntu"
|
|
306
|
-
knife_ec2_ami_list.config[:search] = "Quan"
|
|
307
|
-
allow(ec2_connection).to receive(:describe_images).and_return(@describe_images_format)
|
|
308
|
-
ubuntu_image = ec2_connection.describe_images.body["imagesSet"][1]
|
|
309
|
-
expect(knife_ec2_ami_list).to receive(:validate!)
|
|
310
|
-
output_column = ["AMI ID", "Platform", "Architecture", "Size", "Name", "Description"]
|
|
311
|
-
output_column_count = output_column.length
|
|
312
|
-
output_column << ubuntu_image["imageId"]
|
|
313
|
-
output_column << ubuntu_image["name"].split(/\W+/).first
|
|
314
|
-
output_column << ubuntu_image["architecture"]
|
|
315
|
-
output_column << ubuntu_image["blockDeviceMapping"].first["volumeSize"].to_s
|
|
316
|
-
output_column << ubuntu_image["name"].split(/\W+/).first
|
|
317
|
-
output_column << ubuntu_image["description"]
|
|
318
|
-
expect(knife_ec2_ami_list.ui).to receive(:list).with(output_column, :uneven_columns_across, output_column_count)
|
|
319
|
-
knife_ec2_ami_list.run
|
|
320
|
-
end
|
|
321
|
-
end
|
|
322
|
-
|
|
323
|
-
context "When user pass owner, platform and search keyword" do
|
|
324
|
-
it "shows only AMIs List that owner microsoft platform windows and search keyword is winrm" do
|
|
325
|
-
knife_ec2_ami_list.config[:owner] = "microsoft"
|
|
326
|
-
knife_ec2_ami_list.config[:platform] = "windows"
|
|
327
|
-
knife_ec2_ami_list.config[:search] = "winrm"
|
|
328
|
-
allow(ec2_connection).to receive(:describe_images).and_return(@describe_images_format)
|
|
329
|
-
ubuntu_image = ec2_connection.describe_images.body["imagesSet"].first
|
|
330
|
-
expect(knife_ec2_ami_list).to receive(:validate!)
|
|
331
|
-
output_column = ["AMI ID", "Platform", "Architecture", "Size", "Name", "Description"]
|
|
332
|
-
output_column_count = output_column.length
|
|
333
|
-
output_column << ubuntu_image["imageId"]
|
|
334
|
-
output_column << ubuntu_image["platform"]
|
|
335
|
-
output_column << ubuntu_image["architecture"]
|
|
336
|
-
output_column << ubuntu_image["blockDeviceMapping"].first["volumeSize"].to_s
|
|
337
|
-
output_column << ubuntu_image["name"].split(/\W+/).first
|
|
338
|
-
output_column << ubuntu_image["description"]
|
|
339
|
-
expect(knife_ec2_ami_list.ui).to receive(:list).with(output_column, :uneven_columns_across, output_column_count)
|
|
340
|
-
knife_ec2_ami_list.run
|
|
341
|
-
end
|
|
342
|
-
end
|
|
343
|
-
|
|
344
|
-
context "When search key word is not present in description" do
|
|
345
|
-
it "Fetch no AMI" do
|
|
346
|
-
knife_ec2_ami_list.config[:search] = "Not present"
|
|
347
|
-
allow(ec2_connection).to receive(:describe_images).and_return(@describe_images_format)
|
|
348
|
-
expect(knife_ec2_ami_list).to receive(:validate!)
|
|
349
|
-
output_column = ["AMI ID", "Platform", "Architecture", "Size", "Name", "Description"]
|
|
350
|
-
output_column_count = output_column.length
|
|
351
|
-
expect(knife_ec2_ami_list.ui).to receive(:list).with(output_column, :uneven_columns_across, output_column_count)
|
|
352
|
-
knife_ec2_ami_list.run
|
|
353
|
-
end
|
|
354
|
-
end
|
|
355
|
-
end
|
|
356
|
-
end
|
|
357
|
-
end
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
# License:: Apache License, Version 2.0
|
|
2
|
-
#
|
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
# you may not use this file except in compliance with the License.
|
|
5
|
-
# You may obtain a copy of the License at
|
|
6
|
-
#
|
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
#
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
14
|
-
#
|
|
15
|
-
|
|
16
|
-
require File.expand_path("../../spec_helper", __FILE__)
|
|
17
|
-
require "fog/aws"
|
|
18
|
-
|
|
19
|
-
describe Chef::Knife::Ec2FlavorList do
|
|
20
|
-
|
|
21
|
-
describe "#run" do
|
|
22
|
-
let(:knife_flavor_list) { Chef::Knife::Ec2FlavorList.new }
|
|
23
|
-
let(:ec2_connection) { double(Fog::Compute::AWS) }
|
|
24
|
-
before do
|
|
25
|
-
allow(knife_flavor_list).to receive(:connection).and_return(ec2_connection)
|
|
26
|
-
@flavor1 = double("flavor1", name: "High-CPU Medium", architecture: "32", id: "c1.medium", bits: "32", cores: "5", ram: "1740.8", disk: "350", ebs_optimized_available: "false", instance_store_volumes: "0")
|
|
27
|
-
|
|
28
|
-
allow(ec2_connection).to receive(:flavors).and_return([@flavor1])
|
|
29
|
-
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
it "invokes validate!" do
|
|
33
|
-
ec2_flavors = double(sort_by: [])
|
|
34
|
-
|
|
35
|
-
allow(ec2_connection).to receive(:flavors).and_return(ec2_flavors)
|
|
36
|
-
allow(knife_flavor_list.ui).to receive(:warn)
|
|
37
|
-
expect(knife_flavor_list).to receive(:validate!)
|
|
38
|
-
knife_flavor_list.run
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
context "when region is not specified" do
|
|
42
|
-
it "shows warning that default region will be will be used" do
|
|
43
|
-
knife_flavor_list.config.delete(:region)
|
|
44
|
-
Chef::Config[:knife].delete(:region)
|
|
45
|
-
ec2_flavors = double(sort_by: [])
|
|
46
|
-
allow(ec2_connection).to receive(:flavors).and_return(ec2_flavors)
|
|
47
|
-
allow(knife_flavor_list).to receive(:validate!)
|
|
48
|
-
expect(knife_flavor_list.ui).to receive(:warn).with("No region was specified in knife.rb/config.rb or as an argument. The default region, us-east-1, will be used:")
|
|
49
|
-
knife_flavor_list.run
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
context "--format option" do
|
|
54
|
-
context "when format=summary" do
|
|
55
|
-
before do
|
|
56
|
-
@output_s = ["ID", "Name", "Architecture", "RAM", "Disk", "Cores", "c1.medium", "High-CPU Medium", "32-bit", "1740.8", "350 GB", "5"]
|
|
57
|
-
knife_flavor_list.config[:format] = "summary"
|
|
58
|
-
allow(knife_flavor_list.ui).to receive(:warn)
|
|
59
|
-
allow(knife_flavor_list).to receive(:validate!)
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
it "shows the output in summary format" do
|
|
63
|
-
expect(knife_flavor_list.ui).to receive(:list).with(@output_s, :uneven_columns_across, 6)
|
|
64
|
-
knife_flavor_list.run
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
context "when format=json" do
|
|
69
|
-
before do
|
|
70
|
-
knife_flavor_list.config[:format] = "json"
|
|
71
|
-
allow(knife_flavor_list.ui).to receive(:warn)
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
it "shows the output in json format" do
|
|
75
|
-
allow(ec2_connection).to receive(:flavors).and_return([])
|
|
76
|
-
allow(knife_flavor_list).to receive(:validate!)
|
|
77
|
-
allow(knife_flavor_list).to receive(:format_for_display)
|
|
78
|
-
expect(knife_flavor_list).to receive(:output)
|
|
79
|
-
knife_flavor_list.run
|
|
80
|
-
end
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
end
|