opsicle 2.10.0 → 2.10.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/opsicle/aws_instance_manager_helper.rb +3 -0
- data/lib/opsicle/commands/create_instance.rb +1 -1
- data/lib/opsicle/commands/delete_instance.rb +20 -6
- data/lib/opsicle/commands/stop_instance.rb +21 -6
- data/lib/opsicle/creatable_instance.rb +5 -5
- data/lib/opsicle/manageable_stack.rb +4 -4
- data/lib/opsicle/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: 2e28df963a182535bfaf92964eeb32df3950e884
|
4
|
+
data.tar.gz: 7ba69cac271a9c2269afe46fe28e120a7405d92b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0197fea7b2f46f0ea103c8c8df2549040acf4f00a87ff220827feb237e21d2edce2cad5587f35f25fe6c21b38e6fa3b35ca8da45f244ac2ee11b42567b3df06d
|
7
|
+
data.tar.gz: 46270627f6c99cb98f4e362aeb93dfac47796c982572b7bea7de5be94062c4f98aec94c49036ffe8525532292f9ce8118a24e1356ef0d6a67c4baf44778a05f7
|
@@ -18,7 +18,8 @@ module Opsicle
|
|
18
18
|
|
19
19
|
def execute(options={})
|
20
20
|
puts "Stack ID = #{@stack.id}"
|
21
|
-
|
21
|
+
layer = select_layer
|
22
|
+
instances_to_delete = select_instances(layer)
|
22
23
|
instances_to_delete.each do |instance|
|
23
24
|
begin
|
24
25
|
@opsworks.delete_instance(instance_id: instance.instance_id)
|
@@ -29,16 +30,29 @@ module Opsicle
|
|
29
30
|
end
|
30
31
|
end
|
31
32
|
|
32
|
-
def deleteable_instances
|
33
|
-
@stack.deleteable_instances
|
33
|
+
def deleteable_instances(layer)
|
34
|
+
@stack.deleteable_instances(layer)
|
35
|
+
end
|
36
|
+
|
37
|
+
def select_layer
|
38
|
+
puts "\nLayers:\n"
|
39
|
+
ops_layers = @opsworks.describe_layers({ :stack_id => @stack.id }).layers
|
40
|
+
|
41
|
+
layers = []
|
42
|
+
ops_layers.each do |layer|
|
43
|
+
layers << ManageableLayer.new(layer.name, layer.layer_id, @stack, @opsworks, @ec2, @cli)
|
44
|
+
end
|
34
45
|
|
46
|
+
layers.each_with_index { |layer, index| puts "#{index.to_i + 1}) #{layer.name}" }
|
47
|
+
layer_index = @cli.ask("Layer?\n", Integer) { |q| q.in = 1..layers.length.to_i } - 1
|
48
|
+
layers[layer_index]
|
35
49
|
end
|
36
50
|
|
37
|
-
def select_instances
|
38
|
-
instances = deleteable_instances
|
51
|
+
def select_instances(layer)
|
52
|
+
instances = deleteable_instances(layer)
|
39
53
|
return_array = []
|
40
54
|
if instances.empty?
|
41
|
-
puts "There are no deletable instances"
|
55
|
+
puts "There are no deletable instances."
|
42
56
|
else
|
43
57
|
puts "\nDeleteable Instances:\n"
|
44
58
|
instances.each_with_index { |instance, index| puts "#{index.to_i + 1}) #{instance.status} - #{instance.hostname}" }
|
@@ -18,7 +18,8 @@ module Opsicle
|
|
18
18
|
|
19
19
|
def execute(options={})
|
20
20
|
puts "Stack ID = #{@stack.id}"
|
21
|
-
|
21
|
+
layer = select_layer
|
22
|
+
instances_to_stop = select_instances(layer)
|
22
23
|
instances_to_stop.each do |instance|
|
23
24
|
begin
|
24
25
|
@opsworks.stop_instance(instance_id: instance.instance_id)
|
@@ -29,15 +30,29 @@ module Opsicle
|
|
29
30
|
end
|
30
31
|
end
|
31
32
|
|
32
|
-
def stoppable_instances
|
33
|
-
@stack.stoppable_instances
|
33
|
+
def stoppable_instances(layer)
|
34
|
+
@stack.stoppable_instances(layer)
|
34
35
|
end
|
35
36
|
|
36
|
-
def
|
37
|
-
|
37
|
+
def select_layer
|
38
|
+
puts "\nLayers:\n"
|
39
|
+
ops_layers = @opsworks.describe_layers({ :stack_id => @stack.id }).layers
|
40
|
+
|
41
|
+
layers = []
|
42
|
+
ops_layers.each do |layer|
|
43
|
+
layers << ManageableLayer.new(layer.name, layer.layer_id, @stack, @opsworks, @ec2, @cli)
|
44
|
+
end
|
45
|
+
|
46
|
+
layers.each_with_index { |layer, index| puts "#{index.to_i + 1}) #{layer.name}" }
|
47
|
+
layer_index = @cli.ask("Layer?\n", Integer) { |q| q.in = 1..layers.length.to_i } - 1
|
48
|
+
layers[layer_index]
|
49
|
+
end
|
50
|
+
|
51
|
+
def select_instances(layer)
|
52
|
+
instances = stoppable_instances(layer)
|
38
53
|
return_array = []
|
39
54
|
if instances.empty?
|
40
|
-
puts "There are no stoppable instances"
|
55
|
+
puts "There are no stoppable instances."
|
41
56
|
else
|
42
57
|
puts "\nStoppable Instances:\n"
|
43
58
|
instances.each_with_index { |instance, index| puts "#{index.to_i + 1}) #{instance.status} - #{instance.hostname}" }
|
@@ -30,14 +30,14 @@ module Opsicle
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def make_new_hostname
|
33
|
-
new_instance_hostname = auto_generated_hostname
|
34
|
-
puts "\nAutomatically generated hostname: #{new_instance_hostname}\n"
|
33
|
+
new_instance_hostname = auto_generated_hostname || nil
|
34
|
+
puts "\nAutomatically generated hostname: #{new_instance_hostname}\n" if new_instance_hostname
|
35
35
|
new_instance_hostname = ask_for_new_option("instance's hostname") if ask_for_overriding_permission("hostname", false)
|
36
36
|
new_instance_hostname
|
37
37
|
end
|
38
38
|
|
39
39
|
def hostname
|
40
|
-
self.layer.instances.first.hostname
|
40
|
+
self.layer.instances.first.hostname if self.layer.instances.first
|
41
41
|
end
|
42
42
|
|
43
43
|
def auto_generated_hostname
|
@@ -118,7 +118,7 @@ module Opsicle
|
|
118
118
|
end
|
119
119
|
|
120
120
|
def os
|
121
|
-
self.layer.instances.first.os
|
121
|
+
self.layer.instances.first.os if self.layer.instances.first
|
122
122
|
end
|
123
123
|
|
124
124
|
def ask_for_possible_options(arr, description)
|
@@ -149,7 +149,7 @@ module Opsicle
|
|
149
149
|
ami_id: ami_id,
|
150
150
|
subnet_id: subnet_id,
|
151
151
|
agent_version: agent_version,
|
152
|
-
os: os
|
152
|
+
os: os || 'Custom'
|
153
153
|
})
|
154
154
|
self.new_instance_id = new_instance.instance_id
|
155
155
|
self.layer.add_new_instance(new_instance_id)
|
@@ -68,16 +68,16 @@ module Opsicle
|
|
68
68
|
@opsworks.describe_instances(stack_id: self.id).instances
|
69
69
|
end
|
70
70
|
|
71
|
-
def deleteable_instances
|
72
|
-
instances.select{ |instance| instance.auto_scaling_type.nil? && instance.status == "stopped" }
|
71
|
+
def deleteable_instances(layer)
|
72
|
+
instances.select{ |instance| instance.auto_scaling_type.nil? && instance.status == "stopped" && instance.layer_ids.include?(layer.layer_id) }
|
73
73
|
end
|
74
74
|
|
75
75
|
def stoppable_states
|
76
76
|
%w(start_failed stop_failed online running_setup setup_failed booting rebooting)
|
77
77
|
end
|
78
78
|
|
79
|
-
def stoppable_instances
|
80
|
-
instances.select{ |instance| instance.elastic_ip.nil? && stoppable_states.include?(instance.status) }
|
79
|
+
def stoppable_instances(layer)
|
80
|
+
instances.select{ |instance| instance.elastic_ip.nil? && stoppable_states.include?(instance.status) && instance.layer_ids.include?(layer.layer_id) }
|
81
81
|
end
|
82
82
|
end
|
83
83
|
end
|
data/lib/opsicle/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opsicle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.10.
|
4
|
+
version: 2.10.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Fleener
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-
|
12
|
+
date: 2018-02-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: aws-sdk
|
@@ -190,6 +190,7 @@ files:
|
|
190
190
|
- LICENSE
|
191
191
|
- bin/opsicle
|
192
192
|
- lib/opsicle.rb
|
193
|
+
- lib/opsicle/aws_instance_manager_helper.rb
|
193
194
|
- lib/opsicle/client.rb
|
194
195
|
- lib/opsicle/commands.rb
|
195
196
|
- lib/opsicle/commands/add_tags.rb
|