vm_shepherd 1.5.4 → 1.6.0

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: 43c462e588b30f5889f991c17ea977b3770134ce
4
- data.tar.gz: a8b35cbfe28cd38c0ac292caca125ae4263f2ae3
3
+ metadata.gz: 5b205f1eac35569f69fe5709c0019c0fd51a6e86
4
+ data.tar.gz: 105cc945195c4300389ef2d5e208203ff5d35d6d
5
5
  SHA512:
6
- metadata.gz: d85a9915a494c2c5a65b7321223d35a29fd9b20b39d5ad2dfd37747f2e34fbfb1b26f1d67aa8f6f3a60f27817b017d4b928600170f21ff82d5bdb8f76053db80
7
- data.tar.gz: c4c25f5e4c71d90cd25e85d11ab53da05a354c7165d28562a07af42bfad5d17c503f4adbdc50c984c65855a7367ed166daacea8189f912cc49df6884e356eec3
6
+ metadata.gz: b872bef61ea5d9f432b822aebd8cfb8de74f97312d104ffc68c452b15ce4ee6c691c336899dddf52835f5b59715f2c5f49caaa951c361e8ce6a551e5295e0bf3
7
+ data.tar.gz: fda97963ff3c34a9546c870d6e00b87897213f12ca4a4295fc19d46c4d8c0eea765a58260dd9b8d566764686122a48452a449a69d8797ddd71897ba053c21e3b
@@ -85,9 +85,15 @@ module VmShepherd
85
85
  end
86
86
  end
87
87
 
88
- logger.info('Creating an Elastic IP and assigning it to the instance')
89
- elastic_ip = AWS.ec2.elastic_ips.create(vpc: true)
90
- instance.associate_elastic_ip(elastic_ip.allocation_id)
88
+ vm_ip_address = vm_config.fetch(:vm_ip_address, nil)
89
+ if vm_ip_address
90
+ logger.info('Associating existing IP to the instance')
91
+ elastic_ip = AWS::EC2::ElasticIp.new(vm_ip_address)
92
+ else
93
+ logger.info('Creating an Elastic IP and assigning it to the instance')
94
+ elastic_ip = AWS.ec2.elastic_ips.create(vpc: true)
95
+ end
96
+ instance.associate_elastic_ip(elastic_ip)
91
97
  instance.add_tag('Name', value: vm_config.fetch(:vm_name))
92
98
  end
93
99
 
@@ -1,3 +1,3 @@
1
1
  module VmShepherd
2
- VERSION = '1.5.4'.freeze
2
+ VERSION = '1.6.0'.freeze
3
3
  end
@@ -238,13 +238,31 @@ module VmShepherd
238
238
  expect { ami_manager.deploy(ami_file_path: ami_file_path, vm_config: vm_config) }.to raise_error(AwsManager::RetryLimitExceeded)
239
239
  end
240
240
 
241
- it 'creates and attaches an elastic IP' do
242
- expect(ec2).to receive_message_chain(:elastic_ips, :create).with(
241
+ context 'vm configuration does not contain an elastic IP' do
242
+ it 'creates and attaches an elastic IP' do
243
+ expect(ec2).to receive_message_chain(:elastic_ips, :create).with(
243
244
  vpc: true).and_return(elastic_ip)
244
245
 
245
- expect(instance).to receive(:associate_elastic_ip).with(elastic_ip.allocation_id)
246
+ expect(instance).to receive(:associate_elastic_ip).with(elastic_ip)
246
247
 
247
- ami_manager.deploy(ami_file_path: ami_file_path, vm_config: vm_config)
248
+ ami_manager.deploy(ami_file_path: ami_file_path, vm_config: vm_config)
249
+ end
250
+ end
251
+
252
+ context 'vm configuration contains an elastic IP' do
253
+ let(:vm_config) do
254
+ {
255
+ vm_name: 'some-vm-name',
256
+ vm_ip_address: 'some-ip-address'
257
+ }
258
+ end
259
+
260
+ it 'attaches the provided ip address to the VM' do
261
+ expect(AWS::EC2::ElasticIp).to receive(:new).and_return(elastic_ip)
262
+ expect(instance).to receive(:associate_elastic_ip).with(elastic_ip)
263
+
264
+ ami_manager.deploy(ami_file_path: ami_file_path, vm_config: vm_config)
265
+ end
248
266
  end
249
267
 
250
268
  it 'tags the instance with a name' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vm_shepherd
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.4
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ops Manager Team
@@ -195,7 +195,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
195
195
  version: '0'
196
196
  requirements: []
197
197
  rubyforge_project:
198
- rubygems_version: 2.4.7
198
+ rubygems_version: 2.4.5
199
199
  signing_key:
200
200
  specification_version: 4
201
201
  summary: A tool for booting and tearing down Ops Manager VMs on various Infrastructures.