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 +4 -4
- data/lib/vm_shepherd/aws_manager.rb +2 -1
- data/lib/vm_shepherd/version.rb +1 -1
- data/spec/vm_shepherd/aws_manager_spec.rb +24 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88deef3c10c81db0c5ea70d8cfd04e85999424ba
|
4
|
+
data.tar.gz: 4d4a8c296e95d0c574d76f67a5f92ee21c2edf66
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
data/lib/vm_shepherd/version.rb
CHANGED
@@ -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
|