awspec 0.66.0 → 0.66.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/doc/_resource_types/ec2.md +10 -0
- data/doc/resource_types.md +15 -4
- data/lib/awspec/generator/doc/type/base.rb +1 -1
- data/lib/awspec/generator/spec/ec2.rb +4 -0
- data/lib/awspec/helper/finder/ec2.rb +7 -0
- data/lib/awspec/matcher.rb +1 -0
- data/lib/awspec/matcher/have_network_interface.rb +15 -0
- data/lib/awspec/stub/ec2.rb +67 -0
- data/lib/awspec/stub/network_interface.rb +1 -1
- data/lib/awspec/type/ec2.rb +9 -0
- data/lib/awspec/type/network_interface.rb +3 -3
- data/lib/awspec/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7bfc427b5c45404f29d5b083a2677fddfbcb3436
|
4
|
+
data.tar.gz: 3fb322b83f4f0eae316f3f3ffdc26e9f1c19e746
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9134db801d2643c9ad4101ef3f27e06bc6f2a402c7e35e0e85a98ad8d384240d7e36c08219e8e3031e73c089561b3b9ac1ca75e7d5bbd80727d963de197bc48c
|
7
|
+
data.tar.gz: 03894ab2663220cc3561c58308de62ccc7dbbd9acf3516ca07f3a673775ffaf3fb6defeebaddbc21ffdd159054cb2c7b86538390c0285bbc43a4e17ec6efdec5
|
data/doc/_resource_types/ec2.md
CHANGED
@@ -72,6 +72,16 @@ describe ec2('my-ec2') do
|
|
72
72
|
end
|
73
73
|
```
|
74
74
|
|
75
|
+
### have_network_interface
|
76
|
+
|
77
|
+
```ruby
|
78
|
+
describe ec2('my-ec2') do
|
79
|
+
it { should have_network_interface('my-eni') }
|
80
|
+
it { should have_network_interface('eni-12ab3cde') }
|
81
|
+
it { should have_network_interface('my-eni').as_eth0 }
|
82
|
+
end
|
83
|
+
```
|
84
|
+
|
75
85
|
### have_security_group
|
76
86
|
|
77
87
|
```ruby
|
data/doc/resource_types.md
CHANGED
@@ -411,6 +411,17 @@ end
|
|
411
411
|
```
|
412
412
|
|
413
413
|
|
414
|
+
### have_network_interface
|
415
|
+
|
416
|
+
```ruby
|
417
|
+
describe ec2('my-ec2') do
|
418
|
+
it { should have_network_interface('my-eni') }
|
419
|
+
it { should have_network_interface('eni-12ab3cde') }
|
420
|
+
it { should have_network_interface('my-eni').as_eth0 }
|
421
|
+
end
|
422
|
+
```
|
423
|
+
|
424
|
+
|
414
425
|
### have_security_group
|
415
426
|
|
416
427
|
```ruby
|
@@ -476,7 +487,7 @@ EcrRepository resource type.
|
|
476
487
|
### exist
|
477
488
|
|
478
489
|
|
479
|
-
## <a name="
|
490
|
+
## <a name="ecs_cluster">ecs_cluster</a>
|
480
491
|
|
481
492
|
ECS Cluster resource type.
|
482
493
|
|
@@ -507,7 +518,7 @@ end
|
|
507
518
|
```
|
508
519
|
|
509
520
|
### its(:cluster_arn), its(:cluster_name), its(:status), its(:registered_container_instances_count), its(:running_tasks_count), its(:pending_tasks_count), its(:active_services_count)
|
510
|
-
## <a name="
|
521
|
+
## <a name="ecs_container_instance">ecs_container_instance</a>
|
511
522
|
|
512
523
|
ECS Container Instance resource type.
|
513
524
|
|
@@ -532,7 +543,7 @@ end
|
|
532
543
|
|
533
544
|
|
534
545
|
### its(:container_instance_arn), its(:ec2_instance_id), its(:version), its(:version_info), its(:status), its(:agent_connected), its(:running_tasks_count), its(:pending_tasks_count), its(:agent_update_status), its(:attributes)
|
535
|
-
## <a name="
|
546
|
+
## <a name="ecs_service">ecs_service</a>
|
536
547
|
|
537
548
|
ECS Service resource type.
|
538
549
|
|
@@ -554,7 +565,7 @@ end
|
|
554
565
|
```
|
555
566
|
|
556
567
|
### its(:service_arn), its(:service_name), its(:cluster_arn), its(:status), its(:desired_count), its(:running_count), its(:pending_count), its(:task_definition), its(:role_arn), its(:created_at), its(:placement_constraints), its(:placement_strategy)
|
557
|
-
## <a name="
|
568
|
+
## <a name="ecs_task_definition">ecs_task_definition</a>
|
558
569
|
|
559
570
|
ECS Task Definition resource type.
|
560
571
|
|
@@ -56,7 +56,7 @@ module Awspec::Generator
|
|
56
56
|
|
57
57
|
def doc_template
|
58
58
|
template = <<-'EOF'
|
59
|
-
## <a name="<%= @type_name.underscore %>"><%= @type_name.underscore %></a>
|
59
|
+
## <a name="<%= @type_name.gsub(/ /, '_').underscore %>"><%= @type_name.gsub(/ /, '_').underscore %></a>
|
60
60
|
|
61
61
|
<%= @type_name %> resource type.
|
62
62
|
<%- if @descriptions.include?('first') -%><%= @descriptions['first'] %><%- end -%>
|
@@ -18,6 +18,7 @@ module Awspec::Generator
|
|
18
18
|
subnet = find_subnet(instance.subnet_id)
|
19
19
|
eips = select_eip_by_instance_id(instance_id)
|
20
20
|
volumes = select_ebs_by_instance_id(instance_id)
|
21
|
+
network_interfaces = select_network_interface_by_instance_id(instance_id)
|
21
22
|
content = ERB.new(ec2_spec_template, nil, '-').result(binding).gsub(/^\n/, '')
|
22
23
|
end
|
23
24
|
specs.join("\n")
|
@@ -65,6 +66,9 @@ describe ec2('<%= instance_id %>') do
|
|
65
66
|
it { should have_ebs('<%= volume.volume_id %>') }
|
66
67
|
<%- end -%>
|
67
68
|
<% end %>
|
69
|
+
<% network_interfaces.each do |interface| %>
|
70
|
+
it { should have_network_interface('<%= interface.network_interface_id %>') }
|
71
|
+
<% end %>
|
68
72
|
end
|
69
73
|
EOF
|
70
74
|
template
|
@@ -109,6 +109,13 @@ module Awspec::Helper
|
|
109
109
|
res.addresses
|
110
110
|
end
|
111
111
|
|
112
|
+
def select_network_interface_by_instance_id(id)
|
113
|
+
res = ec2_client.describe_network_interfaces({
|
114
|
+
filters: [{ name: 'attachment.instance-id', values: [id] }]
|
115
|
+
})
|
116
|
+
res.network_interfaces
|
117
|
+
end
|
118
|
+
|
112
119
|
def select_nat_gateway_by_vpc_id(vpc_id)
|
113
120
|
res = ec2_client.describe_nat_gateways({
|
114
121
|
filter: [{ name: 'vpc-id', values: [vpc_id] }]
|
data/lib/awspec/matcher.rb
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
RSpec::Matchers.define :have_network_interface do |network_interface_id|
|
2
|
+
match do |type|
|
3
|
+
type.has_network_interface?(network_interface_id, @device_index)
|
4
|
+
end
|
5
|
+
|
6
|
+
chain :device_index do |device_index|
|
7
|
+
@device_index = device_index
|
8
|
+
end
|
9
|
+
|
10
|
+
(0..10).each do |idx|
|
11
|
+
chain "as_eth#{idx}".to_sym do
|
12
|
+
@device_index = idx
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/awspec/stub/ec2.rb
CHANGED
@@ -29,6 +29,16 @@ Aws.config[:ec2] = {
|
|
29
29
|
}
|
30
30
|
}
|
31
31
|
],
|
32
|
+
network_interfaces: [
|
33
|
+
{
|
34
|
+
network_interface_id: 'eni-12ab3cde',
|
35
|
+
subnet_id: 'subnet-1234a567',
|
36
|
+
vpc_id: 'vpc-ab123cde',
|
37
|
+
attachment: {
|
38
|
+
device_index: 1
|
39
|
+
}
|
40
|
+
}
|
41
|
+
],
|
32
42
|
tags: [
|
33
43
|
{
|
34
44
|
key: 'Name',
|
@@ -151,6 +161,63 @@ Aws.config[:ec2] = {
|
|
151
161
|
{ group_name: 'my-vpc-security-group-name', group_id: nil }
|
152
162
|
]
|
153
163
|
]
|
164
|
+
},
|
165
|
+
describe_network_interfaces: {
|
166
|
+
network_interfaces: [
|
167
|
+
{
|
168
|
+
network_interface_id: 'eni-12ab3cde',
|
169
|
+
subnet_id: 'subnet-1234a567',
|
170
|
+
vpc_id: 'vpc-ab123cde',
|
171
|
+
availability_zone: 'ap-northeast-1c',
|
172
|
+
description: '',
|
173
|
+
owner_id: '1234567890',
|
174
|
+
requester_id: nil,
|
175
|
+
requester_managed: false,
|
176
|
+
status: 'in-use',
|
177
|
+
mac_address: '00:11:aa:bb:cc:22',
|
178
|
+
private_ip_address: '10.0.1.1',
|
179
|
+
private_dns_name: nil,
|
180
|
+
source_dest_check: true,
|
181
|
+
groups:
|
182
|
+
[
|
183
|
+
{
|
184
|
+
group_name: 'my-security-group-name',
|
185
|
+
group_id: 'sg-1a2b3cd4'
|
186
|
+
}
|
187
|
+
],
|
188
|
+
attachment: {
|
189
|
+
attachment_id: 'eni-attach-12ab3cde',
|
190
|
+
instance_id: 'i-ec12345a',
|
191
|
+
instance_owner_id: '1234567890',
|
192
|
+
device_index: 0,
|
193
|
+
status: 'attached',
|
194
|
+
attach_time: nil,
|
195
|
+
delete_on_termination: true
|
196
|
+
},
|
197
|
+
association: nil,
|
198
|
+
tag_set: [
|
199
|
+
{
|
200
|
+
key: 'Name',
|
201
|
+
value: 'my-eni'
|
202
|
+
}
|
203
|
+
],
|
204
|
+
private_ip_addresses: [
|
205
|
+
{
|
206
|
+
private_ip_address: '10.0.1.1',
|
207
|
+
private_dns_name: nil,
|
208
|
+
primary: true,
|
209
|
+
association: nil
|
210
|
+
},
|
211
|
+
{
|
212
|
+
private_ip_address: '10.0.1.2',
|
213
|
+
private_dns_name: '',
|
214
|
+
primary: false,
|
215
|
+
association: nil
|
216
|
+
}
|
217
|
+
],
|
218
|
+
interface_type: nil
|
219
|
+
}
|
220
|
+
]
|
154
221
|
}
|
155
222
|
}
|
156
223
|
}
|
data/lib/awspec/type/ec2.rb
CHANGED
@@ -68,6 +68,15 @@ module Awspec::Type
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
+
def has_network_interface?(network_interface_id, device_index = nil)
|
72
|
+
res = find_network_interface(network_interface_id)
|
73
|
+
interfaces = resource_via_client.network_interfaces
|
74
|
+
ret = interfaces.find do |interface|
|
75
|
+
next false if device_index && interface.attachment.device_index != device_index
|
76
|
+
interface.network_interface_id == res.network_interface_id
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
71
80
|
def has_event?(event_code)
|
72
81
|
status = find_ec2_status(id)
|
73
82
|
ret = status.events.find do |event|
|
@@ -20,13 +20,13 @@ module Awspec::Type
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
def attached_to?(instance_id, device_index =
|
23
|
+
def attached_to?(instance_id, device_index = nil)
|
24
24
|
instance = find_ec2(instance_id)
|
25
25
|
return false unless instance
|
26
26
|
return false unless resource_via_client.attachment
|
27
|
+
return false if device_index && resource_via_client.attachment.device_index != device_index
|
27
28
|
resource_via_client.attachment.instance_id == instance.instance_id && \
|
28
|
-
resource_via_client.attachment.status == 'attached'
|
29
|
-
resource_via_client.attachment.device_index == device_index
|
29
|
+
resource_via_client.attachment.status == 'attached'
|
30
30
|
end
|
31
31
|
|
32
32
|
def has_private_ip_address?(ip_address, primary = nil)
|
data/lib/awspec/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: awspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.66.
|
4
|
+
version: 0.66.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- k1LoW
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-02-
|
11
|
+
date: 2017-02-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -380,6 +380,7 @@ files:
|
|
380
380
|
- lib/awspec/matcher/belong_to_vpc.rb
|
381
381
|
- lib/awspec/matcher/have_inline_policy.rb
|
382
382
|
- lib/awspec/matcher/have_key_policy.rb
|
383
|
+
- lib/awspec/matcher/have_network_interface.rb
|
383
384
|
- lib/awspec/matcher/have_origin.rb
|
384
385
|
- lib/awspec/matcher/have_private_ip_address.rb
|
385
386
|
- lib/awspec/matcher/have_record_set.rb
|