Merge pull request #2130 from spulec/bugfix/network-interface-and-private-ip
Add private IP to every NetworkInterface
This commit is contained in:
commit
66dafc6679
@ -189,7 +189,7 @@ class NetworkInterface(TaggedEC2Resource):
|
|||||||
self.ec2_backend = ec2_backend
|
self.ec2_backend = ec2_backend
|
||||||
self.id = random_eni_id()
|
self.id = random_eni_id()
|
||||||
self.device_index = device_index
|
self.device_index = device_index
|
||||||
self.private_ip_address = private_ip_address
|
self.private_ip_address = private_ip_address or random_private_ip()
|
||||||
self.subnet = subnet
|
self.subnet = subnet
|
||||||
self.instance = None
|
self.instance = None
|
||||||
self.attachment_id = None
|
self.attachment_id = None
|
||||||
|
@ -29,6 +29,10 @@ template = {
|
|||||||
"NinjaENI": {
|
"NinjaENI": {
|
||||||
"Description": "Elastic IP mapping to Auto-Scaling Group",
|
"Description": "Elastic IP mapping to Auto-Scaling Group",
|
||||||
"Value": {"Ref": "ENI"}
|
"Value": {"Ref": "ENI"}
|
||||||
|
},
|
||||||
|
"ENIIpAddress": {
|
||||||
|
"Description": "ENI's Private IP address",
|
||||||
|
"Value": {"Fn::GetAtt": ["ENI", "PrimaryPrivateIpAddress"]}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,8 @@ def test_elastic_network_interfaces():
|
|||||||
all_enis.should.have.length_of(1)
|
all_enis.should.have.length_of(1)
|
||||||
eni = all_enis[0]
|
eni = all_enis[0]
|
||||||
eni.groups.should.have.length_of(0)
|
eni.groups.should.have.length_of(0)
|
||||||
eni.private_ip_addresses.should.have.length_of(0)
|
eni.private_ip_addresses.should.have.length_of(1)
|
||||||
|
eni.private_ip_addresses[0].private_ip_address.startswith('10.').should.be.true
|
||||||
|
|
||||||
with assert_raises(EC2ResponseError) as ex:
|
with assert_raises(EC2ResponseError) as ex:
|
||||||
conn.delete_network_interface(eni.id, dry_run=True)
|
conn.delete_network_interface(eni.id, dry_run=True)
|
||||||
@ -354,9 +355,13 @@ def test_elastic_network_interfaces_cloudformation():
|
|||||||
)
|
)
|
||||||
ec2_conn = boto.ec2.connect_to_region("us-west-1")
|
ec2_conn = boto.ec2.connect_to_region("us-west-1")
|
||||||
eni = ec2_conn.get_all_network_interfaces()[0]
|
eni = ec2_conn.get_all_network_interfaces()[0]
|
||||||
|
eni.private_ip_addresses.should.have.length_of(1)
|
||||||
|
|
||||||
stack = conn.describe_stacks()[0]
|
stack = conn.describe_stacks()[0]
|
||||||
resources = stack.describe_resources()
|
resources = stack.describe_resources()
|
||||||
cfn_eni = [resource for resource in resources if resource.resource_type ==
|
cfn_eni = [resource for resource in resources if resource.resource_type ==
|
||||||
'AWS::EC2::NetworkInterface'][0]
|
'AWS::EC2::NetworkInterface'][0]
|
||||||
cfn_eni.physical_resource_id.should.equal(eni.id)
|
cfn_eni.physical_resource_id.should.equal(eni.id)
|
||||||
|
|
||||||
|
outputs = {output.key: output.value for output in stack.outputs}
|
||||||
|
outputs['ENIIpAddress'].should.equal(eni.private_ip_addresses[0].private_ip_address)
|
||||||
|
Loading…
Reference in New Issue
Block a user