Merge "Handle instances not being found in EC2 API responses." into stable/folsom
This commit is contained in:
commit
7e70428477
|
@ -129,7 +129,9 @@ def id_to_ec2_id(instance_id, template='i-%08x'):
|
||||||
|
|
||||||
def id_to_ec2_inst_id(instance_id):
|
def id_to_ec2_inst_id(instance_id):
|
||||||
"""Get or create an ec2 instance ID (i-[base 16 number]) from uuid."""
|
"""Get or create an ec2 instance ID (i-[base 16 number]) from uuid."""
|
||||||
if utils.is_uuid_like(instance_id):
|
if instance_id is None:
|
||||||
|
return None
|
||||||
|
elif utils.is_uuid_like(instance_id):
|
||||||
ctxt = context.get_admin_context()
|
ctxt = context.get_admin_context()
|
||||||
int_id = get_int_id_from_instance_uuid(ctxt, instance_id)
|
int_id = get_int_id_from_instance_uuid(ctxt, instance_id)
|
||||||
return id_to_ec2_id(int_id)
|
return id_to_ec2_id(int_id)
|
||||||
|
|
|
@ -312,6 +312,18 @@ class CloudTestCase(test.TestCase):
|
||||||
self.cloud.disassociate_address,
|
self.cloud.disassociate_address,
|
||||||
self.context, public_ip=address)
|
self.context, public_ip=address)
|
||||||
|
|
||||||
|
def test_disassociate_unassociated_address(self):
|
||||||
|
address = "10.10.10.10"
|
||||||
|
db.floating_ip_create(self.context,
|
||||||
|
{'address': address,
|
||||||
|
'pool': 'nova'})
|
||||||
|
self.cloud.allocate_address(self.context)
|
||||||
|
self.cloud.describe_addresses(self.context)
|
||||||
|
self.assertRaises(exception.InstanceNotFound,
|
||||||
|
self.cloud.disassociate_address,
|
||||||
|
self.context, public_ip=address)
|
||||||
|
db.floating_ip_destroy(self.context, address)
|
||||||
|
|
||||||
def test_describe_security_groups(self):
|
def test_describe_security_groups(self):
|
||||||
"""Makes sure describe_security_groups works and filters results."""
|
"""Makes sure describe_security_groups works and filters results."""
|
||||||
sec = db.security_group_create(self.context,
|
sec = db.security_group_create(self.context,
|
||||||
|
|
|
@ -116,6 +116,15 @@ class ExecutorTestCase(test.TestCase):
|
||||||
result = self._execute(not_found)
|
result = self._execute(not_found)
|
||||||
self.assertIn('i-00000005', self._extract_message(result))
|
self.assertIn('i-00000005', self._extract_message(result))
|
||||||
|
|
||||||
|
def test_instance_not_found_none(self):
|
||||||
|
def not_found(context):
|
||||||
|
raise exception.InstanceNotFound(instance_id=None)
|
||||||
|
|
||||||
|
# NOTE(mikal): we want no exception to be raised here, which was what
|
||||||
|
# was happening in bug/1080406
|
||||||
|
result = self._execute(not_found)
|
||||||
|
self.assertIn('None', self._extract_message(result))
|
||||||
|
|
||||||
def test_snapshot_not_found(self):
|
def test_snapshot_not_found(self):
|
||||||
def not_found(context):
|
def not_found(context):
|
||||||
raise exception.SnapshotNotFound(snapshot_id=5)
|
raise exception.SnapshotNotFound(snapshot_id=5)
|
||||||
|
|
Loading…
Reference in New Issue