sport_ngin_aws_auditor 3.10.0 → 3.10.1

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: 17745ae35107bce99406b1270ca64d8f9f81a403
4
- data.tar.gz: 06ceb2d5d68b6f716e0dfdfd0e8030d7aaabc855
3
+ metadata.gz: 5240cf6426681a9d75f9a357c7912adb58b00d81
4
+ data.tar.gz: 09c2971243df4a8bb6998d65a9c101bf3eeb7566
5
5
  SHA512:
6
- metadata.gz: eb20a8082e473c2255f3d3644c656a0922220ed4ce0b554f910b0f027ee0a680da08cff6fe98c42e660789d19e427e7041c57b5f7512202642aabefc2aaf3a0a
7
- data.tar.gz: e94b7838fbcb173e27d36a43602105de44064f89ea7fb388361568f54919be2c8dda0541ba468b6eb725120f147bcb06d3b7ac427c383ebb35f50283073761bf
6
+ metadata.gz: 82c3810457541106a45e05f874227eff17b6d5ea4b8421aad5c1a0baa40a3c2768ca3eeecd584e4248c126a026f12d5d41187ae137ec7b6fa79f9d1c896bef91
7
+ data.tar.gz: 246ff9987a1af7b769ad8df4dcb7e19ad13b020143532872593a11b95620eefcfe21d9ca20fe0a8f829a1525d9bf27f5816b2a9bff0cb4c97a3863cfded4f41c
data/CHANGELOG.markdown CHANGED
@@ -1,3 +1,8 @@
1
+ #### v3.10.1
2
+ * Caching should not affect RI counts between runs
3
+
4
+ > Emma Sax: Andy Fleener, Unknown User: https://github.com/sportngin/sport_ngin_aws_auditor/pull/25
5
+
1
6
  #### v3.10.0
2
7
  * Handling region-based RIs
3
8
 
@@ -60,7 +60,7 @@ module SportNginAwsAuditor
60
60
  private :get_more_info
61
61
  end
62
62
 
63
- attr_accessor :id, :name, :platform, :availability_zone, :scope, :instance_type, :count, :stack_name, :tag_value, :tag_reason, :expiration_date
63
+ attr_accessor :id, :name, :platform, :availability_zone, :scope, :instance_type, :count, :stack_name, :tag_value, :tag_reason, :expiration_date, :count_remaining
64
64
  def initialize(ec2_instance, tag_name, count=1)
65
65
  if ec2_instance.class.to_s == "Aws::EC2::Types::ReservedInstances"
66
66
  self.id = ec2_instance.reserved_instances_id
@@ -55,6 +55,8 @@ module SportNginAwsAuditor
55
55
 
56
56
  def apply_region_ris(ris_region, differences)
57
57
  ris_region.each do |ri|
58
+ ri.count_remaining = ri.count
59
+
58
60
  differences.each do |key, value|
59
61
  # if key = 'Linux VPC us-east-1a t2.medium'...
60
62
  my_match = key.match(/(\w*\s*\w*\s*)\w{2}-\w{2,}-\w{2}(\s*\S*)/)
@@ -68,16 +70,17 @@ module SportNginAwsAuditor
68
70
  size[0] = ''
69
71
 
70
72
  if (platform == ri.platform) && (size == ri.instance_type) && (value[:count] < 0)
71
- until (ri.count == 0) || (value[:count] == 0)
73
+ until (ri.count_remaining == 0) || (value[:count] == 0)
72
74
  value[:count] = value[:count] + 1
73
- ri.count = ri.count - 1
75
+ ri.count_remaining = ri.count_remaining - 1
74
76
  end
75
77
  end
76
78
  end
77
79
  end
78
80
 
79
81
  ris_region.each do |ri|
80
- differences[ri.to_s] = {:count => ri.count, :region_based => true}
82
+ differences[ri.to_s] = {:count => ri.count_remaining, :region_based => true}
83
+ ri.count_remaining = nil
81
84
  end
82
85
  end
83
86
 
@@ -1,3 +1,3 @@
1
1
  module SportNginAwsAuditor
2
- VERSION = "3.10.0"
2
+ VERSION = "3.10.1"
3
3
  end
@@ -12,7 +12,8 @@ module SportNginAwsAuditor
12
12
  tags: nil,
13
13
  class: "Aws::EC2::Types::Instance",
14
14
  key_name: 'Example-instance-01',
