Cleanup public IPs for EC2 classic instances and fix some default ENI things.
This commit is contained in:
parent
556394c68e
commit
136873d49e
@ -69,6 +69,7 @@ from .utils import (
|
|||||||
random_internet_gateway_id,
|
random_internet_gateway_id,
|
||||||
random_ip,
|
random_ip,
|
||||||
random_key_pair,
|
random_key_pair,
|
||||||
|
random_private_ip,
|
||||||
random_public_ip,
|
random_public_ip,
|
||||||
random_reservation_id,
|
random_reservation_id,
|
||||||
random_route_table_id,
|
random_route_table_id,
|
||||||
@ -174,9 +175,12 @@ class NetworkInterface(object):
|
|||||||
|
|
||||||
security_group_ids = properties.get('SecurityGroups', [])
|
security_group_ids = properties.get('SecurityGroups', [])
|
||||||
|
|
||||||
subnet_id = properties['SubnetId']
|
|
||||||
ec2_backend = ec2_backends[region_name]
|
ec2_backend = ec2_backends[region_name]
|
||||||
subnet = ec2_backend.get_subnet(subnet_id)
|
subnet_id = properties.get('SubnetId')
|
||||||
|
if subnet_id:
|
||||||
|
subnet = ec2_backend.get_subnet(subnet_id)
|
||||||
|
else:
|
||||||
|
subnet = None
|
||||||
|
|
||||||
private_ip_address = properties.get('PrivateIpAddress', None)
|
private_ip_address = properties.get('PrivateIpAddress', None)
|
||||||
|
|
||||||
@ -224,7 +228,7 @@ class NetworkInterfaceBackend(object):
|
|||||||
super(NetworkInterfaceBackend, self).__init__()
|
super(NetworkInterfaceBackend, self).__init__()
|
||||||
|
|
||||||
def create_network_interface(self, subnet, private_ip_address, group_ids=None, **kwargs):
|
def create_network_interface(self, subnet, private_ip_address, group_ids=None, **kwargs):
|
||||||
eni = NetworkInterface(self, subnet, private_ip_address, group_ids=group_ids)
|
eni = NetworkInterface(self, subnet, private_ip_address, group_ids=group_ids, **kwargs)
|
||||||
self.enis[eni.id] = eni
|
self.enis[eni.id] = eni
|
||||||
return eni
|
return eni
|
||||||
|
|
||||||
@ -297,10 +301,14 @@ class Instance(BotoInstance, TaggedEC2Resource):
|
|||||||
self.instance_type = kwargs.get("instance_type", "m1.small")
|
self.instance_type = kwargs.get("instance_type", "m1.small")
|
||||||
self.vpc_id = None
|
self.vpc_id = None
|
||||||
self.subnet_id = kwargs.get("subnet_id")
|
self.subnet_id = kwargs.get("subnet_id")
|
||||||
|
in_ec2_classic = not bool(self.subnet_id)
|
||||||
self.key_name = kwargs.get("key_name")
|
self.key_name = kwargs.get("key_name")
|
||||||
self.source_dest_check = "true"
|
self.source_dest_check = "true"
|
||||||
self.launch_time = datetime.utcnow().isoformat()
|
self.launch_time = datetime.utcnow().isoformat()
|
||||||
self.private_ip_address = kwargs.get('private_ip_address')
|
associate_public_ip = kwargs.get("associate_public_ip", False)
|
||||||
|
if in_ec2_classic:
|
||||||
|
# If we are in EC2-Classic, autoassign a public IP
|
||||||
|
associate_public_ip = True
|
||||||
|
|
||||||
self.block_device_mapping = BlockDeviceMapping()
|
self.block_device_mapping = BlockDeviceMapping()
|
||||||
self.block_device_mapping['/dev/sda1'] = BlockDeviceType(volume_id=random_volume_id())
|
self.block_device_mapping['/dev/sda1'] = BlockDeviceType(volume_id=random_volume_id())
|
||||||
@ -326,9 +334,26 @@ class Instance(BotoInstance, TaggedEC2Resource):
|
|||||||
self.vpc_id = subnet.vpc_id
|
self.vpc_id = subnet.vpc_id
|
||||||
|
|
||||||
self.prep_nics(kwargs.get("nics", {}),
|
self.prep_nics(kwargs.get("nics", {}),
|
||||||
subnet_id=kwargs.get("subnet_id"),
|
subnet_id=self.subnet_id,
|
||||||
private_ip=kwargs.get("private_ip"),
|
private_ip=kwargs.get("private_ip"),
|
||||||
associate_public_ip=kwargs.get("associate_public_ip"))
|
associate_public_ip=associate_public_ip)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def private_ip(self):
|
||||||
|
return self.nics[0].private_ip_address
|
||||||
|
|
||||||
|
@property
|
||||||
|
def private_dns(self):
|
||||||
|
return "ip-{0}.ec2.internal".format(self.private_ip)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def public_ip(self):
|
||||||
|
return self.nics[0].public_ip
|
||||||
|
|
||||||
|
@property
|
||||||
|
def public_dns(self):
|
||||||
|
if self.public_ip:
|
||||||
|
return "ec2-{0}.compute-1.amazonaws.com".format(self.public_ip)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create_from_cloudformation_json(cls, resource_name, cloudformation_json, region_name):
|
def create_from_cloudformation_json(cls, resource_name, cloudformation_json, region_name):
|
||||||
@ -346,7 +371,7 @@ class Instance(BotoInstance, TaggedEC2Resource):
|
|||||||
instance_type=properties.get("InstanceType", "m1.small"),
|
instance_type=properties.get("InstanceType", "m1.small"),
|
||||||
subnet_id=properties.get("SubnetId"),
|
subnet_id=properties.get("SubnetId"),
|
||||||
key_name=properties.get("KeyName"),
|
key_name=properties.get("KeyName"),
|
||||||
private_ip_address=properties.get('PrivateIpAddress'),
|
private_ip=properties.get('PrivateIpAddress'),
|
||||||
)
|
)
|
||||||
return reservation.instances[0]
|
return reservation.instances[0]
|
||||||
|
|
||||||
@ -407,6 +432,9 @@ class Instance(BotoInstance, TaggedEC2Resource):
|
|||||||
def prep_nics(self, nic_spec, subnet_id=None, private_ip=None, associate_public_ip=None):
|
def prep_nics(self, nic_spec, subnet_id=None, private_ip=None, associate_public_ip=None):
|
||||||
self.nics = {}
|
self.nics = {}
|
||||||
|
|
||||||
|
if not private_ip:
|
||||||
|
private_ip = random_private_ip()
|
||||||
|
|
||||||
# Primary NIC defaults
|
# Primary NIC defaults
|
||||||
primary_nic = {'SubnetId': subnet_id,
|
primary_nic = {'SubnetId': subnet_id,
|
||||||
'PrivateIpAddress': private_ip,
|
'PrivateIpAddress': private_ip,
|
||||||
@ -434,7 +462,10 @@ class Instance(BotoInstance, TaggedEC2Resource):
|
|||||||
if device_index == 0 and primary_nic:
|
if device_index == 0 and primary_nic:
|
||||||
nic.update(primary_nic)
|
nic.update(primary_nic)
|
||||||
|
|
||||||
subnet = self.ec2_backend.get_subnet(nic['SubnetId'])
|
if 'SubnetId' in nic:
|
||||||
|
subnet = self.ec2_backend.get_subnet(nic['SubnetId'])
|
||||||
|
else:
|
||||||
|
subnet = None
|
||||||
|
|
||||||
group_id = nic.get('SecurityGroupId')
|
group_id = nic.get('SecurityGroupId')
|
||||||
group_ids = [group_id] if group_id else []
|
group_ids = [group_id] if group_id else []
|
||||||
@ -468,13 +499,13 @@ class Instance(BotoInstance, TaggedEC2Resource):
|
|||||||
if attribute_name == 'AvailabilityZone':
|
if attribute_name == 'AvailabilityZone':
|
||||||
return self.placement
|
return self.placement
|
||||||
elif attribute_name == 'PrivateDnsName':
|
elif attribute_name == 'PrivateDnsName':
|
||||||
return self.private_dns_name
|
return self.private_dns
|
||||||
elif attribute_name == 'PublicDnsName':
|
elif attribute_name == 'PublicDnsName':
|
||||||
return self.public_dns_name
|
return self.public_dns
|
||||||
elif attribute_name == 'PrivateIp':
|
elif attribute_name == 'PrivateIp':
|
||||||
return self.private_ip_address
|
return self.private_ip
|
||||||
elif attribute_name == 'PublicIp':
|
elif attribute_name == 'PublicIp':
|
||||||
return self.ip_address
|
return self.public_ip
|
||||||
raise UnformattedGetAttTemplateException()
|
raise UnformattedGetAttTemplateException()
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,6 +25,11 @@ class ElasticNetworkInterfaces(BaseResponse):
|
|||||||
def describe_network_interfaces(self):
|
def describe_network_interfaces(self):
|
||||||
# Partially implemented. Supports only network-interface-id and group-id filters
|
# Partially implemented. Supports only network-interface-id and group-id filters
|
||||||
filters = filters_from_querystring(self.querystring)
|
filters = filters_from_querystring(self.querystring)
|
||||||
|
eni_ids = self._get_multi_param('NetworkInterfaceId.')
|
||||||
|
if 'network-interface-id' not in filters and eni_ids:
|
||||||
|
# Network interfaces can be filtered by passing the 'network-interface-id'
|
||||||
|
# filter or by passing the NetworkInterfaceId parameter
|
||||||
|
filters['network-interface-id'] = eni_ids
|
||||||
enis = self.ec2_backend.describe_network_interfaces(filters)
|
enis = self.ec2_backend.describe_network_interfaces(filters)
|
||||||
template = self.response_template(DESCRIBE_NETWORK_INTERFACES_RESPONSE)
|
template = self.response_template(DESCRIBE_NETWORK_INTERFACES_RESPONSE)
|
||||||
return template.render(enis=enis)
|
return template.render(enis=enis)
|
||||||
|
@ -198,8 +198,8 @@ EC2_RUN_INSTANCES = """<RunInstancesResponse xmlns="http://ec2.amazonaws.com/doc
|
|||||||
<code>0</code>
|
<code>0</code>
|
||||||
<name>pending</name>
|
<name>pending</name>
|
||||||
</instanceState>
|
</instanceState>
|
||||||
<privateDnsName/>
|
<privateDnsName>{{ instance.private_dns }}</privateDnsName>
|
||||||
<dnsName/>
|
<publicDnsName>{{ instance.public_dns }}</publicDnsName>
|
||||||
<reason/>
|
<reason/>
|
||||||
<keyName>{{ instance.key_name }}</keyName>
|
<keyName>{{ instance.key_name }}</keyName>
|
||||||
<amiLaunchIndex>0</amiLaunchIndex>
|
<amiLaunchIndex>0</amiLaunchIndex>
|
||||||
@ -216,9 +216,9 @@ EC2_RUN_INSTANCES = """<RunInstancesResponse xmlns="http://ec2.amazonaws.com/doc
|
|||||||
{% if instance.nics %}
|
{% if instance.nics %}
|
||||||
<subnetId>{{ instance.nics[0].subnet.id }}</subnetId>
|
<subnetId>{{ instance.nics[0].subnet.id }}</subnetId>
|
||||||
<vpcId>{{ instance.nics[0].subnet.vpc_id }}</vpcId>
|
<vpcId>{{ instance.nics[0].subnet.vpc_id }}</vpcId>
|
||||||
<privateIpAddress>{{ instance.nics[0].private_ip_address }}</privateIpAddress>
|
<privateIpAddress>{{ instance.private_ip }}</privateIpAddress>
|
||||||
{% if instance.nics[0].public_ip %}
|
{% if instance.public_ip %}
|
||||||
<ipAddress>{{ instance.nics[0].public_ip }}</ipAddress>
|
<ipAddress>{{ instance.public_ip }}</ipAddress>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<subnetId>{{ instance.subnet_id }}</subnetId>
|
<subnetId>{{ instance.subnet_id }}</subnetId>
|
||||||
@ -318,8 +318,8 @@ EC2_DESCRIBE_INSTANCES = """<DescribeInstancesResponse xmlns='http://ec2.amazona
|
|||||||
<code>{{ instance._state.code }}</code>
|
<code>{{ instance._state.code }}</code>
|
||||||
<name>{{ instance._state.name }}</name>
|
<name>{{ instance._state.name }}</name>
|
||||||
</instanceState>
|
</instanceState>
|
||||||
<privateDnsName>ip-10.0.0.12.ec2.internal</privateDnsName>
|
<privateDnsName>{{ instance.private_dns }}</privateDnsName>
|
||||||
<dnsName>ec2-46.51.219.63.compute-1.amazonaws.com</dnsName>
|
<publicDnsName>{{ instance.public_dns }}</publicDnsName>
|
||||||
<reason>{{ instance._reason }}</reason>
|
<reason>{{ instance._reason }}</reason>
|
||||||
<keyName>{{ instance.key_name }}</keyName>
|
<keyName>{{ instance.key_name }}</keyName>
|
||||||
<amiLaunchIndex>0</amiLaunchIndex>
|
<amiLaunchIndex>0</amiLaunchIndex>
|
||||||
@ -340,7 +340,7 @@ EC2_DESCRIBE_INSTANCES = """<DescribeInstancesResponse xmlns='http://ec2.amazona
|
|||||||
{% if instance.nics %}
|
{% if instance.nics %}
|
||||||
<subnetId>{{ instance.nics[0].subnet.id }}</subnetId>
|
<subnetId>{{ instance.nics[0].subnet.id }}</subnetId>
|
||||||
<vpcId>{{ instance.nics[0].subnet.vpc_id }}</vpcId>
|
<vpcId>{{ instance.nics[0].subnet.vpc_id }}</vpcId>
|
||||||
<privateIpAddress>{{ instance.nics[0].private_ip_address }}</privateIpAddress>
|
<privateIpAddress>{{ instance.private_ip }}</privateIpAddress>
|
||||||
{% if instance.nics[0].public_ip %}
|
{% if instance.nics[0].public_ip %}
|
||||||
<ipAddress>{{ instance.nics[0].public_ip }}</ipAddress>
|
<ipAddress>{{ instance.nics[0].public_ip }}</ipAddress>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -130,6 +130,12 @@ def random_public_ip():
|
|||||||
random.choice(range(255)))
|
random.choice(range(255)))
|
||||||
|
|
||||||
|
|
||||||
|
def random_private_ip():
|
||||||
|
return '10.{0}.{1}.{2}'.format(random.choice(range(255)),
|
||||||
|
random.choice(range(255)),
|
||||||
|
random.choice(range(255)))
|
||||||
|
|
||||||
|
|
||||||
def random_ip():
|
def random_ip():
|
||||||
return "127.{0}.{1}.{2}".format(
|
return "127.{0}.{1}.{2}".format(
|
||||||
random.randint(0, 255),
|
random.randint(0, 255),
|
||||||
@ -347,6 +353,7 @@ def passes_filter_dict(instance, filter_dict):
|
|||||||
filter_name)
|
filter_name)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def instance_value_in_filter_values(instance_value, filter_values):
|
def instance_value_in_filter_values(instance_value, filter_values):
|
||||||
if isinstance(instance_value, list):
|
if isinstance(instance_value, list):
|
||||||
if not set(filter_values).intersection(set(instance_value)):
|
if not set(filter_values).intersection(set(instance_value)):
|
||||||
@ -355,6 +362,7 @@ def instance_value_in_filter_values(instance_value, filter_values):
|
|||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def filter_reservations(reservations, filter_dict):
|
def filter_reservations(reservations, filter_dict):
|
||||||
result = []
|
result = []
|
||||||
for reservation in reservations:
|
for reservation in reservations:
|
||||||
|
@ -76,14 +76,14 @@ def test_elastic_network_interfaces_with_groups():
|
|||||||
subnet = conn.create_subnet(vpc.id, "10.0.0.0/18")
|
subnet = conn.create_subnet(vpc.id, "10.0.0.0/18")
|
||||||
security_group1 = conn.create_security_group('test security group #1', 'this is a test security group')
|
security_group1 = conn.create_security_group('test security group #1', 'this is a test security group')
|
||||||
security_group2 = conn.create_security_group('test security group #2', 'this is a test security group')
|
security_group2 = conn.create_security_group('test security group #2', 'this is a test security group')
|
||||||
conn.create_network_interface(subnet.id, groups=[security_group1.id,security_group2.id])
|
conn.create_network_interface(subnet.id, groups=[security_group1.id, security_group2.id])
|
||||||
|
|
||||||
all_enis = conn.get_all_network_interfaces()
|
all_enis = conn.get_all_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(2)
|
eni.groups.should.have.length_of(2)
|
||||||
set([group.id for group in eni.groups]).should.equal(set([security_group1.id,security_group2.id]))
|
set([group.id for group in eni.groups]).should.equal(set([security_group1.id, security_group2.id]))
|
||||||
|
|
||||||
|
|
||||||
@requires_boto_gte("2.12.0")
|
@requires_boto_gte("2.12.0")
|
||||||
@ -122,25 +122,30 @@ def test_elastic_network_interfaces_filtering():
|
|||||||
security_group1 = conn.create_security_group('test security group #1', 'this is a test security group')
|
security_group1 = conn.create_security_group('test security group #1', 'this is a test security group')
|
||||||
security_group2 = conn.create_security_group('test security group #2', 'this is a test security group')
|
security_group2 = conn.create_security_group('test security group #2', 'this is a test security group')
|
||||||
|
|
||||||
eni1 = conn.create_network_interface(subnet.id, groups=[security_group1.id,security_group2.id])
|
eni1 = conn.create_network_interface(subnet.id, groups=[security_group1.id, security_group2.id])
|
||||||
eni2 = conn.create_network_interface(subnet.id, groups=[security_group1.id])
|
eni2 = conn.create_network_interface(subnet.id, groups=[security_group1.id])
|
||||||
eni3 = conn.create_network_interface(subnet.id)
|
eni3 = conn.create_network_interface(subnet.id)
|
||||||
|
|
||||||
all_enis = conn.get_all_network_interfaces()
|
all_enis = conn.get_all_network_interfaces()
|
||||||
all_enis.should.have.length_of(3)
|
all_enis.should.have.length_of(3)
|
||||||
|
|
||||||
|
# Filter by NetworkInterfaceId
|
||||||
|
enis_by_id = conn.get_all_network_interfaces([eni1.id])
|
||||||
|
enis_by_id.should.have.length_of(1)
|
||||||
|
set([eni.id for eni in enis_by_id]).should.equal(set([eni1.id]))
|
||||||
|
|
||||||
# Filter by ENI ID
|
# Filter by ENI ID
|
||||||
enis_by_id = conn.get_all_network_interfaces(filters={'network-interface-id':eni1.id})
|
enis_by_id = conn.get_all_network_interfaces(filters={'network-interface-id': eni1.id})
|
||||||
enis_by_id.should.have.length_of(1)
|
enis_by_id.should.have.length_of(1)
|
||||||
set([eni.id for eni in enis_by_id]).should.equal(set([eni1.id]))
|
set([eni.id for eni in enis_by_id]).should.equal(set([eni1.id]))
|
||||||
|
|
||||||
# Filter by Security Group
|
# Filter by Security Group
|
||||||
enis_by_group = conn.get_all_network_interfaces(filters={'group-id':security_group1.id})
|
enis_by_group = conn.get_all_network_interfaces(filters={'group-id':security_group1.id})
|
||||||
enis_by_group.should.have.length_of(2)
|
enis_by_group.should.have.length_of(2)
|
||||||
set([eni.id for eni in enis_by_group]).should.equal(set([eni1.id,eni2.id]))
|
set([eni.id for eni in enis_by_group]).should.equal(set([eni1.id, eni2.id]))
|
||||||
|
|
||||||
# Filter by ENI ID and Security Group
|
# Filter by ENI ID and Security Group
|
||||||
enis_by_group = conn.get_all_network_interfaces(filters={'network-interface-id':eni1.id, 'group-id':security_group1.id})
|
enis_by_group = conn.get_all_network_interfaces(filters={'network-interface-id': eni1.id, 'group-id': security_group1.id})
|
||||||
enis_by_group.should.have.length_of(1)
|
enis_by_group.should.have.length_of(1)
|
||||||
set([eni.id for eni in enis_by_group]).should.equal(set([eni1.id]))
|
set([eni.id for eni in enis_by_group]).should.equal(set([eni1.id]))
|
||||||
|
|
||||||
@ -157,7 +162,7 @@ def test_elastic_network_interfaces_cloudformation():
|
|||||||
conn.create_stack(
|
conn.create_stack(
|
||||||
"test_stack",
|
"test_stack",
|
||||||
template_body=template_json,
|
template_body=template_json,
|
||||||
)
|
)
|
||||||
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]
|
||||||
|
|
||||||
|
@ -491,23 +491,23 @@ def test_instance_with_nic_attach_detach():
|
|||||||
eni = conn.create_network_interface(subnet.id, groups=[security_group2.id])
|
eni = conn.create_network_interface(subnet.id, groups=[security_group2.id])
|
||||||
|
|
||||||
# Check initial instance and ENI data
|
# Check initial instance and ENI data
|
||||||
instance.interfaces.should.have.length_of(0)
|
instance.interfaces.should.have.length_of(1)
|
||||||
|
|
||||||
eni.groups.should.have.length_of(1)
|
eni.groups.should.have.length_of(1)
|
||||||
set([group.id for group in eni.groups]).should.equal(set([security_group2.id]))
|
set([group.id for group in eni.groups]).should.equal(set([security_group2.id]))
|
||||||
|
|
||||||
# Attach
|
# Attach
|
||||||
conn.attach_network_interface(eni.id, instance.id, device_index=0)
|
conn.attach_network_interface(eni.id, instance.id, device_index=1)
|
||||||
|
|
||||||
# Check attached instance and ENI data
|
# Check attached instance and ENI data
|
||||||
instance.update()
|
instance.update()
|
||||||
instance.interfaces.should.have.length_of(1)
|
instance.interfaces.should.have.length_of(2)
|
||||||
instance_eni = instance.interfaces[0]
|
instance_eni = instance.interfaces[1]
|
||||||
instance_eni.id.should.equal(eni.id)
|
instance_eni.id.should.equal(eni.id)
|
||||||
instance_eni.groups.should.have.length_of(2)
|
instance_eni.groups.should.have.length_of(2)
|
||||||
set([group.id for group in instance_eni.groups]).should.equal(set([security_group1.id,security_group2.id]))
|
set([group.id for group in instance_eni.groups]).should.equal(set([security_group1.id,security_group2.id]))
|
||||||
|
|
||||||
eni = conn.get_all_network_interfaces(eni.id)[0]
|
eni = conn.get_all_network_interfaces(filters={'network-interface-id': eni.id})[0]
|
||||||
eni.groups.should.have.length_of(2)
|
eni.groups.should.have.length_of(2)
|
||||||
set([group.id for group in eni.groups]).should.equal(set([security_group1.id,security_group2.id]))
|
set([group.id for group in eni.groups]).should.equal(set([security_group1.id,security_group2.id]))
|
||||||
|
|
||||||
@ -516,9 +516,9 @@ def test_instance_with_nic_attach_detach():
|
|||||||
|
|
||||||
# Check detached instance and ENI data
|
# Check detached instance and ENI data
|
||||||
instance.update()
|
instance.update()
|
||||||
instance.interfaces.should.have.length_of(0)
|
instance.interfaces.should.have.length_of(1)
|
||||||
|
|
||||||
eni = conn.get_all_network_interfaces(eni.id)[0]
|
eni = conn.get_all_network_interfaces(filters={'network-interface-id': eni.id})[0]
|
||||||
eni.groups.should.have.length_of(1)
|
eni.groups.should.have.length_of(1)
|
||||||
set([group.id for group in eni.groups]).should.equal(set([security_group2.id]))
|
set([group.id for group in eni.groups]).should.equal(set([security_group2.id]))
|
||||||
|
|
||||||
@ -530,6 +530,18 @@ def test_instance_with_nic_attach_detach():
|
|||||||
cm.exception.request_id.should_not.be.none
|
cm.exception.request_id.should_not.be.none
|
||||||
|
|
||||||
|
|
||||||
|
@mock_ec2
|
||||||
|
def test_ec2_classic_has_public_ip_address():
|
||||||
|
conn = boto.connect_ec2('the_key', 'the_secret')
|
||||||
|
reservation = conn.run_instances('ami-1234abcd', key_name="keypair_name")
|
||||||
|
instance = reservation.instances[0]
|
||||||
|
instance.ip_address.should_not.equal(None)
|
||||||
|
instance.public_dns_name.should.contain(instance.ip_address)
|
||||||
|
|
||||||
|
instance.private_ip_address.should_not.equal(None)
|
||||||
|
instance.private_dns_name.should.contain(instance.private_ip_address)
|
||||||
|
|
||||||
|
|
||||||
@mock_ec2
|
@mock_ec2
|
||||||
def test_run_instance_with_keypair():
|
def test_run_instance_with_keypair():
|
||||||
conn = boto.connect_ec2('the_key', 'the_secret')
|
conn = boto.connect_ec2('the_key', 'the_secret')
|
||||||
|
Loading…
Reference in New Issue
Block a user