ip_protocol for ec2 security groups

fix for bug 1057196.
-Enforce restrictions on IP protocol in AuthorizeSecurityGroupIngress call.
 This value may only be: 'tcp', 'udp', 'icmp', '6', '17' or '1'
-Ensure that ip protocol returned from DescribeSecurityGroups is in lower case,
 in case security group was set improperly in previous versions
-Update EC2APIError in nova/exception.py to remove the HTTP error code from the
 message. The HTTP error code is inserted in nova.api.ec2.faults.Fault. Inserting
 the code in the EC2APIError causes the HTTP code to appear twice in the message
-Update unit tests to expect new error message when invalid protocol is entered.
-Fixing pep8 issues

Change-Id: Iffe0f38abde327288e6a3960a72ad6a273f78aca
This commit is contained in:
John Herndon
2012-10-02 19:39:37 +00:00
parent 8d676a1096
commit afc88c0a3e
2 changed files with 2 additions and 5 deletions

View File

@@ -164,10 +164,7 @@ class EC2APIError(NovaException):
def __init__(self, message=None, code=None):
self.msg = message
self.code = code
if code:
outstr = '%s: %s' % (code, message)
else:
outstr = '%s' % message
outstr = '%s' % message
super(EC2APIError, self).__init__(outstr)

View File

@@ -448,7 +448,7 @@ class ApiEc2TestCase(test.TestCase):
# Invalid Cidr for ICMP type
_assert('Invalid CIDR', 'icmp', -1, -1, '0.0.444.0/4')
# Invalid protocol
_assert('An unknown error has occurred', 'xyz', 1, 14, '0.0.0.0/0')
_assert('Invalid IP protocol', 'xyz', 1, 14, '0.0.0.0/0')
# Invalid port
_assert('An unknown error has occurred', 'tcp', " ", "81", '0.0.0.0/0')
# Invalid icmp port