Merge "Don't allow EC2 removal of security group in use."

This commit is contained in:
Jenkins
2012-02-22 17:41:32 +00:00
committed by Gerrit Code Review
3 changed files with 16 additions and 0 deletions

View File

@@ -286,6 +286,10 @@ class InvalidAggregateAction(Invalid):
"%(aggregate_id)s. Reason: %(reason)s.")
class InvalidGroup(Invalid):
message = _("Group not valid. Reason: %(reason)s")
class InstanceInvalidState(Invalid):
message = _("Instance %(instance_uuid)s in %(attr)s %(state)s. Cannot "
"%(method)s while the instance is in this state.")

View File

@@ -570,6 +570,15 @@ class ApiEc2TestCase(test.TestCase):
self.expect_http()
self.mox.ReplayAll()
# Can not delete the group while it is still used by
# another group.
self.assertRaises(EC2ResponseError,
self.ec2.delete_security_group,
other_security_group_name)
self.expect_http()
self.mox.ReplayAll()
rv = self.ec2.get_all_security_groups()
for group in rv:
@@ -583,3 +592,4 @@ class ApiEc2TestCase(test.TestCase):
self.mox.ReplayAll()
self.ec2.delete_security_group(security_group_name)
self.ec2.delete_security_group(other_security_group_name)

View File

@@ -1821,6 +1821,8 @@ class NWFilterTestCase(test.TestCase):
self.fw.setup_basic_filtering(instance, network_info)
_ensure_all_called(mac)
db.instance_remove_security_group(self.context, inst_uuid,
self.security_group.id)
self.teardown_security_group()
db.instance_destroy(context.get_admin_context(), instance_ref['id'])