cfn_manage 0.2.8 → 0.3.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 +4 -4
- data/lib/cf_start_stop_environment.rb +1 -0
- data/lib/spot_fleet_start_stop_handler.rb +53 -0
- data/lib/start_stop_handler_factory.rb +3 -0
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 76bc39237a58017a9ed11fabb8f926b2732f91f25af127807b2b6403d8f6c21c
|
|
4
|
+
data.tar.gz: 35a655a89c72079b96323ba9e41d1afa36838ddadb45c31552a4c2b206717cbb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fb97e8f646522f3eec33e85ff24f4b3b2c713e827a2c136e63e95769a3e5f7421efbf71ca37cf7227c224c369fa3439621158031d5dfefbfb5e9253010f1f5d0
|
|
7
|
+
data.tar.gz: b80c71ab75a3384cded073a8564362b7d12a97260f1661b1a11913983403ebdf738128010a55124dd5b4e9332bf2bb702aae8f8b8a076b24c1c188b4df5a1199
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
require_relative '../lib/aws_credentials'
|
|
2
|
+
|
|
3
|
+
module Base2
|
|
4
|
+
|
|
5
|
+
class SpotFleetStartStopHandler
|
|
6
|
+
|
|
7
|
+
def initialize(fleet_id)
|
|
8
|
+
@fleet_id = fleet_id
|
|
9
|
+
|
|
10
|
+
credentials = Base2::AWSCredentials.get_session_credentials("startstopfleet_#{fleet_id}")
|
|
11
|
+
@ec2_client = Aws::EC2::Client.new(retry_limit: 20)
|
|
12
|
+
if credentials != nil
|
|
13
|
+
@ec2_client = Aws::EC2::Client.new(credentials: credentials, retry_limit: 20)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
@fleet = @ec2_client.describe_spot_fleet_requests({spot_fleet_request_ids:[fleet_id]})
|
|
17
|
+
@fleet = @fleet.spot_fleet_request_configs[0].spot_fleet_request_config
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def start(configuration)
|
|
21
|
+
|
|
22
|
+
$log.info("Setting fleet #{@fleet_id} capacity to #{configuration['target_capacity']}")
|
|
23
|
+
@ec2_client.modify_spot_fleet_request({
|
|
24
|
+
spot_fleet_request_id: @fleet_id,
|
|
25
|
+
target_capacity: configuration['target_capacity'],
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
return configuration
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def stop
|
|
32
|
+
|
|
33
|
+
if @fleet.target_capacity == 0
|
|
34
|
+
$log.info("Spot fleet #{@fleet_id} already stopped")
|
|
35
|
+
return nil
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
configuration = {
|
|
39
|
+
target_capacity: @fleet.target_capacity
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
$log.info("Setting fleet #{@fleet_id} capacity to 0")
|
|
43
|
+
@ec2_client.modify_spot_fleet_request({
|
|
44
|
+
spot_fleet_request_id: @fleet_id,
|
|
45
|
+
target_capacity: 0,
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
return configuration
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
end
|
|
@@ -2,6 +2,7 @@ require_relative '../lib/asg_start_stop_handler'
|
|
|
2
2
|
require_relative '../lib/ec2_start_stop_handler'
|
|
3
3
|
require_relative '../lib/rds_start_stop_handler'
|
|
4
4
|
require_relative '../lib/alarm_start_stop_handler'
|
|
5
|
+
require_relative '../lib/spot_fleet_start_stop_handler'
|
|
5
6
|
|
|
6
7
|
module Base2
|
|
7
8
|
|
|
@@ -24,6 +25,8 @@ module Base2
|
|
|
24
25
|
when 'AWS::CloudWatch::Alarm'
|
|
25
26
|
return Base2::AlarmStartStopHandler.new(resource_id)
|
|
26
27
|
|
|
28
|
+
when 'AWS::EC2::SpotFleet'
|
|
29
|
+
return Base2::SpotFleetStartStopHandler.new(resource_id)
|
|
27
30
|
else
|
|
28
31
|
return nil
|
|
29
32
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cfn_manage
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Base2Services
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2018-04-
|
|
12
|
+
date: 2018-04-26 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: aws-sdk-core
|
|
@@ -190,6 +190,7 @@ files:
|
|
|
190
190
|
- lib/dynamodb_start_stop_handler.rb
|
|
191
191
|
- lib/ec2_start_stop_handler.rb
|
|
192
192
|
- lib/rds_start_stop_handler.rb
|
|
193
|
+
- lib/spot_fleet_start_stop_handler.rb
|
|
193
194
|
- lib/start_stop_handler_factory.rb
|
|
194
195
|
homepage: https://github.com/base2Services/cfn-library/blob/master/README.md
|
|
195
196
|
licenses:
|