Merge pull request #1149 from gvlproject/fix_disassociate_address
Fix for instance public ip not being cleared on eip disassociation
This commit is contained in:
commit
a7049acf70
@ -590,10 +590,6 @@ class Instance(TaggedEC2Resource, BotoInstance):
|
||||
|
||||
self.attach_eni(use_nic, device_index)
|
||||
|
||||
def set_ip(self, ip_address):
|
||||
# Should we be creating a new ENI?
|
||||
self.nics[0].public_ip = ip_address
|
||||
|
||||
def attach_eni(self, eni, device_index):
|
||||
device_index = int(device_index)
|
||||
self.nics[device_index] = eni
|
||||
@ -3047,8 +3043,6 @@ class ElasticAddressBackend(object):
|
||||
eip.eni.public_ip = eip.public_ip
|
||||
if eip.domain == "vpc":
|
||||
eip.association_id = random_eip_association_id()
|
||||
if instance:
|
||||
instance.set_ip(eip.public_ip)
|
||||
|
||||
return eip
|
||||
|
||||
@ -3082,10 +3076,9 @@ class ElasticAddressBackend(object):
|
||||
eip = eips[0]
|
||||
|
||||
if eip.eni:
|
||||
eip.eni.public_ip = None
|
||||
if eip.eni.instance and eip.eni.instance._state.name == "running":
|
||||
eip.eni.check_auto_public_ip()
|
||||
else:
|
||||
eip.eni.public_ip = None
|
||||
eip.eni = None
|
||||
|
||||
eip.instance = None
|
||||
|
@ -180,13 +180,31 @@ def test_eip_boto3_vpc_association():
|
||||
'SubnetId': subnet_res['Subnet']['SubnetId']
|
||||
})[0]
|
||||
allocation_id = client.allocate_address(Domain='vpc')['AllocationId']
|
||||
address = service.VpcAddress(allocation_id)
|
||||
address.load()
|
||||
address.association_id.should.be.none
|
||||
address.instance_id.should.be.empty
|
||||
address.network_interface_id.should.be.empty
|
||||
association_id = client.associate_address(
|
||||
InstanceId=instance.id,
|
||||
AllocationId=allocation_id,
|
||||
AllowReassociation=False)
|
||||
instance.load()
|
||||
address.reload()
|
||||
address.association_id.should_not.be.none
|
||||
instance.public_ip_address.should_not.be.none
|
||||
instance.public_dns_name.should_not.be.none
|
||||
address.network_interface_id.should.equal(instance.network_interfaces_attribute[0].get('NetworkInterfaceId'))
|
||||
address.public_ip.should.equal(instance.public_ip_address)
|
||||
address.instance_id.should.equal(instance.id)
|
||||
|
||||
client.disassociate_address(AssociationId=address.association_id)
|
||||
instance.reload()
|
||||
address.reload()
|
||||
instance.public_ip_address.should.be.none
|
||||
address.network_interface_id.should.be.empty
|
||||
address.association_id.should.be.none
|
||||
address.instance_id.should.be.empty
|
||||
|
||||
|
||||
@mock_ec2_deprecated
|
||||
|
Loading…
Reference in New Issue
Block a user