vm_shepherd 1.8.3 → 1.8.4

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: 2a9a455d9504af7f1bc06d5c48c9677046d9fe89
4
- data.tar.gz: 88ab68ce1d9cd9aba074fc68b129def3d01538b8
3
+ metadata.gz: 88deef3c10c81db0c5ea70d8cfd04e85999424ba
4
+ data.tar.gz: 4d4a8c296e95d0c574d76f67a5f92ee21c2edf66
5
5
  SHA512:
6
- metadata.gz: 13117df80be86c6c5b2472e0b92948e6f2e073c0c9a23c5f5bd50e797f74c15dea3d9a6aabee1fea0eb3ce38119d7ccf5c4c75f667f9bb4c986c5199c0a0ba3f
7
- data.tar.gz: 83b9c1a707a8ec42c0cd82e521c6ab0533a9a1eb1029667d61726ce4acc64df1347ef3ddadac4fea1e6c6af1899dff954da838208dbae8ffd805bce143b8f4fb
6
+ metadata.gz: 1c71799a37d10d37049f2bce2410d34d3b8c0c6ca16ff242312786d76c486f98032216e7c25ad7d867c522fc810828ec69b73dcadda3a5f31e9bb0ad835eec66
7
+ data.tar.gz: 6332671a327756f8b1893082b4f67580f07cf52dc00c57d364802570d5457c5d5992b08129845239a9643ce5c716303bbc6aeb9ff7782a988b175db17882ff00
@@ -123,7 +123,8 @@ module VmShepherd
123
123
  def destroy(vm_config)
124
124
  AWS.ec2.instances.each do |instance|
125
125
  if instance.tags.to_h['Name'] == vm_config.fetch(:vm_name)
126
- elastic_ip = instance.elastic_ip
126
+ vm_ip_address = vm_config.fetch(:vm_ip_address, nil)
127
+ elastic_ip = instance.elastic_ip unless vm_ip_address
127
128
  if elastic_ip
128
129
  elastic_ip.disassociate
129
130
  elastic_ip.delete
@@ -1,3 +1,3 @@
1
1
  module VmShepherd
2
- VERSION = '1.8.3'.freeze
2
+ VERSION = '1.8.4'.freeze
3
3
  end
@@ -686,7 +686,7 @@ module VmShepherd
686
686
  ami_manager.destroy(vm_config)
687
687
  end
688
688
 
689
- context 'when there is an elastic ip' do
689
+ context 'when there is an elastic ip and it is not specified in env config' do
690
690
  let(:elastic_ip) { instance_double(AWS::EC2::ElasticIp) }
691
691
 
692
692
  before do
@@ -708,6 +708,29 @@ module VmShepherd
708
708
  ami_manager.destroy(vm_config)
709
709
  end
710
710
  end
711
+
712
+ context 'when there is an elastic ip and it is specified in env config' do
713
+ let(:elastic_ip) { instance_double(AWS::EC2::ElasticIp) }
714
+ let(:vm_config) do
715
+ {
716
+ vm_name: 'some-vm-name',
717
+ vm_ip_address: 'some-ip-address'
718
+ }
719
+ end
720
+
721
+ it 'terminates the VM with the specified name' do
722
+ expect(non_terminated_instance).not_to receive(:terminate)
723
+ expect(instance).to receive(:terminate)
724
+
725
+ ami_manager.destroy(vm_config)
726
+ end
727
+
728
+ it 'does not destroy the elastic ip' do
729
+ expect(elastic_ip).not_to receive(:delete).ordered
730
+
731
+ ami_manager.destroy(vm_config)
732
+ end
733
+ end
711
734
  end
712
735
  end
713
736
  end
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.8.3
4
+ version: 1.8.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ops Manager Team