fog-aws 0.9.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fog/aws/auto_scaling.rb +2 -0
- data/lib/fog/aws/models/auto_scaling/group.rb +12 -0
- data/lib/fog/aws/requests/auto_scaling/attach_instances.rb +60 -0
- data/lib/fog/aws/requests/auto_scaling/detach_instances.rb +69 -0
- data/lib/fog/aws/version.rb +1 -1
- data/tests/requests/auto_scaling/auto_scaling_tests.rb +9 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a3fe2205326df34b806ce5c7d47829ce70f0d5b
|
4
|
+
data.tar.gz: 40bdef0a30eb0a7aeda1f17eea835246582b1e79
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ae069b0e407eec780b4f21bddd5a33c47f63008ad4a768faf126668d445006d15508b98a257da98bc992bf07d644bd028b0a1d71a406eb0219349023ed3c908
|
7
|
+
data.tar.gz: ab88e76d662b5f7a4e5cc20fad2482bf8e374623e038b79c3df01a6156c0086c40e84760c7b3a8eba1f8211484949672659d68c122c8a9cc50a29a0a1cbad545
|
data/lib/fog/aws/auto_scaling.rb
CHANGED
@@ -35,6 +35,8 @@ module Fog
|
|
35
35
|
request :describe_tags
|
36
36
|
request :describe_termination_policy_types
|
37
37
|
request :detach_load_balancers
|
38
|
+
request :detach_instances
|
39
|
+
request :attach_instances
|
38
40
|
request :disable_metrics_collection
|
39
41
|
request :enable_metrics_collection
|
40
42
|
request :execute_policy
|
@@ -61,6 +61,18 @@ module Fog
|
|
61
61
|
reload
|
62
62
|
end
|
63
63
|
|
64
|
+
def detach_instances(*instance_ids)
|
65
|
+
requires :id
|
66
|
+
service.detach_instances(id, 'InstanceIds' => instance_ids)
|
67
|
+
reload
|
68
|
+
end
|
69
|
+
|
70
|
+
def attach_instances(*instance_ids)
|
71
|
+
requires :id
|
72
|
+
service.attach_instances(id, 'InstanceIds' => instance_ids)
|
73
|
+
reload
|
74
|
+
end
|
75
|
+
|
64
76
|
def disable_metrics_collection(metrics = {})
|
65
77
|
requires :id
|
66
78
|
service.disable_metrics_collection(id, 'Metrics' => metrics)
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module Fog
|
2
|
+
module AWS
|
3
|
+
class AutoScaling
|
4
|
+
class Real
|
5
|
+
require 'fog/aws/parsers/auto_scaling/basic'
|
6
|
+
|
7
|
+
# Removes one or more instances from the specified Auto Scaling group.
|
8
|
+
#
|
9
|
+
# cli equiv:
|
10
|
+
# `aws autoscaling attach-instances --instance-ids i-93633f9b --auto-scaling-group-name my-auto-scaling-group`
|
11
|
+
#
|
12
|
+
# ==== Parameters
|
13
|
+
#
|
14
|
+
# * AutoScalingGroupName<~String> - The name of the Auto Scaling group``
|
15
|
+
# * 'InstanceIds'<~Array> - The list of Auto Scaling instances to detach.
|
16
|
+
#
|
17
|
+
# ==== See Also
|
18
|
+
#
|
19
|
+
# http://docs.aws.amazon.com/AutoScaling/latest/APIReference/API_AttachInstances.html
|
20
|
+
|
21
|
+
ExpectedOptions[:asg_name] = %w[AutoScalingGroupName]
|
22
|
+
ExpectedOptions[:instance_ids] = %w[InstanceIds]
|
23
|
+
|
24
|
+
def attach_instances(auto_scaling_group_name, options = {})
|
25
|
+
|
26
|
+
if instance_ids = options.delete('InstanceIds')
|
27
|
+
options.merge!(AWS.indexed_param('InstanceIds.member.%d', [*instance_ids]))
|
28
|
+
end
|
29
|
+
|
30
|
+
request({
|
31
|
+
'Action' => 'AttachInstances',
|
32
|
+
'AutoScalingGroupName' => auto_scaling_group_name,
|
33
|
+
:parser => Fog::Parsers::AWS::AutoScaling::Basic.new
|
34
|
+
}.merge!(options))
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
class Mock
|
39
|
+
def attach_instances(auto_scaling_group_name, options = {})
|
40
|
+
unexpected_options = options.keys - ExpectedOptions[:asg_name] - ExpectedOptions[:instance_ids]
|
41
|
+
|
42
|
+
unless unexpected_options.empty?
|
43
|
+
raise Fog::AWS::AutoScaling::ValidationError.new("Options #{unexpected_options.join(',')} should not be included in request")
|
44
|
+
end
|
45
|
+
|
46
|
+
unless self.data[:auto_scaling_groups].key?(auto_scaling_group_name)
|
47
|
+
raise Fog::AWS::AutoScaling::ValidationError.new('AutoScalingGroup name not found - null')
|
48
|
+
end
|
49
|
+
|
50
|
+
response = Excon::Response.new
|
51
|
+
response.status = 200
|
52
|
+
response.body = {
|
53
|
+
'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id }
|
54
|
+
}
|
55
|
+
response
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
module Fog
|
2
|
+
module AWS
|
3
|
+
class AutoScaling
|
4
|
+
class Real
|
5
|
+
require 'fog/aws/parsers/auto_scaling/basic'
|
6
|
+
|
7
|
+
# Removes one or more instances from the specified Auto Scaling group.
|
8
|
+
#
|
9
|
+
# cli equiv:
|
10
|
+
# `aws autoscaling detach-instances --instance-ids i-2a2d8978 --auto-scaling-group-name my-asg --should-decrement-desired-capacity`
|
11
|
+
#
|
12
|
+
# ==== Parameters
|
13
|
+
#
|
14
|
+
# * AutoScalingGroupName<~String> - The name of the Auto Scaling group``
|
15
|
+
# * 'InstanceIds'<~Array> - The list of Auto Scaling instances to detach.
|
16
|
+
#
|
17
|
+
# * options<~Hash>:
|
18
|
+
# 'shouldDecrementDesiredCapacity'<~Boolean> - decrement the asg capacity or not (it will boot another if an instance id detached)
|
19
|
+
#
|
20
|
+
# ==== See Also
|
21
|
+
#
|
22
|
+
# http://docs.aws.amazon.com/AutoScaling/latest/APIReference/API_DetachInstances.html
|
23
|
+
|
24
|
+
ExpectedOptions[:asg_name] = %w[AutoScalingGroupName]
|
25
|
+
ExpectedOptions[:instance_ids] = %w[InstanceIds]
|
26
|
+
|
27
|
+
def detach_instances(auto_scaling_group_name, options = {})
|
28
|
+
|
29
|
+
if should_decrement_desired_capacity = options.delete('ShouldDecrementDesiredCapacity')
|
30
|
+
options.merge!('ShouldDecrementDesiredCapacity' => true.to_s)
|
31
|
+
else
|
32
|
+
options.merge!('ShouldDecrementDesiredCapacity' => false.to_s)
|
33
|
+
end
|
34
|
+
|
35
|
+
if instance_ids = options.delete('InstanceIds')
|
36
|
+
options.merge!(AWS.indexed_param('InstanceIds.member.%d', [*instance_ids]))
|
37
|
+
end
|
38
|
+
|
39
|
+
request({
|
40
|
+
'Action' => 'DetachInstances',
|
41
|
+
'AutoScalingGroupName' => auto_scaling_group_name,
|
42
|
+
:parser => Fog::Parsers::AWS::AutoScaling::Basic.new
|
43
|
+
}.merge!(options))
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
class Mock
|
48
|
+
def detach_instances(auto_scaling_group_name, options = {})
|
49
|
+
unexpected_options = options.keys - ExpectedOptions[:asg_name] - ExpectedOptions[:instance_ids]
|
50
|
+
|
51
|
+
unless unexpected_options.empty?
|
52
|
+
raise Fog::AWS::AutoScaling::ValidationError.new("Options #{unexpected_options.join(',')} should not be included in request")
|
53
|
+
end
|
54
|
+
|
55
|
+
unless self.data[:auto_scaling_groups].key?(auto_scaling_group_name)
|
56
|
+
raise Fog::AWS::AutoScaling::ValidationError.new('AutoScalingGroup name not found - null')
|
57
|
+
end
|
58
|
+
|
59
|
+
response = Excon::Response.new
|
60
|
+
response.status = 200
|
61
|
+
response.body = {
|
62
|
+
'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id }
|
63
|
+
}
|
64
|
+
response
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
data/lib/fog/aws/version.rb
CHANGED
@@ -35,7 +35,15 @@ Shindo.tests('AWS::AutoScaling | auto_scaling_tests', ['aws', 'auto_scaling']) d
|
|
35
35
|
Fog::AWS[:auto_scaling].detach_load_balancers(@asg_name, 'LoadBalancerNames' => 'elb-test-fog').body
|
36
36
|
end
|
37
37
|
|
38
|
-
tests("#
|
38
|
+
tests("#detach_instances").formats(AWS::AutoScaling::Formats::BASIC) do
|
39
|
+
Fog::AWS[:auto_scaling].detach_instances(@asg_name, 'InstanceIds' => 'i-deadbeef').body
|
40
|
+
end
|
41
|
+
|
42
|
+
tests("#attach_instances").formats(AWS::AutoScaling::Formats::BASIC) do
|
43
|
+
Fog::AWS[:auto_scaling].attach_instances(@asg_name, 'InstanceIds' => 'i-deadbeef').body
|
44
|
+
end
|
45
|
+
|
46
|
+
tests("#describe_auto_scaling_groups").formats(AWS::AutoScaling::Formats::DESCRIBE_AUTO_SCALING_GROUPS) do
|
39
47
|
Fog::AWS[:auto_scaling].describe_auto_scaling_groups().body
|
40
48
|
end
|
41
49
|
tests("#describe_auto_scaling_groups").formats(AWS::AutoScaling::Formats::DESCRIBE_AUTO_SCALING_GROUPS) do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fog-aws
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Lane
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-03-
|
12
|
+
date: 2016-03-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -707,6 +707,7 @@ files:
|
|
707
707
|
- lib/fog/aws/parsers/sts/get_session_token.rb
|
708
708
|
- lib/fog/aws/rds.rb
|
709
709
|
- lib/fog/aws/redshift.rb
|
710
|
+
- lib/fog/aws/requests/auto_scaling/attach_instances.rb
|
710
711
|
- lib/fog/aws/requests/auto_scaling/attach_load_balancers.rb
|
711
712
|
- lib/fog/aws/requests/auto_scaling/create_auto_scaling_group.rb
|
712
713
|
- lib/fog/aws/requests/auto_scaling/create_launch_configuration.rb
|
@@ -730,6 +731,7 @@ files:
|
|
730
731
|
- lib/fog/aws/requests/auto_scaling/describe_scheduled_actions.rb
|
731
732
|
- lib/fog/aws/requests/auto_scaling/describe_tags.rb
|
732
733
|
- lib/fog/aws/requests/auto_scaling/describe_termination_policy_types.rb
|
734
|
+
- lib/fog/aws/requests/auto_scaling/detach_instances.rb
|
733
735
|
- lib/fog/aws/requests/auto_scaling/detach_load_balancers.rb
|
734
736
|
- lib/fog/aws/requests/auto_scaling/disable_metrics_collection.rb
|
735
737
|
- lib/fog/aws/requests/auto_scaling/enable_metrics_collection.rb
|