opsicle 2.8.0 → 2.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/opsicle/client.rb +2 -0
- data/lib/opsicle/cloneable_instance.rb +30 -10
- data/lib/opsicle/cloneable_layer.rb +6 -4
- data/lib/opsicle/cloneable_stack.rb +2 -1
- data/lib/opsicle/commands/clone_instance.rb +2 -1
- data/lib/opsicle/version.rb +1 -1
- data/spec/opsicle/cloneable_instance_spec.rb +28 -17
- data/spec/opsicle/cloneable_layer_spec.rb +6 -4
- data/spec/opsicle/cloneable_stack_spec.rb +1 -1
- data/spec/opsicle/commands/clone_instance_spec.rb +9 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca50977663e63f6963d4db7590ae6fe5997fc903
|
4
|
+
data.tar.gz: 1515347a9f489aa3c092312c61431cc13cbce576
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70d15051bfd1c61ee6188f617c373a5589f1787f5c2f28e0dd062298535c1e8bf92e3bb4124cd4435538b467001821d64edb8f9ef64350510dd13ca26efcce61
|
7
|
+
data.tar.gz: f018f227c6cd17fbf0453aed9d88f98ab6014d116d4e3370e469524faf3be54b413b8b05142426de093a863a31de89418c0826efda198ca29d0b56e1aa6dad7b
|
data/lib/opsicle/client.rb
CHANGED
@@ -3,6 +3,7 @@ require 'opsicle/config'
|
|
3
3
|
module Opsicle
|
4
4
|
class Client
|
5
5
|
attr_reader :opsworks
|
6
|
+
attr_reader :ec2
|
6
7
|
attr_reader :s3
|
7
8
|
attr_reader :config
|
8
9
|
|
@@ -14,6 +15,7 @@ module Opsicle
|
|
14
15
|
aws_opts = {region: region}
|
15
16
|
aws_opts[:credentials] = credentials unless credentials.nil?
|
16
17
|
@opsworks = Aws::OpsWorks::Client.new aws_opts
|
18
|
+
@ec2 = Aws::EC2::Client.new aws_opts
|
17
19
|
@s3 = Aws::S3::Client.new aws_opts
|
18
20
|
end
|
19
21
|
|
@@ -4,6 +4,7 @@ module Opsicle
|
|
4
4
|
:hostname,
|
5
5
|
:status,
|
6
6
|
:layer,
|
7
|
+
:stack,
|
7
8
|
:ami_id,
|
8
9
|
:instance_type,
|
9
10
|
:instance_id,
|
@@ -23,13 +24,15 @@ module Opsicle
|
|
23
24
|
:ebs_optimized,
|
24
25
|
:tenancy,
|
25
26
|
:opsworks,
|
27
|
+
:ec2,
|
26
28
|
:cli
|
27
29
|
)
|
28
30
|
|
29
|
-
def initialize(instance, layer, opsworks, cli)
|
31
|
+
def initialize(instance, layer, stack, opsworks, ec2, cli)
|
30
32
|
self.hostname = instance.hostname
|
31
33
|
self.status = instance.status
|
32
34
|
self.layer = layer
|
35
|
+
self.stack = stack
|
33
36
|
self.ami_id = instance.ami_id
|
34
37
|
self.instance_type = instance.instance_type
|
35
38
|
self.agent_version = instance.agent_version
|
@@ -47,6 +50,7 @@ module Opsicle
|
|
47
50
|
self.ebs_optimized = instance.ebs_optimized
|
48
51
|
self.tenancy = instance.tenancy
|
49
52
|
self.opsworks = opsworks
|
53
|
+
self.ec2 = ec2
|
50
54
|
self.cli = cli
|
51
55
|
self.instance_id = instance.instance_id
|
52
56
|
self.new_instance_id = nil
|
@@ -109,6 +113,13 @@ module Opsicle
|
|
109
113
|
!sibling_hostnames.include?(name)
|
110
114
|
end
|
111
115
|
|
116
|
+
def find_subnet_name(subnet)
|
117
|
+
tags = subnet.tags
|
118
|
+
tag = nil
|
119
|
+
tags.each { |t| tag = t if t.key == 'Name' }
|
120
|
+
tag.value if tag
|
121
|
+
end
|
122
|
+
|
112
123
|
def verify_ami_id
|
113
124
|
if self.layer.ami_id
|
114
125
|
ami_id = self.layer.ami_id
|
@@ -156,17 +167,26 @@ module Opsicle
|
|
156
167
|
if self.layer.subnet_id
|
157
168
|
subnet_id = self.layer.subnet_id
|
158
169
|
else
|
159
|
-
|
170
|
+
current_subnet = Aws::EC2::Subnet.new(id: self.subnet_id)
|
171
|
+
subnet_name = find_subnet_name(current_subnet)
|
172
|
+
puts "\nCurrent subnet ID is \"#{subnet_name}\" #{current_subnet.availability_zone} (#{self.subnet_id})"
|
160
173
|
|
161
174
|
if ask_for_overriding_permission("subnet ID", true)
|
162
|
-
|
163
|
-
|
164
|
-
subnet_ids << "Provide a different subnet ID."
|
165
|
-
subnet_id = ask_for_possible_options(subnet_ids, "subnet ID")
|
175
|
+
ec2_subnets = ec2.describe_subnets.subnets
|
176
|
+
subnets = []
|
166
177
|
|
167
|
-
|
168
|
-
|
178
|
+
ec2_subnets.each do |subnet|
|
179
|
+
if subnet.vpc_id == stack.vpc_id
|
180
|
+
subnet_name = find_subnet_name(subnet)
|
181
|
+
zone_name = subnet.availability_zone
|
182
|
+
subnet_id = subnet.subnet_id
|
183
|
+
subnets << "\"#{subnet_name}\" #{zone_name} (#{subnet_id})"
|
184
|
+
end
|
169
185
|
end
|
186
|
+
|
187
|
+
subnets = subnets.sort
|
188
|
+
subnet_id = ask_for_possible_options(subnets, "subnet ID")
|
189
|
+
subnet_id = subnet_id.scan(/(subnet-[a-z0-9]*)/).first.first if subnet_id
|
170
190
|
else
|
171
191
|
subnet_id = self.subnet_id
|
172
192
|
end
|
@@ -212,9 +232,9 @@ module Opsicle
|
|
212
232
|
os: self.os,
|
213
233
|
ami_id: ami_id,
|
214
234
|
ssh_key_name: self.ssh_key_name,
|
215
|
-
availability_zone: self.availability_zone,
|
216
|
-
virtualization_type: self.virtualization_type,
|
235
|
+
# availability_zone: self.availability_zone,
|
217
236
|
subnet_id: subnet_id,
|
237
|
+
virtualization_type: self.virtualization_type,
|
218
238
|
architecture: self.architecture, # accepts x86_64, i386
|
219
239
|
root_device_type: self.root_device_type, # accepts ebs, instance-store
|
220
240
|
install_updates_on_boot: self.install_updates_on_boot,
|
@@ -1,11 +1,13 @@
|
|
1
1
|
module Opsicle
|
2
2
|
class CloneableLayer
|
3
|
-
attr_accessor :name, :layer_id, :instances, :opsworks, :cli, :agent_version, :ami_id, :subnet_id
|
3
|
+
attr_accessor :name, :layer_id, :stack, :instances, :opsworks, :ec2, :cli, :agent_version, :ami_id, :subnet_id
|
4
4
|
|
5
|
-
def initialize(name, layer_id, opsworks, cli)
|
5
|
+
def initialize(name, layer_id, stack, opsworks, ec2, cli)
|
6
6
|
self.name = name
|
7
7
|
self.layer_id = layer_id
|
8
|
+
self.stack = stack
|
8
9
|
self.opsworks = opsworks
|
10
|
+
self.ec2 = ec2
|
9
11
|
self.cli = cli
|
10
12
|
self.instances = []
|
11
13
|
end
|
@@ -13,14 +15,14 @@ module Opsicle
|
|
13
15
|
def get_cloneable_instances
|
14
16
|
ops_instances = @opsworks.describe_instances({ :layer_id => layer_id }).instances
|
15
17
|
ops_instances.each do |instance|
|
16
|
-
self.instances << CloneableInstance.new(instance, self, @opsworks, @cli)
|
18
|
+
self.instances << CloneableInstance.new(instance, self, stack, @opsworks, @ec2, @cli)
|
17
19
|
end
|
18
20
|
self.instances
|
19
21
|
end
|
20
22
|
|
21
23
|
def add_new_instance(instance_id)
|
22
24
|
instance = @opsworks.describe_instances({ :instance_ids => [instance_id] }).instances.first
|
23
|
-
self.instances << CloneableInstance.new(instance, self, @opsworks, @cli)
|
25
|
+
self.instances << CloneableInstance.new(instance, self, stack, @opsworks, @ec2, @cli)
|
24
26
|
end
|
25
27
|
end
|
26
28
|
end
|
@@ -1,11 +1,12 @@
|
|
1
1
|
module Opsicle
|
2
2
|
class CloneableStack
|
3
|
-
attr_accessor :id, :opsworks, :stack
|
3
|
+
attr_accessor :id, :opsworks, :stack, :vpc_id
|
4
4
|
|
5
5
|
def initialize(stack_id, opsworks)
|
6
6
|
self.id = stack_id
|
7
7
|
self.opsworks = opsworks
|
8
8
|
self.stack = get_stack
|
9
|
+
self.vpc_id = self.stack.vpc_id
|
9
10
|
end
|
10
11
|
|
11
12
|
def get_stack
|
@@ -10,6 +10,7 @@ module Opsicle
|
|
10
10
|
def initialize(environment)
|
11
11
|
@client = Client.new(environment)
|
12
12
|
@opsworks = @client.opsworks
|
13
|
+
@ec2 = @client.ec2
|
13
14
|
stack_id = @client.config.opsworks_config[:stack_id]
|
14
15
|
@stack = CloneableStack.new(@client.config.opsworks_config[:stack_id], @opsworks)
|
15
16
|
@cli = HighLine.new
|
@@ -39,7 +40,7 @@ module Opsicle
|
|
39
40
|
|
40
41
|
layers = []
|
41
42
|
ops_layers.each do |layer|
|
42
|
-
layers << CloneableLayer.new(layer.name, layer.layer_id, @opsworks, @cli)
|
43
|
+
layers << CloneableLayer.new(layer.name, layer.layer_id, @stack, @opsworks, @ec2, @cli)
|
43
44
|
end
|
44
45
|
|
45
46
|
layers.each_with_index { |layer, index| puts "#{index.to_i + 1}) #{layer.name}"}
|
data/lib/opsicle/version.rb
CHANGED
@@ -25,19 +25,31 @@ module Opsicle
|
|
25
25
|
allow(@layer).to receive(:subnet_id)
|
26
26
|
@new_instance = double('new_instance', :instance_id => 1029384756)
|
27
27
|
@opsworks = double('opsworks', :create_instance => @new_instance)
|
28
|
+
@ec2 = double('ec2')
|
29
|
+
@stack = double('stack')
|
28
30
|
@agent_version_1 = double('agent_version', :version => '3434-20160316181345')
|
29
31
|
@agent_version_2 = double('agent_version', :version => '3435-20160406115841')
|
30
32
|
@agent_version_3 = double('agent_version', :version => '3436-20160418214624')
|
31
33
|
@agent_versions = double('agent_versions', :agent_versions => [@agent_version_1, @agent_version_2, @agent_version_3])
|
32
34
|
allow(@opsworks).to receive(:describe_agent_versions).with({:stack_id=>1234567890}).and_return(@agent_versions)
|
35
|
+
tag1 = double('tag', :value => 'Subnet', :key => 'Name')
|
36
|
+
@tags = [tag1]
|
37
|
+
@subnet1 = double('subnet', :vpc_id => 'vpc-123456', :subnet_id => 'subnet-123456', :tags => @tags, :availability_zone => 'us-east-1b')
|
38
|
+
@subnet2 = double('subnet', :vpc_id => 'vpc-123456', :subnet_id => 'subnet-789123', :tags => @tags, :availability_zone => 'us-east-1b')
|
39
|
+
@subnet3 = double('subnet', :vpc_id => 'vpc-123456', :subnet_id => 'subnet-456789', :tags => @tags, :availability_zone => 'us-east-1b')
|
40
|
+
@subnets = double('subnets', :subnets => [@subnet1, @subnet2, @subnet3])
|
41
|
+
allow(@stack).to receive(:vpc_id).and_return('vpc-123456')
|
33
42
|
@instances = double('instances', :instances => [@instance])
|
43
|
+
allow(@ec2).to receive(:describe_subnets).and_return(@subnets)
|
34
44
|
allow(@opsworks).to receive(:describe_instances).with({:stack_id=>1234567890}).and_return(@instances)
|
45
|
+
@current_subnet = double('subnet', :tags => @tags, :availability_zone => 'us-east-1b')
|
46
|
+
allow(Aws::EC2::Subnet).to receive(:new).and_return(@current_subnet)
|
35
47
|
@cli = double('cli', :ask => 2)
|
36
48
|
end
|
37
49
|
|
38
50
|
context "#make_new_hostname" do
|
39
51
|
it "should make a unique incremented hostname" do
|
40
|
-
instance = CloneableInstance.new(@instance, @layer, @opsworks, @cli)
|
52
|
+
instance = CloneableInstance.new(@instance, @layer, @stack, @opsworks, @ec2, @cli)
|
41
53
|
instance1 = double('instance', :hostname => 'example-hostname-01')
|
42
54
|
instance2 = double('instance', :hostname => 'example-hostname-02')
|
43
55
|
allow(@layer).to receive(:instances).and_return([instance1, instance2])
|
@@ -45,7 +57,7 @@ module Opsicle
|
|
45
57
|
end
|
46
58
|
|
47
59
|
it "should make a unique incremented hostname" do
|
48
|
-
instance = CloneableInstance.new(@instance, @layer, @opsworks, @cli)
|
60
|
+
instance = CloneableInstance.new(@instance, @layer, @stack, @opsworks, @ec2, @cli)
|
49
61
|
instance1 = double('instance', :hostname => 'example-hostname-01')
|
50
62
|
instance2 = double('instance', :hostname => 'example-hostname-02')
|
51
63
|
instance3 = double('instance', :hostname => 'example-hostname-03')
|
@@ -57,7 +69,7 @@ module Opsicle
|
|
57
69
|
|
58
70
|
context "#increment_hostname" do
|
59
71
|
it "should increment the hostname" do
|
60
|
-
instance = CloneableInstance.new(@instance, @layer, @opsworks, @cli)
|
72
|
+
instance = CloneableInstance.new(@instance, @layer, @stack, @opsworks, @ec2, @cli)
|
61
73
|
expect(instance).to receive(:hostname_unique?).and_return('example-hostname-03')
|
62
74
|
allow(@opsworks).to receive(:describe_agent_version).with({})
|
63
75
|
expect(instance.increment_hostname).to eq('example-hostname-01')
|
@@ -66,13 +78,13 @@ module Opsicle
|
|
66
78
|
|
67
79
|
context "#clone" do
|
68
80
|
it "should grab instances and make new hostname" do
|
69
|
-
instance = CloneableInstance.new(@instance, @layer, @opsworks, @cli)
|
81
|
+
instance = CloneableInstance.new(@instance, @layer, @stack, @opsworks, @ec2, @cli)
|
70
82
|
expect(instance).to receive(:make_new_hostname).and_return('example-hostname-03')
|
71
83
|
instance.clone({})
|
72
84
|
end
|
73
85
|
|
74
86
|
it "should get information from old instance" do
|
75
|
-
instance = CloneableInstance.new(@instance, @layer, @opsworks, @cli)
|
87
|
+
instance = CloneableInstance.new(@instance, @layer, @stack, @opsworks, @ec2, @cli)
|
76
88
|
expect(instance).to receive(:verify_ami_id)
|
77
89
|
expect(instance).to receive(:verify_agent_version)
|
78
90
|
expect(instance).to receive(:verify_instance_type)
|
@@ -81,13 +93,13 @@ module Opsicle
|
|
81
93
|
end
|
82
94
|
|
83
95
|
it "should create new instance" do
|
84
|
-
instance = CloneableInstance.new(@instance, @layer, @opsworks, @cli)
|
96
|
+
instance = CloneableInstance.new(@instance, @layer, @stack, @opsworks, @ec2, @cli)
|
85
97
|
expect(instance).to receive(:create_new_instance)
|
86
98
|
instance.clone({})
|
87
99
|
end
|
88
100
|
|
89
101
|
it "should start new instance" do
|
90
|
-
instance = CloneableInstance.new(@instance, @layer, @opsworks, @cli)
|
102
|
+
instance = CloneableInstance.new(@instance, @layer, @stack, @opsworks, @ec2, @cli)
|
91
103
|
allow(instance).to receive(:ask_to_start_instance).and_return(true)
|
92
104
|
expect(instance).to receive(:start_new_instance)
|
93
105
|
instance.clone({})
|
@@ -97,7 +109,7 @@ module Opsicle
|
|
97
109
|
context '#verify_agent_version' do
|
98
110
|
it "should check the agent version and ask if the user wants a new agent version" do
|
99
111
|
@cli = double('cli', :ask => 1)
|
100
|
-
instance = CloneableInstance.new(@instance, @layer, @opsworks, @cli)
|
112
|
+
instance = CloneableInstance.new(@instance, @layer, @stack, @opsworks, @ec2, @cli)
|
101
113
|
allow(@layer).to receive(:agent_version).and_return(nil)
|
102
114
|
allow_any_instance_of(HighLine).to receive(:ask).with("Do you wish to override this version? By overriding, you are choosing to override the current agent version for all instances you are cloning.\n1) Yes\n2) No", Integer).and_return(1)
|
103
115
|
expect(instance).to receive(:ask_for_possible_options)
|
@@ -105,7 +117,7 @@ module Opsicle
|
|
105
117
|
end
|
106
118
|
|
107
119
|
it "should see if the layer already has overwritten the agent version" do
|
108
|
-
instance = CloneableInstance.new(@instance, @layer, @opsworks, @cli)
|
120
|
+
instance = CloneableInstance.new(@instance, @layer, @stack, @opsworks, @ec2, @cli)
|
109
121
|
expect(@layer).to receive(:agent_version)
|
110
122
|
instance.verify_agent_version
|
111
123
|
end
|
@@ -114,7 +126,7 @@ module Opsicle
|
|
114
126
|
context '#verify_subnet_id' do
|
115
127
|
it "should check the subnet id and ask if the user wants a new subnet id" do
|
116
128
|
@cli = double('cli', :ask => 1)
|
117
|
-
instance = CloneableInstance.new(@instance, @layer, @opsworks, @cli)
|
129
|
+
instance = CloneableInstance.new(@instance, @layer, @stack, @opsworks, @ec2, @cli)
|
118
130
|
allow(@layer).to receive(:subnet_id).and_return(nil)
|
119
131
|
allow_any_instance_of(HighLine).to receive(:ask).with("Do you wish to override this id? By overriding, you are choosing to override the current agent version for all instances you are cloning.\n1) Yes\n2) No", Integer).and_return(1)
|
120
132
|
expect(instance).to receive(:ask_for_possible_options)
|
@@ -122,7 +134,7 @@ module Opsicle
|
|
122
134
|
end
|
123
135
|
|
124
136
|
it "should see if the layer already has overwritten the subnet id" do
|
125
|
-
instance = CloneableInstance.new(@instance, @layer, @opsworks, @cli)
|
137
|
+
instance = CloneableInstance.new(@instance, @layer, @stack, @opsworks, @ec2, @cli)
|
126
138
|
expect(@layer).to receive(:subnet_id)
|
127
139
|
instance.verify_subnet_id
|
128
140
|
end
|
@@ -131,7 +143,7 @@ module Opsicle
|
|
131
143
|
context '#verify_ami_id' do
|
132
144
|
it "should check the ami id and ask if the user wants a new ami" do
|
133
145
|
@cli = double('cli', :ask => 1)
|
134
|
-
instance = CloneableInstance.new(@instance, @layer, @opsworks, @cli)
|
146
|
+
instance = CloneableInstance.new(@instance, @layer, @stack, @opsworks, @ec2, @cli)
|
135
147
|
allow(@layer).to receive(:ami_id).and_return(nil)
|
136
148
|
allow_any_instance_of(HighLine).to receive(:ask).with("Do you wish to override this AMI? By overriding, you are choosing to override the current AMI for all instances you are cloning.\n1) Yes\n2) No", Integer).and_return(1)
|
137
149
|
expect(@cli).to receive(:ask)
|
@@ -140,7 +152,7 @@ module Opsicle
|
|
140
152
|
end
|
141
153
|
|
142
154
|
it "should see if the layer already has overwritten the ami id" do
|
143
|
-
instance = CloneableInstance.new(@instance, @layer, @opsworks, @cli)
|
155
|
+
instance = CloneableInstance.new(@instance, @layer, @stack, @opsworks, @ec2, @cli)
|
144
156
|
expect(@layer).to receive(:ami_id)
|
145
157
|
instance.verify_ami_id
|
146
158
|
end
|
@@ -149,7 +161,7 @@ module Opsicle
|
|
149
161
|
context '#verify_instance_type' do
|
150
162
|
it "should check the agent version and ask if the user wants a new agent version" do
|
151
163
|
@cli = double('cli', :ask => 1)
|
152
|
-
instance = CloneableInstance.new(@instance, @layer, @opsworks, @cli)
|
164
|
+
instance = CloneableInstance.new(@instance, @layer, @stack, @opsworks, @ec2, @cli)
|
153
165
|
allow(@layer).to receive(:ami_id).and_return(nil)
|
154
166
|
allow_any_instance_of(HighLine).to receive(:ask).with("Do you wish to override this instance type?\n1) Yes\n2) No", Integer).and_return(1)
|
155
167
|
expect(@cli).to receive(:ask).twice
|
@@ -159,19 +171,18 @@ module Opsicle
|
|
159
171
|
|
160
172
|
context "#create_new_instance" do
|
161
173
|
it "should create an instance" do
|
162
|
-
instance = CloneableInstance.new(@instance, @layer, @opsworks, @cli)
|
174
|
+
instance = CloneableInstance.new(@instance, @layer, @stack, @opsworks, @ec2, @cli)
|
163
175
|
expect(@opsworks).to receive(:create_instance)
|
164
176
|
instance.create_new_instance('hostname', 'type', 'ami', 'agent_version', 'subnet_id')
|
165
177
|
end
|
166
178
|
|
167
179
|
it "should take information from old instance" do
|
168
|
-
instance = CloneableInstance.new(@instance, @layer, @opsworks, @cli)
|
180
|
+
instance = CloneableInstance.new(@instance, @layer, @stack, @opsworks, @ec2, @cli)
|
169
181
|
expect(instance).to receive(:stack_id)
|
170
182
|
expect(instance).to receive(:layer_ids)
|
171
183
|
expect(instance).to receive(:auto_scaling_type)
|
172
184
|
expect(instance).to receive(:os)
|
173
185
|
expect(instance).to receive(:ssh_key_name)
|
174
|
-
expect(instance).to receive(:availability_zone)
|
175
186
|
expect(instance).to receive(:virtualization_type)
|
176
187
|
instance.create_new_instance('hostname', 'type', 'ami', 'agent_version', 'subnet_id')
|
177
188
|
end
|
@@ -36,18 +36,20 @@ module Opsicle
|
|
36
36
|
@instances = double('instances', :instances => [@instance1, @instance2])
|
37
37
|
@new_instance = double('new_instance', :instances => [@instance3])
|
38
38
|
@opsworks = double('opsworks', :describe_instances => @instances)
|
39
|
+
@ec2 = double('ec2')
|
40
|
+
@stack = double('stack')
|
39
41
|
end
|
40
42
|
|
41
43
|
context "#get_cloneable_instances" do
|
42
44
|
it "should gather opsworks instances for that layer" do
|
43
|
-
layer = CloneableLayer.new('layer-name', 12345, @opsworks, @cli)
|
45
|
+
layer = CloneableLayer.new('layer-name', 12345, @stack, @opsworks, @ec2, @cli)
|
44
46
|
expect(@opsworks).to receive(:describe_instances).and_return(@instances)
|
45
47
|
expect(@instances).to receive(:instances)
|
46
48
|
layer.get_cloneable_instances
|
47
49
|
end
|
48
50
|
|
49
51
|
it "should make a new CloneableInstance for each instance" do
|
50
|
-
layer = CloneableLayer.new('layer-name', 12345, @opsworks, @cli)
|
52
|
+
layer = CloneableLayer.new('layer-name', 12345, @stack, @opsworks, @ec2, @cli)
|
51
53
|
expect(CloneableInstance).to receive(:new).twice
|
52
54
|
layer.get_cloneable_instances
|
53
55
|
end
|
@@ -55,14 +57,14 @@ module Opsicle
|
|
55
57
|
|
56
58
|
context "#add_new_instance" do
|
57
59
|
it "should accurately find a new instance via instance_id" do
|
58
|
-
layer = CloneableLayer.new('layer-name', 12345, @opsworks, @cli)
|
60
|
+
layer = CloneableLayer.new('layer-name', 12345, @stack, @opsworks, @ec2, @cli)
|
59
61
|
expect(@opsworks).to receive(:describe_instances).and_return(@new_instance)
|
60
62
|
expect(@new_instance).to receive(:instances)
|
61
63
|
layer.add_new_instance('456-789')
|
62
64
|
end
|
63
65
|
|
64
66
|
it "should add the new instance to the instances array" do
|
65
|
-
layer = CloneableLayer.new('layer-name', 12345, @opsworks, @cli)
|
67
|
+
layer = CloneableLayer.new('layer-name', 12345, @stack, @opsworks, @ec2, @cli)
|
66
68
|
expect(@opsworks).to receive(:describe_instances).and_return(@new_instance)
|
67
69
|
expect(CloneableInstance).to receive(:new).once
|
68
70
|
layer.add_new_instance('456-789')
|
@@ -6,7 +6,7 @@ require "opsicle/user_profile"
|
|
6
6
|
module Opsicle
|
7
7
|
describe CloneableStack do
|
8
8
|
before do
|
9
|
-
|
9
|
+
@stack = double('stack', :vpc_id => 'vpc-123456')
|
10
10
|
@stacks = double('stacks', :stacks => [@stack])
|
11
11
|
@opsworks = double('opsworks', :describe_stacks => @stacks)
|
12
12
|
end
|
@@ -29,13 +29,14 @@ module Opsicle
|
|
29
29
|
@layer2 = double('layer2', :name => 'layer-2', :layer_id => 67890, :instances => [@instance1, @instance2])
|
30
30
|
@layers = double('layers', :layers => [@layer1, @layer2])
|
31
31
|
@new_instance = double('new_instance', :instance_id => 1029384756)
|
32
|
-
@stack = double('stack')
|
32
|
+
@stack = double('stack', :vpc_id => "vpc-123456")
|
33
33
|
@stacks = double('stacks', :stacks => [@stack])
|
34
34
|
@opsworks = double('opsworks', :describe_instances => @instances, :describe_layers => @layers,
|
35
35
|
:create_instance => @new_instance, :describe_stacks => @stacks,
|
36
36
|
:start_instance => @new_instance)
|
37
|
+
@ec2 = double('ec2')
|
37
38
|
@config = double('config', :opsworks_config => {:stack_id => 1234567890})
|
38
|
-
@client = double('client', :config => @config, :opsworks => @opsworks)
|
39
|
+
@client = double('client', :config => @config, :opsworks => @opsworks, :ec2 => @ec2)
|
39
40
|
allow(Client).to receive(:new).with(:environment).and_return(@client)
|
40
41
|
allow(@instances).to receive(:each_with_index)
|
41
42
|
@agent_version_1 = double('agent_version', :version => '3434-20160316181345')
|
@@ -43,6 +44,10 @@ module Opsicle
|
|
43
44
|
@agent_version_3 = double('agent_version', :version => '3436-20160418214624')
|
44
45
|
@agent_versions = double('agent_versions', :agent_versions => [@agent_version_1, @agent_version_2, @agent_version_3])
|
45
46
|
allow(@opsworks).to receive(:describe_agent_versions).and_return(@agent_versions)
|
47
|
+
tag1 = double('tag', :value => 'Subnet', :key => 'Name')
|
48
|
+
@tags = [tag1]
|
49
|
+
@current_subnet = double('subnet', :tags => @tags, :availability_zone => 'us-east-1b')
|
50
|
+
allow(Aws::EC2::Subnet).to receive(:new).and_return(@current_subnet)
|
46
51
|
allow_any_instance_of(HighLine).to receive(:ask).with("Layer?\n", Integer).and_return(2)
|
47
52
|
allow_any_instance_of(HighLine).to receive(:ask).with("Instances? (enter as a comma separated list)\n", String).and_return('2')
|
48
53
|
allow_any_instance_of(HighLine).to receive(:ask).with("Do you wish to override this hostname?\n1) Yes\n2) No", Integer).and_return(2)
|
@@ -93,7 +98,8 @@ module Opsicle
|
|
93
98
|
it "generates a new AWS client from the given configs" do
|
94
99
|
@config = double('config', :opsworks_config => {:stack_id => 1234567890})
|
95
100
|
@client = double('client', :config => @config,
|
96
|
-
:opsworks => @opsworks
|
101
|
+
:opsworks => @opsworks,
|
102
|
+
:ec2 => @ec2)
|
97
103
|
expect(Client).to receive(:new).with(:environment).and_return(@client)
|
98
104
|
CloneInstance.new(:environment)
|
99
105
|
end
|
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.
|
4
|
+
version: 2.9.0
|
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: 2017-
|
12
|
+
date: 2017-07-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: aws-sdk
|
@@ -282,7 +282,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
282
282
|
version: '0'
|
283
283
|
requirements: []
|
284
284
|
rubyforge_project:
|
285
|
-
rubygems_version: 2.
|
285
|
+
rubygems_version: 2.4.8
|
286
286
|
signing_key:
|
287
287
|
specification_version: 4
|
288
288
|
summary: An opsworks specific abstraction on top of the aws sdk
|