15
- availability_zone: 'us-east-1b')
15
+ availability_zone: 'us-east-1b',
16
+ count_remaining: nil)
16
17
  @ec2_instance2 = double('ec2_instance', instance_id: "i-thisisfake",
17
18
  instance_type: "t2.medium",
18
19
  vpc_id: "vpc-alsofake",
@@ -22,7 +23,8 @@ module SportNginAwsAuditor
22
23
  tags: nil,
23
24
  class: "Aws::EC2::Types::Instance",
24
25
  key_name: 'Example-instance-02',
25
- availability_zone: 'us-east-1b')
26
+ availability_zone: 'us-east-1b',
27
+ count_remaining: nil)
26
28
  @reserved_ec2_instance1 = double('reserved_ec2_instance', reserved_instances_id: "12345-dfas-1234-asdf-thisisalsofake",
27
29
  instance_type: "t2.small",
28
30
  product_description: "Linux/UNIX (Amazon VPC)",
@@ -30,7 +32,8 @@ module SportNginAwsAuditor
30
32
  availability_zone: "us-east-1b",
31
33
  instance_count: 2,
32
34
  scope: 'Availability Zone',
33
- class: "Aws::EC2::Types::ReservedInstances")
35
+ class: "Aws::EC2::Types::ReservedInstances",
36
+ count_remaining: nil)
34
37
  @reserved_ec2_instance2 = double('reserved_ec2_instance', reserved_instances_id: "12345-dfas-1234-asdf-thisisfake!!",
35
38
  instance_type: "t2.medium",
36
39
  product_description: "Windows",
@@ -38,7 +41,8 @@ module SportNginAwsAuditor
38
41
  availability_zone: "us-east-1b",
39
42
  instance_count: 4,
40
43
  scope: 'Availability Zone',
41
- class: "Aws::EC2::Types::ReservedInstances")
44
+ class: "Aws::EC2::Types::ReservedInstances",
45
+ count_remaining: nil)
42
46
  @region_reserved_ec2_instance1 = double('reserved_ec2_instance', reserved_instances_id: "12345-dfas-1234-asdf-thisisalsofake",
43
47
  instance_type: "t2.small",
44
48
  product_description: "Linux/UNIX (Amazon VPC)",
@@ -46,7 +50,8 @@ module SportNginAwsAuditor
46
50
  availability_zone: nil,
47
51
  instance_count: 2,
48
52
  scope: 'Region',
49
- class: "Aws::EC2::Types::ReservedInstances")
53
+ class: "Aws::EC2::Types::ReservedInstances",
54
+ count_remaining: nil)
50
55
  @region_reserved_ec2_instance2 = double('reserved_ec2_instance', reserved_instances_id: "12345-dfas-1234-asdf-thisisfake!!",
51
56
  instance_type: "t2.medium",
52
57
  product_description: "Windows",
@@ -54,7 +59,8 @@ module SportNginAwsAuditor
54
59
  availability_zone: nil,
55
60
  instance_count: 4,
56
61
  scope: 'Region',
57
- class: "Aws::EC2::Types::ReservedInstances")
62
+ class: "Aws::EC2::Types::ReservedInstances",
63
+ count_remaining: nil)
58
64
  @ec2_instances = [@ec2_instance1, @ec2_instance2]
59
65
  @reserved_instances = [@reserved_ec2_instance2, @reserved_ec2_instance1]
60
66
  @region_reserved_instances = [@region_reserved_ec2_instance2, @region_reserved_ec2_instance1]
@@ -84,6 +90,10 @@ module SportNginAwsAuditor
84
90
  allow(@region_reserved_ec2_instance2).to receive(:count).and_return(4)
85
91
  allow(@region_reserved_ec2_instance1).to receive(:to_s).and_return('Linux VPC t2.small')
86
92
  allow(@region_reserved_ec2_instance2).to receive(:to_s).and_return('Windows t2.medium')
93
+ allow(@region_reserved_ec2_instance1).to receive(:count_remaining).and_return(2)
94
+ allow(@region_reserved_ec2_instance2).to receive(:count_remaining).and_return(2)
95
+ allow(@region_reserved_ec2_instance1).to receive(:count_remaining=).and_return(2)
96
+ allow(@region_reserved_ec2_instance2).to receive(:count_remaining=).and_return(2)
87
97
  end
88
98
 
89
99
  context '#instance_count_hash' do
@@ -120,7 +130,7 @@ module SportNginAwsAuditor
120
130
  end
121
131
  result = klass.apply_region_ris(@region_reserved_instances, differences)
122
132
  expect(differences).to eq({"Linux VPC us-east-1b t2.small"=>{count: 0, region_based: false}, "Windows us-east-1b t2.medium"=>{count: 0, region_based: false},
123
- "Linux VPC t2.small" => {count: 2, region_based: true}, "Windows t2.medium" => {count: 4, region_based: true}})
133
+ "Linux VPC t2.small" => {count: 2, region_based: true}, "Windows t2.medium" => {count: 2, region_based: true}})
124
134
  end
125
135
 
126
136
  it 'should factor in the region based RIs into the counting when there are no zone specific RIs' do
@@ -132,7 +142,7 @@ module SportNginAwsAuditor
132
142
  instance_hash = klass.instance_count_hash(@ec2_instances)
133
143
  result = klass.apply_region_ris(@region_reserved_instances, instance_hash)
134
144
  expect(instance_hash).to eq({"Linux VPC us-east-1b t2.small"=>{count: 0, region_based: false}, "Windows us-east-1b t2.medium"=>{count: 5, region_based: false},
135
- "Linux VPC t2.small" => {count: 2, region_based: true}, "Windows t2.medium" => {count: 4, region_based: true}})
145
+ "Linux VPC t2.small" => {count: 2, region_based: true}, "Windows t2.medium" => {count: 2, region_based: true}})
136
146
  end
137
147
  end
138
148
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sport_ngin_aws_auditor
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.10.0
4
+ version: 3.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elliot Hursh
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-11-15 00:00:00.000000000 Z
13
+ date: 2016-12-02 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: aws-sdk