awspec 0.34.0 → 0.35.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f1909c7febd232e63f4f01933058887c972a174e
4
- data.tar.gz: cb3d860018b22a635823a714d05b86ae23db32b6
3
+ metadata.gz: 1708fe037ed85b50638c71a0f1120c13f4042384
4
+ data.tar.gz: b424d9466944bac4274b874d8b3199b381a6d1fd
5
5
  SHA512:
6
- metadata.gz: 9f71aa2801687ba6a5d85329fd7613e4d64ac27477daa109df26fd604b18def3103129f5f2576188665a0db7dfba1dc6412e905b58b3fd33deb89e233474959e
7
- data.tar.gz: d16c5744e51f88335da74c058c90b4fb6f55563f3766d5b27d6b1ec8f6138222875f496336dea431a53d10facca6f91b8b790a1298061a8f5120370174c2e100
6
+ metadata.gz: f977aeec94bb0afc4f0de92b06f43f57984a49f2a4558d39a8a4e7b237cda1e7e9ffb08393d0b31bc28fa71b19f15183d00964fea13032e871e712bb677ac73a
7
+ data.tar.gz: cf6ec02eb6a9b75ed66b0c24d88f4803a57eebadb15cb9e7a83a913cd98bf84b1af54e136d5410d255e900d8842498ff335945d47809d7ce3d682eb2b0a3c286
@@ -39,6 +39,22 @@ describe ec2('my-ec2') do
39
39
  end
40
40
  ```
41
41
 
42
+ ### have_event
43
+
44
+ ```ruby
45
+ describe ec2('my-ec2') do
46
+ it { should have_event('system-reboot') }
47
+ end
48
+ ```
49
+
50
+ ### have_events
51
+
52
+ ```ruby
53
+ describe ec2('my-ec2') do
54
+ it { should_not have_events }
55
+ end
56
+ ```
57
+
42
58
  ### have_security_group
43
59
 
44
60
  ```ruby
@@ -270,6 +270,24 @@ end
270
270
  ```
271
271
 
272
272
 
273
+ ### have_event
274
+
275
+ ```ruby
276
+ describe ec2('my-ec2') do
277
+ it { should have_event('system-reboot') }
278
+ end
279
+ ```
280
+
281
+
282
+ ### have_events
283
+
284
+ ```ruby
285
+ describe ec2('my-ec2') do
286
+ it { should_not have_events }
287
+ end
288
+ ```
289
+
290
+
273
291
  ### have_security_group
274
292
 
275
293
  ```ruby
@@ -4,6 +4,8 @@ require 'awspec/setup'
4
4
  module Awspec
5
5
  class Generate < Thor
6
6
  class_option :profile
7
+ class_option :region
8
+ class_option :secrets_path, default: 'secrets.yml'
7
9
 
8
10
  types = %w(
9
11
  vpc ec2 rds security_group elb network_acl route_table subnet nat_gateway
@@ -12,20 +14,20 @@ module Awspec
12
14
  types.each do |type|
13
15
  desc type + ' [vpc_id]', "Generate #{type} spec from VPC ID (or VPC \"Name\" tag)"
14
16
  define_method type do |_vpc_id|
15
- Awsecrets.load(profile: options[:profile])
17
+ Awsecrets.load(profile: options[:profile], region: options[:region], secrets_path: options[:secrets_path])
16
18
  eval "puts Awspec::Generator::Spec::#{type.camelize}.new.generate_by_vpc_id(_vpc_id)"
17
19
  end
18
20
  end
19
21
 
20
22
  desc 'route53_hosted_zone [example.com.]', 'Generate route53_hosted_zone spec from Domain name'
21
23
  def route53_hosted_zone(hosted_zone)
22
- Awsecrets.load(profile: options[:profile])
24
+ Awsecrets.load(profile: options[:profile], region: options[:region], secrets_path: options[:secrets_path])
23
25
  puts Awspec::Generator::Spec::Route53HostedZone.new.generate_by_domain_name(hosted_zone)
24
26
  end
25
27
 
26
28
  desc 's3_bucket [backet_name]', 'Generate s3_bucket spec from S3 bucket name. if NO args, Generate all.'
27
29
  def s3_bucket(bucket_name = nil)
28
- Awsecrets.load(profile: options[:profile])
30
+ Awsecrets.load(profile: options[:profile], region: options[:region], secrets_path: options[:secrets_path])
29
31
  if bucket_name
30
32
  puts Awspec::Generator::Spec::S3Bucket.new.generate(bucket_name)
31
33
  else
@@ -44,7 +46,7 @@ module Awspec
44
46
  desc type, "Generate #{type} spec"
45
47
  end
46
48
  define_method type do
47
- Awsecrets.load(profile: options[:profile])
49
+ Awsecrets.load(profile: options[:profile], region: options[:region], secrets_path: options[:secrets_path])
48
50
  eval "puts Awspec::Generator::Spec::#{type.camelize}.new.generate_all"
49
51
  end
50
52
  end
@@ -24,6 +24,13 @@ module Awspec::Helper
24
24
  })
25
25
  end
26
26
 
27
+ def find_ec2_status(id)
28
+ res = ec2_client.describe_instance_status({
29
+ instance_ids: [id]
30
+ })
31
+ res.instance_statuses.first if res.instance_statuses.count == 1
32
+ end
33
+
27
34
  # find_internet_gateway find_vpn_gateway find_customer_gateway
28
35
  gateway_types = %w(internet vpn customer)
29
36
  gateway_types.each do |type|
@@ -46,6 +46,29 @@ Aws.config[:ec2] = {
46
46
  value: true
47
47
  }
48
48
  },
49
+ describe_instance_status: {
50
+ instance_statuses: [
51
+ {
52
+ instance_id: 'i-ec12345a',
53
+ availability_zone: 'ap-northeast-1c',
54
+ events: [
55
+ {
56
+ code: 'system-reboot',
57
+ description: 'scheduled reboot'
58
+ }
59
+ ],
60
+ instance_state: {
61
+ name: 'running'
62
+ },
63
+ system_status: {
64
+ status: 'ok'
65
+ },
66
+ instance_status: {
67
+ status: 'ok'
68
+ }
69
+ }
70
+ ]
71
+ },
49
72
  describe_vpcs: {
50
73
  vpcs: [
51
74
  {
@@ -60,5 +60,17 @@ module Awspec::Type
60
60
  attachment.instance_id == @id
61
61
  end
62
62
  end
63
+
64
+ def has_event?(event_code)
65
+ status = find_ec2_status(@id)
66
+ ret = status.events.find do |event|
67
+ event.code == event_code
68
+ end
69
+ end
70
+
71
+ def has_events?
72
+ status = find_ec2_status(@id)
73
+ status.events.count > 0
74
+ end
63
75
  end
64
76
  end
@@ -1,3 +1,3 @@
1
1
  module Awspec
2
- VERSION = '0.34.0'
2
+ VERSION = '0.35.0'
3
3
  end
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.34.0
4
+ version: 0.35.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - k1LoW
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-03-07 00:00:00.000000000 Z
11
+ date: 2016-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec